blog about text processing; in drei Sprachen; на три езика
  • Home

\include and missing file

28. Juli 2009 – 15:09

If 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

  1.  
  2. \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.

  1.  
  2. \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@

  1.  
  2. \def\@include#1 {%
  3.   \clearpage
  4.   \if@filesw
  5.     \immediate\write\@mainaux{\string\@input{#1.aux}}%
  6.   \fi
  7.   \@tempswatrue
  8.   \if@partsw
  9.     \@tempswafalse
  10.     \edef\reserved@b{#1}%
  11.     \@for\reserved@a:=\@partlist\do
  12.       {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
  13.   \fi
  14.   \if@tempswa
  15.     \let\@auxout\@partaux
  16.     \if@filesw
  17.       \immediate\openout\@partaux #1.aux
  18.       \immediate\write\@partaux{\relax}%
  19.     \fi
  20.     \@iinput{#1.tex}%
  21.     \clearpage
  22.     \@writeckpt{#1}%
  23.     \if@filesw
  24.       \immediate\closeout\@partaux
  25.     \fi
  26.   \else
  27.     \deadcycles\z@
  28.     \@nameuse{cp@#1}%
  29.   \fi
  30.   \let\@auxout\@mainaux}

Tags: file, missing, redefinition, \include, \input

Post a Comment

  • Letzte Artikel

    • Typesetting Fight Club: 3B2 vs. TeX
    • BibTeX output to XML
    • No Comment. Ohne Worte
    • “Ша” (Ш) като “Шин” (ש)
    • Die neue (Typo-)Epidemie: Ligaturen an den Wortfugen
  • Kategorien

    • Allgemein (7)
    • BibTeX (1)
    • Code (6)
    • Database Publishing (4)
    • Deutsch (8)
    • English (17)
    • Examples (6)
    • Fonts (5)
    • Kvetch (7)
    • LaTeX (8)
    • Math Examples (1)
    • Math Fonts (4)
    • Math Typography (3)
    • Mikrotypografie (1)
    • OpenType (1)
    • TeX (7)
    • Text Processing (7)
    • Typografie (3)
    • Typography (3)
    • Umbruch (3)
    • Work (8)
    • На български (3)
  • Tags

    Ж Курсив Berthold Binnen-I Binnenmajuskel comparing ConTeXt cyrillic diff Ediff Emacs englaufend Font fontinst Formelsatz Geistes- und Sozialwissenschaftler Glyph hanging index italic Katalogproduktion Lindenberg Linotype maiola math Mathesatz Minion Multiple Master online OpenType Piska raggedright register Satz Schrift Slimbach Stempel Garamond TeX tfcpr Times Trennen Umbruch Wortzwischenraum WZR zhe
TANOVSKI & PARTNERS 2.0 is proudly powered by WordPress Entries (RSS) and Comments (RSS). Designed by Bob