Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

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

2 Answers 2

up vote 7 down vote accepted

Use \endinput. Everything after it will be ignored.

share|improve this answer

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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