2

I am getting a TeX capacity exceeded error when running the following example code (which comes from the answer to this question:

\documentclass{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{tikz}
\usetikzlibrary{calc, hobby}
\tikzset{tangent/.style = \tikzset{
        tangent/.style = {
            in angle={(180+#1)},
            Hobby finish,
            designated Hobby path=next,
            out angle=#1
        }
    }}

\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}

        \coordinate (y) at (0,3);
        \coordinate (x) at (5,0);

        \coordinate (sp0) at (1.5, 0);
        \coordinate (ep0) at (3.5, 2);
        \coordinate (csp0) at (2.5, 1);
        \coordinate (cep0) at (2.75, 0);

        \coordinate (sp1) at (ep0);
        \coordinate (ep1) at (4.5, 3);
        \coordinate (csp1) at (4.25, 4);
        \coordinate (cep1) at (4.25, 2);

        \coordinate (sp2) at (sp0);
        \coordinate (ep2) at (0, -1);
        \coordinate (csp2) at (0.5, -1);
        \coordinate (cep2) at (0.5, -1);

        \draw[<->] (y) node[left] {$f(x)$} -- (0,0) --  (x) node[below] {$x$};

        % Using \pgfmathanglebetweenpoints to calculate the angle for tangent
        % tangent takes a degree unit angle
        \pgfmathanglebetweenpoints{\pgfpointanchor{cep0}{center}}{\pgfpointanchor{ep0}{center}}
        \let\angle=\pgfmathresult
        \draw (ep2) to [curve through ={(sp0) .. ([tangent=\angle]ep0)}] (ep1) ;

        \draw[dashed] (cep0) -- (csp1);
        \draw[dotted] let \p1 = (ep0) in (ep0) -- (0, \y1);
        \draw[dotted] let \p1 = (ep0) in (ep0)-- (\x1, 0);

        \draw let \p1 = (ep0) in (\x1,1pt) -- (\x1,-3pt) node[anchor=north] {$x_0$};
        \draw let \p1 = (cep0) in (\x1,1pt) -- (\x1,-3pt) node[anchor=north] {$x_1$};
        \draw let \p1 = (ep0) in (1pt, \y1) -- (-3pt, \y1) node [anchor=east] {$f(x_0)$};
        \end{tikzpicture}
        \caption{Newton's method in action: diagram drawn using the \texttt{hobby} package.}
        \label{fig:newton_method_2}
    \end{figure}
\end{document}

The full error from the log being:

! TeX capacity exceeded, sorry [parameter stack size=10000].
\pgfkeys@@qset #1#2#3->
                       \def \pgfkeysdefaultpath {#2/}\pgfkeys@parse #3,\pgfk...
l.85 ...h ={(sp0) .. ([tangent=\angle]ep0)}] (ep1)
                                                   ;
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

Searches for this error have revealed to me that the solutions are sometimes pretty arcane...so I am not sure where the issue with this lies at all. Could I simply "increase capacity" as suggested by the error message?

4

You are trying to set a style as part of the definition of that style. So TiKZ ties itself in knots as the settings are viciously recursive.

\documentclass{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{tikz}
\usetikzlibrary{calc, hobby}
\tikzset{
        tangent/.style = {
            in angle={(180+#1)},
            Hobby finish,
            designated Hobby path=next,
            out angle=#1
        }
    }

\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}

        \coordinate (y) at (0,3);
        \coordinate (x) at (5,0);

        \coordinate (sp0) at (1.5,0);
        \coordinate (ep0) at (3.5,2);
        \coordinate (csp0) at (2.5,1);
        \coordinate (cep0) at (2.75,0);

        \coordinate (sp1) at (ep0);
        \coordinate (ep1) at (4.5,3);
        \coordinate (csp1) at (4.25,4);
        \coordinate (cep1) at (4.25,2);

        \coordinate (sp2) at (sp0);
        \coordinate (ep2) at (0,-1);
        \coordinate (csp2) at (0.5,-1);
        \coordinate (cep2) at (0.5,-1);

        \draw[<->] (y) node[left] {$f(x)$} -- (0,0) --  (x) node[below] {$x$};

        % Using \pgfmathanglebetweenpoints to calculate the angle for tangent
        % tangent takes a degree unit angle
        \pgfmathanglebetweenpoints{\pgfpointanchor{cep0}{center}}{\pgfpointanchor{ep0}{center}}
        \let\angle=\pgfmathresult
        \draw (ep2) to [curve through ={(sp0) .. ([tangent=\angle]ep0)}] (ep1) ;

        \draw[dashed] (cep0) -- (csp1);
        \draw[dotted] let \p1 = (ep0) in (ep0) -- (0,\y1);
        \draw[dotted] let \p1 = (ep0) in (ep0)-- (\x1,0);

        \draw let \p1 = (ep0) in (\x1,1pt) -- (\x1,-3pt) node[anchor=north] {$x_0$};
        \draw let \p1 = (cep0) in (\x1,1pt) -- (\x1,-3pt) node[anchor=north] {$x_1$};
        \draw let \p1 = (ep0) in (1pt,\y1) -- (-3pt,\y1) node [anchor=east] {$f(x_0)$};
        \end{tikzpicture}
        \caption{Newton's method in action: diagram drawn using the \texttt{hobby} package.}
        \label{fig:newton_method_2}
    \end{figure}
\end{document}

I don't know if they caused problems here, but note that TiKZ/PGF can also be sensitive to spaces, so be consistent in your usage.

Newton redux

2
  • Oh my god. I have made too many typos today. Thanks so much for helping me out with this. – user89 Feb 1 '15 at 1:20
  • @user89 Well. It is always easier to spot other people's ;). – cfr Feb 1 '15 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.