3

Here is my code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\pgfdeclarelindenmayersystem{Tree}{
  \rule{F -> F [ R [+F] [-F] ]}
  \symbol{R}{
    \pgflsystemstep=0.6\pgflsystemstep
  } 
}
\begin{document}
\begin{tikzpicture}
    \draw l-system [l-system={Tree, axiom=[F], step=20, order=9, angle=60}];
\end{tikzpicture}
\end{document}

It worked earlier this year, but now when I try to use it, it says

Runaway definition?
->\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}\pgfsyssoftpath@linetotoken \ETC.
./lindmanyer.tex:12: TeX capacity exceeded, sorry [main memory size=5000000].
\pgfsyssoftpath@thepath ...oken {23.264pt}{22\ETC.
>                                                  
> l.12 ...], step=20, order=9, angle=60}] l-system ;

I have no idea what causes it and how to fix it.

4
  • I tried the code with TeX Live from 2016 to 2023 and the error is always the same. The library for Lindenmayer systems has basically not changed since 2019.
    – egreg
    Commented May 21, 2023 at 22:06
  • With \pgflsystemstep=0.6\pgflsystemstep the library needs an exhaustive amount of main memory. However the example works without error, if you'd use LuaLaTeX instead of PDFLaTeX or XeLaTeX.
    – cabohah
    Commented May 22, 2023 at 7:35
  • pdftex and xetex use fixed memory sizes. However, you can increase these limits in the config file and then rebuild the formats. This has been answered multiple times here already, e.g., here: tex.stackexchange.com/questions/7953/…. Luatex allocates its memory dynamically, so there is no need to edit the config files if you use luattex.
    – sslbrg
    Commented May 22, 2023 at 8:35
  • With F -> F [R+F] [R-F] and axiom = F (no need for a group here) you can get PDFLaTeX to do order = 9 but not 10 anymore. Commented May 22, 2023 at 8:35

1 Answer 1

0

The example requires an extremely large amount of main memory with PDFLaTeX — more than is usually statically allocated for it. I would therefore recommend compiling the example with LuaLaTeX, which dynamically allocates the required memory.

If in real life the example is an image in a larger document which cannot be converted to LuaLaTeX quickly, try to compile only the tikzpicture environments or alternatively only this one via external library with LuaLaTeX. However, for this it is necessary to activate shell-escape:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\usetikzlibrary{external}
\tikzexternalize[system call={lualatex \tikzexternalcheckshellescape
  -halt-on-error -interachtion=batchmode -jobname "\image" "\texsource"}]

\pgfdeclarelindenmayersystem{Tree}{
  \rule{F -> F [ R [+F] [-F] ]}
  \symbol{R}{
    \pgflsystemstep=0.6\pgflsystemstep
  } 
}
\begin{document}
\begin{tikzpicture}
    \draw l-system [l-system={Tree, axiom=[F], step=20, order=9, angle=60}];
\end{tikzpicture}
\end{document}

enter image description here

Note: Depending on packages you are using, this could fail, e.g., if you are loading a package, that should not be used with lualatex. In this case, it can help to load packages depending by engine, e.g.:

\documentclass{article}
\usepackage{iftex}
\ifluatex
  \usepackage{fontspec}
\else
  \usepackage[ansinew]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{lmodern}
\fi
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\usetikzlibrary{external}
\tikzexternalize[system call={lualatex \tikzexternalcheckshellescape
  -halt-on-error -interachtion=batchmode -jobname "\image" "\texsource"}]

\pgfdeclarelindenmayersystem{Tree}{
  \rule{F -> F [ R [+F] [-F] ]}
  \symbol{R}{
    \pgflsystemstep=0.6\pgflsystemstep
  } 
}
\begin{document}
\begin{tikzpicture}
    \draw l-system [l-system={Tree, axiom=[F], step=20, order=9, angle=60}];
\end{tikzpicture}
\end{document}

As an alternative that does neither need shell-escape nor a change of your document, you can increase the memory allocated for main memory with PDFLaTeX. With MiKTeX you can run

pdflatex --extra_mem_top=1000000 foo.tex

(if foo.tex is the name of your document). With TeX Live you can use, e.g.:

pdflatex -cnf-line="extra_mem_top=700000" foo.tex

The result is the same as shown above.

1
  • Thanks! This works.
    – Gau-Syu
    Commented May 22, 2023 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .