
Estou procurando um comando \return
com o qual eu possa sair manualmente de um arquivo TeX, que está incluído em \input
.
(No final do meu arquivo TeX há alguns avisos, que às vezes quero imprimir, às vezes não.)
Responder1
Usar \endinput
. Tudo depois disso será ignorado.
Responder2
Eu recomendo que você use um ambiente ou um \ifdefined
para selecionar se os avisos serão exibidos ou não:
Com a versão "ambiente" você pode usar \DisableMyNotices
e \EnableMyNotices
para alternar se deseja ver os avisos ou não.
Código:\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}
Código: versão do ambiente:
\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}