如何強制停止遺失的輸入檔?

如何強制停止遺失的輸入檔?

我注意到,如果我錯誤地 \include 一個不存在的文件,例如錯誤輸入文件名時,編譯將繼續,沒有錯誤,沒有警告,只有一條消息“沒有文件 colophon2.tex”。這只會發生在 \include-ing tex 檔案時,而不是 \includegraphics 和 \includepdf 時。更糟的是,這則訊息在許多其他不感興趣/不重要的編譯訊息中遺失了。

在這種情況下,如何強制編譯因錯誤而停止,或至少以更明顯的方式警告我缺少某些內容?

我使用的是 Macbook Pro、OS X 10.6.8,並嘗試使用 Sublime Text、Texshop、TexMaker、TexWorks 以及我能找到的所有其他 Tex IDE。他們都有同樣的問題。

pdflatex版本如下:

pdflatex -v
pdfTeX 3.1415926-2.3-1.40.12 (TeX Live 2011)
kpathsea version 6.0.1
Copyright 2011 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.5.2; using libpng 1.5.2
Compiled with zlib 1.2.5; using zlib 1.2.5
Compiled with xpdf version 3.02pl5

先致謝!

答案1

更改輸入

No file no-file-like-this.tex.

到一個錯誤

! LaTeX Error: File `no-file-like-this.tex' not found.

您可以修補\include以使用普通文件\input而不是接受遺失的文件:

\documentclass{article}
\usepackage{etoolbox}
\makeatletter

\patchcmd\@include\@input@\input{}{}

\makeatother
\begin{document}
\include{no-file-like-this}
\end{document}

相關內容