\input - \return-명령

\input - \return-명령

\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}

관련 정보