
Я ищу команду, \return
с помощью которой я могу вручную выйти из файла TeX, который включен в \input
.
(В конце моего TeX-файла есть несколько примечаний, которые я иногда хочу распечатать, иногда нет.)
решение1
Используйте \endinput
. Все, что после него, будет проигнорировано.
решение2
Я бы рекомендовал вам использовать либо среду, либо , \ifdefined
чтобы выбрать, отображать уведомления или нет:
В версии «окружающая среда» вы можете использовать \DisableMyNotices
и \EnableMyNotices
для включения или выключения отображения уведомлений.
Код:\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}
Код: версия среды:
\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}