Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to combine several articles into a single volume using the combine document class. Some of the articles use the TikZ package, which seems to cause problems during compilation. For example, if my main file is

\documentclass{combine}
\usepackage{tikz}
\begin{document}
\begin{papers}
\coltoctitle{Paper 1}
\coltocauthor{A.~Author}
\import{./author1/paper}
\end{papers}
\end{document}

and the document paper.tex in the directory author1 has the contents

\documentclass{article}
\title{My Paper}
\author{A.~Author}
\date{2013}
\begin{document}
\maketitle
My paper.
\end{document}

then compiling the main document fails with the message ! TeX capacity exceeded, sorry [save size=5000]. But if I remove the TikZ package from the main document, then everything works fine. (Of course that's not an option when the included file actually makes use of the package.) Short of manually converting all the TikZ pictures to image files, is there any way to fix this?

share|improve this question
    
Try to compile your document with LuaTex, ie lualatex mydocument.tex. –  pluton Aug 2 '13 at 17:04

1 Answer 1

up vote 4 down vote accepted

That seems to be an incompatibility; something around the everyshi package and the hooks which are installed by tikz cause an endless loop.

I am unaware of immediate fixes for the root cause (which would be fine; I suggest you ask the author of the combine package on what is going on), but one way might be to use the external library.

Here, I want to elaborate the use of the external library. It may or may not be an option; but it could be worth a try.

Assume that all your included papers which make use of tikz also use the external library which is shipped with tikz. As a consequence, all their pictures are also available as separate .pdfs. Then (and only then) can you get rid of \usepackage{tikz}. Clearly, you want to avoid the necessity to touch every input file! Fortunately, the external lib comes with an option which does not need tikz but can read the external .pdfs.

To this end, you have to uncomment every \usepackage{tikz} and use \usepackage{tikzexternal} instead. The file tikzexternal.sty is a style file which kind of "supports" the environment \begin{tikzpicture} ...\end{tikzpicture} in the sense that it replaces the environment by the associated externalized .pdf - without more action from your part.

The only problem is that the papers might contain preamble configurations. These would need to be deactivated. Fortunately, the tikzexternal package already deactivates \tikzset, \pgfkeys and some more. You can deactivate more if you need to (by defining any undefined macros by dummies).

Here is your minimal example:

main document:

\documentclass{combine}
\usepackage{tikzexternal}
\begin{document}
\begin{papers}
\coltoctitle{Paper 1}
\coltocauthor{A.~Author}
\import{paper}
\end{papers}
\end{document}

file paper.tex:

\documentclass{article}
\title{My Paper}
\author{A.~Author}
\date{2013}

\usepackage{tikzexternal}
%\usetikzlibrary{external}
\tikzexternalize

\tikzset{/some/option/.initial=just to see what happens}

\begin{document}
\maketitle
My paper.

\begin{tikzpicture}
    \draw (0,0) grid (10,10);
\end{tikzpicture}
\end{document}

You see that I modified paper.tex such that it actually makes use of tikz.

Naturally, you would need to compile it first with tikz and its external library, i.e. you would need to (a) reactivate \usepackage{tikz} and \usetikzlibrary{external} (b) deactivate \usepackage{tikzexternal} and run pdflatex -shell-escape paper.tex. Then, switch back to tikzexternal (i.e. to the code above) and compile main.tex as usual.

If you have papers containing pgfplots code, you may need to uncomment \usepackage{pgfplots} as well and say

\def\pgfplotsset#1{}

in order to replace its configuration macro by an empty dummy.

POSSIBLE CAVEATS:

  • tikzexternal.sty might not reflect recent changes in tikz, i.e. it may be incomplete or buggy.
  • if the papers make use of \label or \ref to reference images inside of pgfplots code, I do not really know if tikzexternal.sty is able to resolve these special reference. This is a special case.
share|improve this answer
    
I don't seem to have the external library in my distribution, nor can I find it in the most recent pgf distribution available on CTAN. Where should I be looking? –  Annie Carter Aug 3 '13 at 17:15
1  
    
it was originally intented for guys who do not even have tikz, so it should be ok if you copy-paste it to your installation (into the current working directory) –  Christian Feuersänger Aug 3 '13 at 19:54
    
This worked beautifully with the first paper. The second paper is failing to compile when \tikzexternalize is present. The log file for the first picture file says ! Package graphics Error: Division by 0. The strange thing is that, as far as I can tell, I can compile any individual part of the file that doesn't include more than one tikzpicture environment. I can get partway through the paper by successively uncommenting the pictures, but this breaks down before I've finished. –  Annie Carter Aug 5 '13 at 22:24
    
That sounds strange. If I am not mistaken, it is unrelated to tikzexternal.sty; it is just the externalization of the images as such. Perhaps the second paper redefines something or has other special settings which hamper the operation. I fear you will need to isolate the problem (as minimal working example) and ask a new question. –  Christian Feuersänger Aug 6 '13 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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