13

I'm looking for a command like \return with which I can manually exit a TeX file, which is included by \input.

(At the end of my TeX file are some notices, which I sometimes want to print, sometimes not.)

musicman
  • 3,559

2 Answers2

14

Use \endinput. Everything after it will be ignored.

Ulrike Fischer
  • 327,261
4

I would recommend you use either an environment, or an \ifdefined to select if the notices are displayed or not:

enter image description here

With the "environment" version you can use \DisableMyNotices and \EnableMyNotices to toggle if you want to see the notices or not.


Code: \ifdefined

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}

\usepackage{filecontents} \begin{filecontents*}{MyInput.tex} This is text I want always included.

\ifdefined\IncludeNotices \fcolorbox{red}{yellow!40}{% These are notices that I only want sometimes.% }% \fi \end{filecontents*}

\begin{document} Using normal input I get just the text\par

\begin{mdframed} \input{MyInput} \end{mdframed}

\bigskip

But with \verb|\IncludeNotices| defined:\par \def\IncludeNotices{} \begin{mdframed} \input{MyInput} \end{mdframed}

\end{document}


Code: environment version:

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{environ}

\NewEnviron{MyNotices}{}% \newcommand{\EnableMyNotices}{\RenewEnviron{MyNotices}{\BODY}} \newcommand{\DisableMyNotices}{\RenewEnviron{MyNotices}{}}

\usepackage{filecontents} \begin{filecontents*}{MyInput.tex} This is text I want always included.

\begin{MyNotices} \fcolorbox{red}{yellow!40}{% These are notices that I only want sometimes.% }% \end{MyNotices} \end{filecontents*}

\begin{document} \DisableMyNotices With \verb|\DisableMyNotices| defined:\par

\begin{mdframed} \input{MyInput} \end{mdframed}

\bigskip

\EnableMyNotices But with \verb|\EnableMyNotices| defined:\par \begin{mdframed} \input{MyInput} \end{mdframed}

\end{document}

Peter Grill
  • 223,288