pdflatex nonstopmode with TikZ stops compiling

I compiled a TikZ code using pdflatex -interaction=nonstopmode. Depending on code errors, compiling stops. I want to know what went wrong. Let me show you two cases, both of which involve a code error each.

Case 1: "$" is missing in the 6th line (\node at...). Compiling does NOT stop. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [help lines] (0,0) grid (2,2); \node at (1,1) {$x^2};
\end{tikzpicture}
\end{document}


Case 2: ";" is missing at the end of the 5th line (\draw...). Compiling STOPS. I have to press keys to continue.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2)
\node at (1,1) {$x^2$};
\end{tikzpicture}
\end{document}


Is Case 2 an expected result? If so, how can I make compiling non-stop? Your help is appreciated.

• The same result (-.-). – T_T May 17 '13 at 15:36

Processing does not stop, it just goes into a tight loop

tikz@signal@path ->\tikz@signal@path

\tikz@signal@path ->\tikz@signal@path

\tikz@signal@path ->\tikz@signal@path

\tikz@signal@path ->\tikz@signal@path

\tikz@signal@path ->\tikz@signal@path

[15]+  Stopped                 pdflatex -interaction=nonstopmode


You can see this if you run the following with the % removed. Beware do not do this unless you are confident you can stop a misbehaving program: it will write an arbitrarily large log file until you stop it.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
%\tracingmacros1
%tracingonline1
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2)
\node at (1,1) {$x^2$};
\end{tikzpicture}
\end{document}

• Is there any way to avoid such loop? – T_T May 17 '13 at 15:59
• @T_T Not really. If you go \def\foo{\foo}\foo TeX will spin forever. and that is what ended up happening in this case. It is impossible to check in general that programs stop (the halting problem). – David Carlisle May 17 '13 at 16:05
• So we have to live with it... Thanks for your input. Very much appreciated. – T_T May 17 '13 at 16:07
• @T_T why would you want nonstopmode it is prone to such problems you can do yes x |pdflatex -interaction=errorstopmode myfile – David Carlisle May 17 '13 at 16:08
• Saving key strokes.. Perhaps, I am just lazy (^o^)/ – T_T May 17 '13 at 16:10