I am writing an article in a multifile project. I use an external template provided by the organisor. I want to use some tikz pictures. I can load other packages at the beginning of my file, but loading {tikz} gives errors:

! Undefined control sequence. \@enddocumenthook ... \ifpgf@external@grabshipout \pgfutil@ifundefined {pgfe... l.22 \end{document} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct spelling (e.g.,I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

! Extra \fi. \@enddocumenthook ...rnal@error@no@shipout }{}\fi l.22 \end{document} I'm ignoring this; it doesn't match any \if.


The main file:






My file:

\title{Lecture Title}
\author{Name Surname}


Without \usepackage{tikz} it does not return any error.

What can I do to fix it?

I suppose this is sth like this: http://latex-community.org/forum/viewtopic.php?f=4&t=5372 but it still does not improve my situation.

  • Where is your file loaded in the main file? And try to put \usepackage{tikz} in the main file before \begin{document}. – Dr. Manuel Kuehner Sep 4 '15 at 17:41
  • My file is loaded between \import{...} - I removed the name of the file intentionally. It is loaded properly if I don't try to load tikz package. Unfortunately, I can't modify the main file. I can only add additional packages at the beginning of my file. And loading other packages works, there is a problem only with tikz. – silver Sep 5 '15 at 11:04
  • Anyway putting \usepackage{tikz} in the main file before \begin{document} also gives an error: ! TeX capacity exceeded, sorry [input stack size=5000]. – silver Sep 5 '15 at 11:19

The second file is preamble.tex? If so: there are document bodies (all text between \begin{document} … \end{document}) in both the loaded and the master file. You may not have more than one of these in one LaTeX document. Try wrapping the parts of preamble.tex that have to go into the document body in \AtBeginDocument{…} instead.

  • Yeah, there is also the second file preamble.tex where are other packages etc. Unfortunately I can't modify the main file or preamble.tex. – silver Sep 5 '15 at 11:19
  • Well, as the code you’ve shown above will give errors, it has to be changed. Are those files maintained by someone, whom you could contact? – The Finn Sep 13 '15 at 15:18

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.