I am writing a paper, which includes several large tikz figures and I am having a lot of problems. I read a lot of posts about this, but no approach seems to work.
I am working with texstudio 4.5.2 and I am using Miktex.
I tried different things, so I will explain chronological. At the end, I summarize the problems. You also find a MWE at the end, which captures the last try, which ends in an error.
In my paper, I would like to add some large figures, which should also be used in other documents with different format settings. At the beginning, I started using separate .tikz-files by \input{} with the following PDFlatex-configuration in texstudio:
pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex
but I received the following error message:
TeX capacity exceeded, sorry [main memory size=5000000]. ...city=0.7 ] ({x},{y},{testfunction(x, y)});
Then I changed the PDFlatex configuration to:
pdflatex.exe -synctex=1 -interaction=nonstopmode --extra-mem-top=10000000 %.tex
This worked, so my main document is compiled. But the new problem is, that each compilation oif the main file takes very long time, since each large tikz figure has to be compiled once again.
Therefore, I tried to use standalone tikz figures and import the .pdfs. But the problem is, that size and font size don't match my document. I know, that I could change the standalone settings, such that these properties match with the main document. But I would always have to change the settings, if I want to use the figures in other documents with different styles (one column, two columns...), what is annoying and not comfortable.
Therefore, I changed my tikz-settings to enable externalization in the preamble. I also adapted the PDFlatex-configuration once again to:
pdflatex.exe -synctex=1 -interaction=nonstopmode --extra-mem-top=10000000 --shell-escape %.tex
As long as the figures are small (e.g. by setting samples=10), externalization seems to work normal. But when I increase the samples (e.g. samples=100), I get an error message, even if it compiles:
Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
If I recompile without any changes, it takes the same time as before, which means that externalizing the .tikz-files does not work or has no advantage?
So summurized:
- increasing memory by adding
--extra-mem-top=10000000worked for large standalone files, but is not usefull, since main document settings might change and figures do not appear as if compiled with\input{.tikz} - externalizing seems to work, as long as
.tikzfigures are small. When they get too large, the error Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-error occurs. - externalizing does not seem to speed up compilation for large figures.
So what am I doing wrong? How would you work with several large figures?
Below you find the main file:
\documentclass[conference]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/] %Pfad, wo die Daten abgelegt werden sollen
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{pgfplots.groupplots}
\usepgfplotslibrary{colormaps}%
\usepackage{lipsum}
\begin{document}
\section{Introduction}
\lipsum[2]
\begin{figure}[h]
\input{./figures/large_tikz_figure.tikz}
\caption{Tikz with input }
\end{figure}
\begin{figure}[h]
\includegraphics[width=\columnwidth]{./figures/large_tikz_figure_standalone.pdf}
\caption{standalone tikz pdf}
\end{figure}
\end{document}
The large_tiks_figure_standalone.tex
\documentclass[crop,tikz]{standalone}%
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}%
\pgfmathdeclarefunction{testfunction}{2}{%
\pgfmathparse{#1#1+#2#2}%
}
\pgfplotsset{
colormap={whiteblue}{color(0)=(white); color(0.1)=(blue)}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={45}{45},
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
xmin=-3,
ymin=-3,
xmax=3,
ymax=3,
zmin=0,
zmax=5,
axis on top=true,
clip mode=individual,
ticks=none,
width=\columnwidth]
%plot test function
\addplot3 [surf, colormap name=whiteblue, samples=100,domain=-3:3,shader=interp, fill opacity=0.7 ] ({x},{y},{testfunction(x, y)});
\node[ left ,align=center] at (1,1) {test};
\end{axis}
\end{tikzpicture}
\end{document}
and the extern large_tikz_figure.tikz
\pgfmathdeclarefunction{testfunction}{2}{%
\pgfmathparse{#1*#1+#2*#2}%
}
\pgfplotsset{
colormap={whiteblue}{color(0)=(white); color(0.1)=(blue)}
}
\begin{tikzpicture}
\begin{axis}[
view={45}{45},
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
xmin=-3,
ymin=-3,
xmax=3,
ymax=3,
zmin=0,
zmax=5,
axis on top=true,
clip mode=individual,
ticks=none,
width=\columnwidth] % \columnwidth does not seem to work here?
%plot test function
\addplot3 [surf, colormap name=whiteblue, samples=100,domain=-3:3,shader=interp, fill opacity=0.7 ] ({x},{y},{testfunction(x, y)});
\node[ left ,align=center] at (1,1) {test};
\end{axis}
\end{tikzpicture}
And the error from the log file
===== 'mode=convert with system call': Invoking 'pdflatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "figures/main-figure0" "\def\tikzextern
alrealjob{main}\input{main}"' ========
runsystem(pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname
"figures/main-figure0" "\def\tikzexternalrealjob{main}\input{main}")...execute
d.
\openout3 = `main.auxlock'.
! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "figures/main-figure0" "\def\tikzexternalr
ealjob{main}\input{main}"' did NOT result in a usable output file 'figures/main
-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have
enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes
it is also named 'write 18' or something like that. Or maybe the command simpl
y failed? Error messages can be found in 'figures/main-figure0.log'. If you con
tinue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.34 \end{tikzpicture}
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.
LaTeX Font Info: External font cmex10' loaded for size (Font) <7> on input line 1. LaTeX Font Info: External fontcmex10' loaded for size
(Font) <5> on input line 1.
)
\openout3 = `figures/main-figure1.md5'.
\openout3 = `main.auxlock'.
===== 'mode=convert with system call': Invoking 'pdflatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "figures/main-figure1" "\def\tikzextern
alrealjob{main}\input{main}"' ========
runsystem(pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname
"figures/main-figure1" "\def\tikzexternalrealjob{main}\input{main}")...execute
d.
\openout3 = `main.auxlock'.
! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "figures/main-figure1" "\def\tikzexternalr
ealjob{main}\input{main}"' did NOT result in a usable output file 'figures/main
-figure1' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have
enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes
it is also named 'write 18' or something like that. Or maybe the command simpl
y failed? Error messages can be found in 'figures/main-figure1.log'. If you con
tinue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.68 \end{tikzpicture}
(That was another \errmessage.)
LaTeX Warning: h' float specifier changed toht'.
<./figures/large_tikz_figure_standalone.pdf, id=12, 322.09235pt x 252.676pt>
File: ./figures/large_tikz_figure_standalone.pdf Graphic file (type pdf)
<use ./figures/large_tikz_figure_standalone.pdf>
Package pdftex.def Info: ./figures/large_tikz_figure_standalone.pdf used on in
put line 73.
(pdftex.def) Requested size: 252.0pt x 197.69565pt.
LaTeX Warning: h' float specifier changed toht'.
** Conference Paper **
Before submitting the final camera ready copy, remember to:
- Manually equalize the lengths of two columns on the last page
of your paper;
- Ensure that any PostScript and/or PDF output post-processing
uses only Type 1 fonts and that every step in the generation
process uses the appropriate paper size.
[1
{C:/Users/\Userx/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}{C:/Users/
\Userx/AppData/Local/Programs/MiKTeX/fonts/enc/dvips/base/8r.enc} <./figures
/large_tikz_figure_standalone.pdf>] (main.aux)
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-06-30>
)
Here is how much of TeX's memory you used:
24417 strings out of 475550
739689 string characters out of 5760645
6321070 words of memory out of 9390832
45262 multiletter control sequences out of 15000+600000
584144 words of font info for 81 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
102i,12n,107p,727b,2742s stack positions out of 10000i,1000n,20000p,200000b,200000s




memoizewould make it to CTAN soon. – cfr Oct 13 '23 at 19:22