\include and missing file
28. Juli 2009 – 15:09If you try to \input a non-existing file, you get an error and if in interactive mode, you are prompting to type a new filename. But if you do the same with \include, no error occurs, just a little warning “No file …”. This behaviour, although documented, is sometimes not optimal if one wants to make sure that no file is lost without checking the logfiles.
\include uses \@input@ in its definition to load a file and \@input@ is defined as
-
-
\def\@input@#1{\InputIfFileExists{#1}{}{\typeout{No file #1.}}}
The simplest way to change \@input@ ist to \let it to \@iinput, the macro, which issues an error if file is not found.
-
-
\let\@input@\@iinput
Since \@input@ is not only used in the \include macro, this redefinition affects the input of .fd and .bbl files. You can see this as some kind of strict (or final, because of BibTeX) mode LaTeX, producing error on missing files.
Of course, we can redefine only the \include macro, just by copying its definition and replacing \@input@
-
-
\def\@include#1 {%
-
\clearpage
-
\if@filesw
-
\immediate\write\@mainaux{\string\@input{#1.aux}}%
-
\fi
-
\@tempswatrue
-
\if@partsw
-
\@tempswafalse
-
\edef\reserved@b{#1}%
-
\@for\reserved@a:=\@partlist\do
-
{\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
-
\fi
-
\if@tempswa
-
\let\@auxout\@partaux
-
\if@filesw
-
\immediate\openout\@partaux #1.aux
-
\immediate\write\@partaux{\relax}%
-
\fi
-
\@iinput{#1.tex}%
-
\clearpage
-
\@writeckpt{#1}%
-
\if@filesw
-
\immediate\closeout\@partaux
-
\fi
-
\else
-
\deadcycles\z@
-
\@nameuse{cp@#1}%
-
\fi
-
\let\@auxout\@mainaux}
Tags: file, missing, redefinition, \include, \input