跳轉到內容

TeX/endinput

來自華夏公益教科書,開放的書籍,開放的世界
< TeX
  \endinput
  • 該命令在檔案中間終止輸入過程。在檔案末尾它是多餘的。
  • 遇到該命令後,TeX 會繼續讀取直到行尾。這使得將 \endinput 包含在 \if 單行中成為可能。
  \def\false{false}
  \def\students{false}
  
  % Questions, for teachers and students ...
  
  \ifx\students\true\endinput\fi
  
  % Answers, for teacher only

如果 \if 語句不能是一行程式碼(例如,出於可讀性原因),那麼可以使用 \expandafter

  \ifx\students\true
       % ... various other statements ...
       \expandafter\endinput
  \fi
華夏公益教科書