매 두 번째 페이지마다 뭔가를 하세요

매 두 번째 페이지마다 뭔가를 하세요

매 페이지마다 문서의 주요 텍스트만 인쇄하는 방법이 있습니까?두번째다른 페이지에서 다른 코드를 실행하는 동안 페이지? 내가 원하는 것은 아래 예와 같이 실행되는 것입니다.

\documentclass{memoir}
\usepackage{lipsum}

\begin{document}
\begin{atevenpages}
  The content of this environment is supposed to be printed on even-numbered pages. On the other hand, even-numbered pages are supposed to contain none of the main text.
\end{atevenpages}

This is the main text, which is only to appear on odd-numbered pages.
\lipsum[1-22]
\end{document}

답변1

everypage및 패키지 를 살펴보십시오 ifthen. everypage각 페이지가 설정된 후에 호출되는 후크를 소개합니다. 따라서 첫 번째 페이지에 대해서만 수동으로 명령을 호출해야 하며 \checkthatpage다른 모든 페이지에는 후크가 사용됩니다. 더 정교한 솔루션이 있을 수 있지만 아직 찾지 못했습니다.

\documentclass{article}
\usepackage{ifthen,everypage}

\newcommand{\checkthatpage}[2]{%
\ifthenelse{\isodd{\value{page}}}%
    {#1}%
    {#2}%
}%

\AddEverypageHook{\checkthatpage{Even}{Odd}}

\begin{document}

Foo

\clearpage

Bar

\end{document}

답변2

나는 이 문제를 더 낮은 수준에서 다루겠습니다. \shipout페이지가 가득 차서 내보내야 할 때 TeX에 의해 호출되는 루틴입니다. 이 단계에서는 의도한 콘텐츠가 포함된 다른 페이지를 추가하면 됩니다.

\documentclass{memoir}
\usepackage{lipsum}

\usepackage{atbegshi}

\AtBeginShipout{%
  \ifodd\value{page}%
    \EvenPageContent%
    \newpage
  \fi
}

\newcommand{\EvenPageContent}{%
  The content of this environment is supposed to be printed on even-numbered pages. On the other hand, even-numbered pages are supposed to contain none of the main text.
}

\begin{document}

This is the main text, which is only to appear on odd-numbered pages.
\lipsum[1-22]
\end{document}

관련 정보