0

I have an abbrev.tex file that used in another file project.tex through

\input{abbrev}

Today for some reason, abbrev.tex is missing (I may have deleted it accidentally). I tried compile project.tex using pdflatex and it keeps complaining that command not found.

I wasted about 30 mins before I realized that that perpetual abbrev.tex is missing.

If pdflatex crashes immediately if it cannot find abbrev.tex then it will help me to locate the source of the problem.

Is there a way to cause pdflatex to just die when it cannot find a file?

Mensch
  • 65,388
Ed Gan
  • 1
  • 1
    \InputIfFileExists{yourfile.tex}{}{\batchmode \read -1 to \x } – Phelype Oleinik Jul 21 '21 at 13:59
  • 2
    Input complains immediately, so where is the problem here? Never ignore compilation errors – daleif Jul 21 '21 at 14:02
  • A missing file cannot lead to an error about "command not found". But as daleif pointed out, a file not found raises an error immediately, so it's not clear to me how it could take 30 minutes to find that out. Are you by any chance using some LaTeX editor? Those tend to hide errors... – campa Jul 21 '21 at 14:06
  • Phelype Oleinik, What does it do? what is \read -1 to \x? – Ed Gan Jul 21 '21 at 14:07
  • Phelype Oleinik, it works like magic. – Ed Gan Jul 21 '21 at 14:17
  • latex already stops with an error message and waits for a user response on a missing file, What else do you want it to do? @PhelypeOleinik's suggestion makes teh error non recoverable so it is ompossible to opt to carry on past that point. – David Carlisle Jul 21 '21 at 14:19
  • @campa: a missing file can cause very misleading error since \input or \include line is replaced by an empty line if a file is missing. When I have many files and dependencies, bad things may just happen. – Ed Gan Jul 21 '21 at 14:20
  • No input does not do that, it stops. Again please explain exactly what you're doing and how you're compiling. – daleif Jul 21 '21 at 15:15
  • @EdGan It was not a really serious solution. It does what you ask, but people don't always know what's best for them :) As others said, \input already complains on a file not found, telling you the name of the guilty file, so you shouldn't need more than that to debug. The trick in my comment puts TeX in \batchmode (no terminal output and no user interaction), then \read -1 to \x tries to read something from the terminal; since user interaction is off, TeX exits immediately. But that gives you absolutely no clue on what file is missing! – Phelype Oleinik Jul 22 '21 at 00:11
  • @PhelypeOleinik you are right. After playing with it, I decide to drop it since it gives no clue where it breaks. I have been using LaTex for a long time and only now I see No file abbrev.tex in the compilation window but it is hiding in tonnes of lines. Unless one is so patient to read every compile line LaTeX compile every time they compile a file and look for warning messages... Everything is there but it is not obvious where things break in the most transparent way. – Ed Gan Jul 22 '21 at 02:20
  • @daleif No input does not do that, it stops. Umm. this is not what I see or know. – Ed Gan Jul 22 '21 at 02:27
  • @EdGan glad we could convince you not to do that :-) Regarding looking for errors: I find it much easier to spot errors by using the command line to run LaTeX, so it stops on each error. Regardless, if you are using the log you can search for Error and it will most likely take you to something that needs attention – Phelype Oleinik Jul 22 '21 at 02:42
  • 1
    Aarghh sorry, \input will crash immediately. But I have used \include – Ed Gan Jul 22 '21 at 02:52
  • As a casual user for years, I do not pay attention to the diff between \input and \include. It seems I should avoid using \include then. – Ed Gan Jul 22 '21 at 02:54
  • The top answer in https://tex.stackexchange.com/questions/246/when-should-i-use-input-vs-include did miss the \input behavior about crashing. – Ed Gan Jul 22 '21 at 03:07

0 Answers0