[OS X TeX] Re: "! LaTeX Error: No counter 'a' defined."

Michael Sharpe msharpe at ucsd.edu
Mon Dec 20 23:46:56 EST 2010


On Dec 20, 2010, at 8:06 PM, John B. Thoo wrote:

> Thank you, Herb S and Don G D, for your replies.
> 
> On Dec 19, 2010, at 12:00 PM, <macosx-tex-request at email.esm.psu.edu> <macosx-tex-request at email.esm.psu.edu> wrote:
> 
>> ------------------------------
>> 
>> Message: 4
>> Date: Sat, 18 Dec 2010 20:14:59 -0600
>> From: Herbert Schulz <herbs at wideopenwest.com>
>> 
>> Well, it looks like something in that chapter is a culprit do you're making some progress.
> 
> Reminiscent of trying to pin down a control panel conflict in ye ole Mac operating systems, I divided the suspect file "ch_numthry.tex" into two parts, A1 and B1, and typeset with only one part.  If only B1 caused errors, e.g., then I divided B1 into two parts, A2 and B2, and typeset with only one part.  Continuing in this way, I narrowed down this piece of code that causes the errors:
> 
> %%%%%%%%%%%%%%%%%%%% begin rogue code %%%%%%%%%%%%%%%%%%%%%%%
> \begin{figure}
> \subfigure[Spiral in Fibonacci rectangles.]{%
>  \begin{tikzpicture}
>  \pgftransformscale{0.4}
> %    \draw[very thin,color=gray] (0,0) grid (15,10);
>    \draw[color=lightgray] (10,6) rectangle (11,7);
>    \draw[color=lightgray] (9,6) rectangle (10,7);
>    \draw[color=lightgray] (9,7) rectangle (11,9);
>    \draw[color=lightgray] (11,6) rectangle (14,9);
>    \draw[color=lightgray] (9,1) rectangle (14,6);
>    \draw[color=lightgray] (1,1) rectangle (9,9);
> 
>    \draw (11,7) arc (0:-90:1);
>    \draw (10,6) arc (-90:-180:1);
>    \draw (9,7) arc (180:90:2);
>    \draw (11,9) arc (90:0:3);
>    \draw (14,6) arc (0:-90:5);
>    \draw (9,1) arc (-90:-180:8);
>  \end{tikzpicture}
> }
> \qquad
> \subfigure[Golden spiral.]{%
>  %% Modified code copied from
>  %% <http://www.texample.net/tikz/examples/fibonacci-spiral/>
>  %%
>  \begin{tikzpicture}%[background rectangle/.style={fill=black},
>                     % show background rectangle] 
>  \pgftransformscale{0.35}
>    % Create some counters for holding the Fibonacci numbers
>    \newcounter{a}
>    \newcounter{b}
>    \newcounter{temp}
> 
>    % Initialize the counters
>    \setcounter{a}{0}
>    \setcounter{b}{1}
> 
>    % The spiral will start at the origin
>    \coordinate (0) at (0,0);
> 
>    % This loop defines the number of turns in the spiral. Note that we
>    % will have to be careful not to overflow our counters or make the
>    % spiral too large for TeX to handle. This is easy to do as the
>    % Fibonacci sequence grows exponentially.
>    \foreach \i in {1,...,18}
>    {
>      % Get the "name" of the last point on the spiral
>      \pgfmathsetmacro{\lastpoint}{\i-1}
> 
>      % Compute the angle for this turn of the spiral
> %      \pgfmathsetmacro{\startangle}{mod(\i-1,4) * 90}
>      \pgfmathsetmacro{\startangle}{mod(\i-1,4) * -90}
> 
>      % Draw this turn of the spiral and remember the point where we end 
> %      \draw[white] (\lastpoint) arc 
>      \draw (\lastpoint) arc 
> %        (\startangle : \startangle + 90 : \value{b}/10.0pt) coordinate (\i);
>        (\startangle : \startangle - 90 : \value{b}/10.0pt) coordinate (\i);
> 
>     % Compute the next Fibonacci number
>      \setcounter{temp}{\value{b}}
>      \addtocounter{b}{\value{a}}
>      \setcounter{a}{\value{temp}}
>   }
> 
>   % Add some framing for the spiral while at the same time not "boxing"
>   % it in. Note that to put a square around each turn of the spiral we
>   % could have just used the command \draw[white] (\lastpoint)
>   % rectangle (\i); after drawing each turn in the loop above.
>   \foreach \i in {1,3,...,17}
>   {
>     \pgfmathsetmacro{\lastpoint}{\i-1}
> %     \draw[white] (\lastpoint) -| (\i);
>     \draw[color=lightgray] (\lastpoint) -| (\i);
>   }
> 
>   \foreach \i in {2,4,...,16}
>   {
>     \pgfmathsetmacro{\lastpoint}{\i-1}
> %     \draw[white] (\lastpoint) |- (\i);
>     \draw[color=lightgray] (\lastpoint) |- (\i);
>   }
> 
> %   \draw[white] (17) -- (17 |- 18);
>   \draw[color=lightgray] (17) -- (17 |- 18);
> 
> %   % Add some text displaying the formula for the Fibonacci numbers
> %   \node(eq) at ($(18) + (2.5,1)$) 
> %     [white,text width = 2cm,font=\fontsize{8}{8}\selectfont] {
> %     \begin{displaymath}
> %       f(n) = \left\{
> %         \begin{array}{lr}
> %           0 & \text{~~if } n = 0\\
> %           1 & \text{~~if } n = 1\\
> %           f(n-1) + f(n-2) & \text{~~if } n \geq 2\\
> %        \end{array}
> %       \right.
> %     \end{displaymath}
> %    };
>  \end{tikzpicture}
> }
>  \caption{A spiral drawn inside Fibonacci rectangles and a golden spiral drawn inside golden rectangles.}
>  \label{fig.numthry:goldenspiral}
> \end{figure}
> %%%%%%%%%%%%%%%%%%%% end rogue code %%%%%%%%%%%%%%%%%%%%%%%
> 
> Recall that the errors were
> 
> ! LaTeX Error: No counter 'a' defined.
> 
> ! LaTeX Error: No counter 'b' defined.
> 
> ! LaTeX Error: No counter 'temp' defined.
> 
> Also recall that in the preamble I declare
> 
> \usetikzlibrary{decorations.pathreplacing}  % load tikz decorations library
> \usetikzlibrary{calc}  % load the tikz calc library
> 
> But I do not know how to fix the code.  Any suggestions on fixing this piece of code would be appreciated.  Thanks.
> 
> 
>> ------------------------------
>> 
>> Message: 7
>> Date: Sat, 18 Dec 2010 20:33:40 -0700
>> From: Don Green Dragon <fergdc at Shaw.ca>
>> 
>> According to George Gratzer's book "More Math into LaTeX", on page 4 he states:
>> 
>> "The name of a LaTeX source file should be one word (no spaces, no special characters), and end with .tex."
>> 
>>> From your error messages, it appears that you have a source file (for example) <ch.geom.tex> (without < and >) and that first occurrence of '.' may be the culprit. Each of the error messages appears to be complaining about an \include line.
>> 
>> Did you try the suggestion made by Ross Moore?
> 
> I replaced all the extra '.' in the filenames with '_'.  So, e.g., "ch.numthry.tex" is now "ch_numthry.tex".  Thanks.
> 
> Thank you all again.
> 
> ---John.

Your code worked without problems for me. Perhaps you need to update all your packages with TeX Live Manager.

Michael




More information about the MacOSX-TeX mailing list