[Tex/LaTex] TikZ error for externalized graphics but output is correct

debuggingtikz-externaltikz-pgf

This is not an MWE per se, but it is the code I boiled the problem down to. Note: it does not produce an error.

The issue is that once I somehow managed to get an error for any TikZ or pgfplots graphic (due to any sort of mishap: missing bracket, semicolon or any other thing I suppose), the error message "--shell-escape -halt-
on-error -interaction=batchmode -jobname
" (and so forth…) comes up. Yet all graphics and edits to them get produced properly as far as I can tell. But the message won't go away.

I'm at a point where I'm totally clueless about it all. Is there a catch in connection to externalized TikZ/pgfplots-graphics? Any help or hints would be greatly appreciated. 🙂

Notes

The error message only goes away if I remove/comment out

  • the footnotetext– and \addtocounter-commands after each figure with a tikzpicture in it or

  • \tikzexternalize

Does the editor (TeXstudio) make a difference?

  • No, the problem appears in the same manner, whether I hit F1 in TeXstudio or run pdflatex from the command line.

Log for running pdflatex from Windows' cmd

http://pastebin.com/vHqE5isd

Log for running pdflatex –shell-escape from Windows' cmd

http://pastebin.com/0JZCij4T

MWE

\documentclass[
a4paper
]{scrartcl}

\usepackage{
    newtxtext,
    amsmath,
    subcaption,
    biblatex
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{
    external,
}
\tikzexternalize

\listfiles

\begin{document}
\begin{figure}[tp]
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        a\\
        \begin{tikzpicture}
        \draw (0,0) rectangle (1,1);
        \end{tikzpicture}
        \subcaption[Something short.]{Something longer. So there is some text.\footnotemark\footnotemark}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        b\\
        \begin{tikzpicture}
        \draw (0,0) rectangle (1,1);
        \end{tikzpicture}
        \subcaption[Text.]{Some longer text and a few words}
    \end{minipage}
\end{figure}
\addtocounter{footnote}{-2}
\footnotetext{\cite[Cp.][12]{Smith}}
\addtocounter{footnote}{1}
\footnotetext{\cite[Cp.][23]{Jones}}



\end{document}

Preamble relating to TikZ and pgfplots with style definitions

%% TikZ

\usetikzlibrary{
    external,
    plotmarks,
    math,
    calc,trees,shadows,positioning,arrows,chains,
    decorations.pathreplacing,
    decorations.pathmorphing,
    decorations.shapes,
    decorations.text,
    shapes,
    shapes.geometric,
    shapes.symbols,
    matrix,
    patterns,
    intersections,
    fit
}
\tikzexternalize

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

%% pgfplots

\usepgfplotslibrary{
    groupplots,
    external
    }

\pgfplotsset{
every axis/.append style={
%%
%tick label style = {font=\sffamily\small\sansmath},
%every axis label = {font=\sffamily\small\sansmath},
%legend style = {font=\sffamily\small\sansmath},
%label style = {font=\sffamily\small\sansmath},
%
xmajorgrids={true},
ymajorgrids={true},
xminorgrids={true},
yminorgrids={true},
%
%line width=1pt,
%thick,
%
minor tick num=1,
%axis lines=middle,
%tick align=center,
compat=1.10,
},
every tick/.append style={
black,
thick
},
/pgf/number format/.cd,
use comma,
1000 sep={\,},
}

\tikzexternalize

File list

*File List*
scrartcl.cls    2013/12/19 v3.12 KOMA-Script document class (article)
scrkbase.sty    2013/12/19 v3.12 KOMA-Script package (KOMA-Script-dependent bas
ics and keyval usage)
 scrbase.sty    2013/12/19 v3.12 KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2013/12/19 v3.12 KOMA-Script package (loading files)
tocbasic.sty    2013/12/19 v3.12 KOMA-Script package (handling toc-files)
scrsize11pt.clo    2013/12/19 v3.12 KOMA-Script font size class option (11pt)
typearea.sty    2013/12/19 v3.12 KOMA-Script package (type area)
newtxtext.sty    2014/04/07 v1.25
fontaxes.sty    2014/03/23 v1.0d Font selection axes
 xkeyval.sty    2012/10/14 v2.6b package option processing (HA)
 xkeyval.tex    2012/10/14 v2.6b key=value parser (HA)
etoolbox.sty    2011/01/03 v2.1 e-TeX tools for LaTeX
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
 amsmath.sty    2013/01/14 v2.14 AMS math features
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
  amsbsy.sty    1999/11/29 v1.2d
  amsopn.sty    1999/12/14 v2.01 operator names
subcaption.sty    2013/02/03 v1.1-62 Sub-captions (AR)
 caption.sty    2013/05/02 v3.3-89 Customizing captions (AR)
caption3.sty    2013/05/02 v1.6-88 caption3 kernel (AR)
biblatex.sty    2013/11/25 v2.8a programmable bibliographies (PK/JW/AB)
biblatex2.sty    2013/11/25 v2.8a programmable bibliographies (biber) (PK/JW/AB
)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  logreq.sty    2010/08/04 v1.0 xml request logger
  logreq.def    2010/08/04 v1.0 logreq spec v1.0
  ifthen.sty    2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
  blx-dm.def
biblatex-dm.cfg
blx-compat.def    2013/11/25 v2.8a biblatex compatibility (PK/JW/AB)
biblatex.def    
standard.bbx    2013/11/25 v2.8a biblatex bibliography style (PK/JW/AB)
 numeric.bbx    2013/11/25 v2.8a biblatex bibliography style (PK/JW/AB)
 numeric.cbx    2013/11/25 v2.8a biblatex citation style (PK/JW/AB)
biblatex.cfg    
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
inputenc.sty    2008/03/30 v1.1d Input encoding file
    utf8.def    2008/04/05 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  ts1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
    tikz.sty    2013/12/13 v3.0.0 (rcs-revision 1.142)
     pgf.sty    2013/12/18 v3.0.0 (rcs-revision 1.14)
  pgfrcs.sty    2013/12/20 v3.0.0 (rcs-revision 1.28)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.0 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
  pgfsys.sty    2013/11/30 v3.0.0 (rcs-revision 1.47)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.0 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.0 (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.0 (rcs-revision 1.25)
 pgfkeys.sty    
 pgfkeys.code.tex
 pgfmath.sty    
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
 english.lbx    2013/11/25 v2.8a biblatex localization (PK/JW/AB)
  ts1cmr.fd    1999/05/25 v2.5h Standard LaTeX font definitions
 t1ntxrx.fd    2012/12/25 v1.0
supp-pdf.mkii
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 ***********

Best Answer

You found an incompatibility: the external library and biblatex's \cite[][] syntax are incompatible.


The bug has been fixed; will become part of the next stable PGF.


According to the additional information provided in K04_4.log , TeX expected a $ sign when processing \cite[Vgl.][421]{PuenteLeon_2012_Messtechnik}. I guessed that this could be related to the underscore: it is a reserved token in math mode and requires $ if it is present within the normal text. Clearly, yours is not a normal text - but what if it becomes one during externalization?

Anyway, you can turn your example into a "real" minimal (non)working example if you write \cite[Cp.][23]{Jones_a} instead of \cite[Cp.][23]{Jones} (I introduced an underscore).

The bug is that the external library redefines \cite in order to catch all undefined symbols and communicate them as warnings into the log file of your original .tex file. This feature which collects warnings expects at most one set of square brackets after \cite and fails to process yours. This needs to be fixed; I will take care of it (no need to submit an extra bug report).

A workaround for now is to disable this feature which communicates unresolved \cite commands. Risk of this work-around: you may not realize that externalized images contain \cite which could not be resolved. In your minimal example, no tikzpicture environment even contains \cite, so it is entirely harmless.

Here is the example with the workaround:

\documentclass[
a4paper
]{scrartcl}

\usepackage{
    amsmath,
    subcaption,
    biblatex
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{
    external,
}
\tikzexternalize[
    failed ref warnings for={%
        \ref,%
        %\cite,% DISABLE THIS
        \pageref},
]

\listfiles

\begin{document}
\begin{figure}[tp]
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        a\\
        \begin{tikzpicture}
        \draw (0,0) rectangle (1,1);
        \end{tikzpicture}
        \subcaption[Something short.]{Something longer. So there is some text.\footnotemark\footnotemark}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        b\\
        \begin{tikzpicture}
        \draw (0,0) rectangle (1,1);
        \end{tikzpicture}
        \subcaption[Text.]{Some longer text and a few words}
    \end{minipage}
\end{figure}
\addtocounter{footnote}{-2}
\footnotetext{\cite[Cp.][12]{Smith}}
\addtocounter{footnote}{1}
\footnotetext{\cite[Cp.][23]{Jones_a}}



\end{document}