1

Say I have a simple LaTeX file to compile (missingPic.tex) but a picture is missing. The following would be a MWE

\documentclass{article}
\usepackage{graphicx}

\begin{document}
We now include a non existing pic:
\includegraphics[width=\textwidth]{iDontExist.pdf}
\end{document}

If I compile it from cmd (using Win7), I get (removing some lines to make it shorter)

C:\giulio>pdflatex missingPic.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6300 64-bit)
entering extended mode
(missingPic.tex
LaTeX2e <2017-04-15>
Babel <3.9t> and hyphenation patterns for 76 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
...
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))))
No file missingPic.aux.
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty")
...
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"))))

LaTeX Warning: File `iDontExist.pdf' not found on input line 9.


! Package pdftex.def Error: File `iDontExist.pdf' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.9 ...egraphics[width=\textwidth]{iDontExist.pdf}

?

So basically it "hangs" and waits for my input from keyboard. I have to do something like ctrl+C to get out.

My question is if there is any way to avoid that and let pdflatex return some kind of error.

My Y is very simply the following: I am actually wrapping this from MATLAB, where I essentially have a line like

[status, result] = system('pdflatex missingPic.tex')

and with this behavior MATLAB really hangs: it keeps saying "busy" without me having access to the variables status and result. So I don't know how to catch this problem (only thing I can think of is something based on elapsed time but it seems quite ugly to me).

Giulio
  • 327
  • 3
    --nonstopmode ;-) – Johannes_B Dec 11 '17 at 10:02
  • 1
    pdflatex -halt-on-error is another option. [Tested] @Johannes_B I tried your way but didn't work in my emacs... – koleygr Dec 11 '17 at 10:05
  • Thanks! Once you gave me the answer I found https://tex.stackexchange.com/questions/5644/ignore-compile-errors, https://tex.stackexchange.com/questions/13323/how-to-disable-the-prompt-on-error and https://tex.stackexchange.com/questions/161352/pdflatex-how-to-automatically-quit-on-compile-error, so I apologize and I guess you can now mark as duplicate? – Giulio Dec 11 '17 at 10:36
  • Also this would answer a natural follow up question: https://tex.stackexchange.com/questions/258814/what-is-the-difference-between-interaction-nonstopmode-and-halt-on-error – Giulio Dec 11 '17 at 10:41
  • @Giulio does both our comments solveyour problem? (Asking because we have to chose which of the other questuions works for you to link it as a duplicate) – koleygr Dec 11 '17 at 10:47
  • @koleygr Yes they both do solve my problem at hand. I will need to understand both better in order to decide which one to use. Btw, the three other questions I mentioned were mentioned in chronological order. I think both the second and the third should have been duplicates as well. In any case, thank you again for your help!! – Giulio Dec 12 '17 at 13:52
  • @Giulio Welcome... Happy TeXing... (Playing around with different code options is the best way to get better and better... You are on the right path) – koleygr Dec 12 '17 at 13:58
  • @koleygr yes i definitely agree.. – Giulio Dec 12 '17 at 18:57

0 Answers0