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 have a number of large plots which exhaust memory when I try to compile them with xelatex, so I am using lualatex instead, which is able to compile them without major difficulty.

However, I am unable to get my documents to compile externally. I normally use Texmaker as my editor and build with xelatex, but the problems with externalization happen also when I run pdflatex --shell-escape or xelatex -shell-escape from the command line.

If I run pdflatex --shell-escape <filename>.tex, pdflatex runs with \write18 enabled:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 \write18 enabled.
entering extended mode
(./external.tex

...but terminates with this error:

===== 'mode=convert with system call': Invoking 'lualatex --shell-escape -halt-
on-error -interaction=batchmode -jobname "external-figure0" "\def\tikzexternalr
ealjob{external}\input{external}"' ========
This is LuaTeX, Version beta-0.76.0-2013052800 (rev 4627) 
 \write18 enabled.
Syntax Error: Couldn't read xref table
Syntax Warning: PDF file is damaged - attempting to reconstruct xref table...
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

!pdfTeX error: pdflatex (file ./external-figure0.pdf): xpdf: reading PDF image 
failed
 ==> Fatal error occurred, no output PDF file produced!

If I run xelatex --shell-escape <filename>.tex, xelatex also runs with \write18 enabled:

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013) (format=xelatex 2013.9.6)  18 SEP 2013 18:14
entering extended mode
 \write18 enabled.
 %&-line parsing enabled.
**external.tex
(./external.tex

... but in this case, lualatex stops with this error:

===== 'mode=convert with system call': Invoking 'lualatex --shell-escape -halt-
on-error -interaction=batchmode -jobname "external-figure0" "\def\tikzexternalr
ealjob{external}\input{external}"' ========
This is LuaTeX, Version beta-0.76.0-2013052800 (rev 4627) 
 \write18 enabled.
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table
! Unable to load picture or PDF file 'external-figure0.pdf'.
<to be read again> 
                   }
l.34 \end{tikzpicture}

? 

and waits for input.

Here is my MWE:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{external} 
\pgfplotsset{compat=newest}

\tikzset{external/system call={lualatex --shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize

\begin{document}
\begin{tikzpicture}

\begin{axis}[
height=9cm,
width=9cm,
grid=major,
]
\addplot {-x^5 - 242};
\addlegendentry{model}
\addplot coordinates {
(-4.77778,2027.60977)
(-3.55556,347.84069)
(-2.33333,22.58953)
(-1.11111,-493.50066)
(0.11111,46.66082)
(1.33333,-205.56286)
(2.55556,-341.40638)
(3.77778,-1169.24780)
(5.00000,-3269.56775)
};
\addlegendentry{estimate}
\end{axis}
\end{tikzpicture}
\end{document}

I'm using Tex Live 2013. I also had this problem in Tex Live 2012. It's not clear to me what's wrong here.

share|improve this question
2  
I do find the idea to combine standalone + externalize a bit odd and it is imho not really a surprise that they thread on the other toes. Use either the article class or only standalone. –  Ulrike Fischer Sep 18 '13 at 16:48
add comment

1 Answer 1

Standalone creates an encapsulated PDF image, which can be treated like any other image. Lose the externalize, create a PDF file named (for example) tikz.pdf and run

\documentclass{article}
\usepackage{graphics}

\begin{document}
\begin{center}
\includegraphics{tikz.pdf}
\end{center}
\end{document}

or some variant thereof.

share|improve this answer
    
I have to externalize because the images require too much memory. I have heard from more than a few people that standalone and externalize don't play nicely together. I also don't want to be building images manually. I will have to do these without standalone and build separate wrappers to build the just the graphics for review purposes. –  Stephen Bosch Sep 20 '13 at 21:59
    
Then just lose the externalize for standalone. That's what I did. –  John Kormylo Sep 22 '13 at 14:26
add comment

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.