2

I experience a problem when I use tikzscale package to compile figures externally.

The minimal working environment is as follows.

The main.tex:

\documentclass[\myopts]{IEEEtran}

\usepackage{lua-visual-debug}
\usepackage{tikzscale}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,calc,patterns}
\usetikzlibrary{er}
\usepackage{tikz-3dplot}

\usepackage{pgfplots}
\usepackage{currfile}
\usepackage{lmodern}

\usetikzlibrary{shapes}
\usepgflibrary{shapes.geometric}

\usetikzlibrary{external}
\tikzexternalize[prefix=figure-build/]

% Use the package ifpdf to share one test document between pdflatex and latex
\usepackage{ifpdf}

\ifpdf
\else
    \tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"; dvips -E -o "\image".eps "\image".dvi; ps2pdf "\image".eps "\image".pdf;}}
\fi

\begin{document}

\begin{figure*}[bth]
    \includegraphics[height=3.25in,width=5.25in]{FileDef-Fig}
    \caption{\small {text}}
\end{figure*}

\end{document}

The content of the file FileDef-Fig.tikz looks like:

\begin{tikzpicture}
........
\end{tikzpicture}

I compile this main.tex file by

pdflatex --shell-escape "\def\myopts{"conference,10pt"}\input{main}"

However, this command complains that the macro \myopts can not be found in the log file.

! Undefined control sequence.
<argument> \myopts

This error message is reported in the following command when the figure is compiled by an automatically generated command:

pdflatex -shell-escape \
         -halt-on-error \
         -interaction=batchmode \
         -jobname "figure-build/main-figure0" \
  "\def\tikzexternalrealjob{main} \input{main}"

My question is how to add a \def\myopts{...} in the above pdflatex command to make it looks like:

pdflatex -shell-escape \
         -halt-on-error \
         -interaction=batchmode \
         -jobname "figure-build/main-figure0" \
  "\def\myopts{...} \def\tikzexternalrealjob{main} \input{main}".
  • I'm not really sure what you're asking... perhaps you should walk through the tikzscale documentation as a starting point (with texdoc tikzscale) and make sure you're not missing a step. I'm sorry I'm not more familiar with the package :( but I'm sure someone else is. – Sean Allred Aug 05 '13 at 04:12
  • Does tikzscale itself externalize TikZ pictures? The external library is actually used to pdflatex the document again, you can insert \def\opts{…} here too if it setup correctly. Can you edit your question to include a minimal working example (MWE)? – Qrrbrbirlbel Aug 05 '13 at 04:18

1 Answers1

2

You need to set \myopts for external system call, too.

Add \string\def\string\myopts{\myopts} in front of \texsource.

The \string writes the macros \def and \myopts as they are without expanding them (or trying to). The second \myopts should be expanded, of course.

(By the way, I have used

pdflatex --shell-escape "\def\myopts{conference,10pt}\input{<file name>}"

without the extra " in the \myopts definition.)

Code

\documentclass[\myopts]{IEEEtran}
\usepackage{tikzscale}
\usepackage{pgfplots}
\usepackage{lmodern}
\usetikzlibrary{external}
\tikzexternalize[prefix=figure-build/]

% Use the package ifpdf to share one test document between pdflatex and latex
\usepackage{ifpdf}

\ifpdf
  \tikzset{external/system call={%
    pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode
      -jobname "\image" "\string\def\string\myopts{\myopts}\texsource"}}
\else
  \tikzset{external/system call={%
    latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode
      -jobname "\image" "\string\def\string\myopts{\myopts}\texsource";
      dvips -E -o "\image".eps "\image".dvi; ps2pdf "\image".eps "\image".pdf;}}
\fi

\begin{document}
\begin{figure*}[bth]
    \includegraphics[height=3.25in,width=5.25in]{FileDef-Fig}
    \caption{\small {text}}
\end{figure*}
\end{document}
Qrrbrbirlbel
  • 119,821
  • Thank you very much for the suggestion. It worked. Another question appears. The externally compiled tikz figures are not rebuilt after modifications. I have to manually remove the .dep, .dpth, .log, .table, and .pdf files. Then, a .pdf file is rebuilt. How to deal with the issue of making tikz externalization to automatically rebuild figures after modifications are made? – Novice User Aug 06 '13 at 14:28