9

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.)

  • 6
    Use \endinput – Ulrike Fischer May 12 '14 at 8:26
  • So easy! Thank you, that was, what I was looking for. Please write it as an answer :) – musicman May 12 '14 at 8:36
8

Use \endinput. Everything after it will be ignored.

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}
  • 1
    +1 Nice way to style up notices, but I just needed a simple out-of-here-command :) – musicman May 12 '14 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.