Robust processing of autogenerated LaTeX files
I use knitr to generate pretty reports, with pdflatex as backend. Everything works fine if the R code runs without error. However, if the R code fails, the autogenerated file is sometimes invalid in such a way that LaTeX won't even generate a PDF out of it -- too many errors, resulting in the following output:
(That makes 100 errors; please try again.)
! ==> Fatal error occurred, no output PDF file produced!
Example: texput.tex
\documentclass{scrartcl}
\pagestyle{empty}
\begin{document}
\input{bad}
\end{document}
Example: bad.tex
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
(The code, and a Makefile, can be downloaded or cloned here.)
In such cases, the error in the R script is difficult to find, because no output is available.
Is there a foolproof equivalent of \input that will gracefully ignore errors which otherwise would be fatal? It's fine even if the resulting document ends abruptly at the place of the fatal error, as long as a valid PDF is generated. Or perhaps just setting the error threshold to an insanely large value and/or resetting the number of encountered errors after each \input will help?
I use knitr to generate pretty reports, with pdflatex as backend. Everything works fine if the R code runs without error. However, if the R code fails, the autogenerated file is sometimes invalid in such a way that LaTeX won't even generate a PDF out of it -- too many errors, resulting in the following output:
(That makes 100 errors; please try again.)
! ==> Fatal error occurred, no output PDF file produced!
Example: texput.tex
\documentclass{scrartcl}
\pagestyle{empty}
\begin{document}
\input{bad}
\end{document}
Example: bad.tex
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e\e
(The code, and a Makefile, can be downloaded or cloned here.)
In such cases, the error in the R script is difficult to find, because no output is available.
Is there a foolproof equivalent of \input that will gracefully ignore errors which otherwise would be fatal? It's fine even if the resulting document ends abruptly at the place of the fatal error, as long as a valid PDF is generated. Or perhaps just setting the error threshold to an insanely large value and/or resetting the number of encountered errors after each \input will help?
No comments:
Post a Comment