2014-09-01 137 views
0

我想從文件中讀取一些座標,然後使用TikZ繪製它們。 該文件是格式如下:TeX容量超過,輸入堆棧大小

timestamp 1.002132 3.2131231 
timestamp 1.332132 2.9120 

這是我的代碼:

\begin{tikzpicture} 

    \draw[step=0.5,black,thin,xshift=0cm,yshift=0cm, opacity=0.3] (0,0) grid (8,4); 

    \draw [->](-.5,.5) -- (8.5,.5); 
    \draw [->] (4, -.5) -- (4, 4.5); 

    % read file and draw coordinates 
     \newread\file 
     \openin\file=recording2 
     \loop 
      \read\file to\fileline 
      \unless\ifeof\file 

      % Fetch coordinates in \coordX and \coordY 
      \StrSplit{\fileline}{14}{\ts}{\coords} 
      \def\coordX{\StrBefore{\coords}{ }} 
      \def\coordY{\StrBehind{\coords}{ }} 

      \draw (1,1) node {\coordX}; %this works fine 
      \draw (1,1) node {\coordY}; %this works fine 
      \draw (\coordX+4,\coordY+0.5) circle(1pt); %this cause the error 
     \repeat 
     \closein\file 

    \end{tikzpicture} 

我已經印雙方coordX和coordY的價值觀,他們是正確的。 你有什麼想法是什麼導致錯誤?爲了讓TikZ將數值解釋爲數值,我是否必須「投射」這些值?

我已經嘗試編輯LaTeX的內存設置沒有運氣,所以我假設錯誤是在代碼中(duh-uh)。

回答

2

嗯,我想我找出了爲什麼它不起作用。

xstring包:

The macros of this package are not purely expandable 

我相信這就是爲什麼我coordXcoordY不能作爲參數進行評估。

我解決它通過切換

\def\coordX{\StrBefore{\coords}{ }} 
\def\coordY{\StrBehind{\coords}{ }} 

\StrBefore{\coords}{ }[\coordX] 
\StrBehind{\coords}{ }[\coordY] 

這是apparantly去與xstring的方式。