Jump to content

TeX/endinput

From Wikibooks, open books for an open world
< TeX

Synopsis

[edit | edit source]
  \endinput

Description

[edit | edit source]
  • This command terminates the input process in the middle of a file. It is redundant at the end of a file.
  • On encountering this command, TeX continues reading until the end of the line. This makes it possible to wrap \endinput in an \if oneliner.

Example

[edit | edit source]
  \def\false{false}
  \def\students{false}
  
  % Questions, for teachers and students ...
  
  \ifx\students\true\endinput\fi
  
  % Answers, for teacher only

If the \if statement cannot be a oneliner (for legibility reasons, say), then one can use \expandafter:

  \ifx\students\true
       % ... various other statements ...
       \expandafter\endinput
  \fi