I am having trouble and some confusing behaviour while trying to produce a large tikz picture. Here is the minimal example of the problem. I should note that I am doing all the work online on Overleaf.
This is my main file main.tex:
\documentclass{amsart}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
\begin{document}
\begin{tikzpicture} % line X
\input{pic}
\end{tikzpicture} % line Y
\end{document}
The file pic.tex is very large (complete file is here), but basically it looks like this:
\begin{tikzpicture}
[scale=4]
% 10000 lines, each drawing one short segment in a different color
\end{tikzpicture}
The following two strange things happen:
- I get the following result
but I am 100% certain the result should be
For some reason the two thirds of the picture are trimmed.
Note that I actually have two nested tikzpicture environments. For some reason this doesn't throw an error, but if I try to remove one of them by commenting line X and line Y in main.tex, I get the error
TeX capacity exceeded, sorry [main memory size=5000000].
This doesn't make any sense to me, why does having two nested tikzpicture environments help here? Is there a more logical way to do it?
\begin{tikzpicture}[scale=4]
and\end{tikzpicture}
from pic.tex and add[scale=4]
in the main file, everything seems to work. I don't know the internals of TikZ well enough to understand why.