나는 다음을 수행하는 환경을 만들고 싶습니다 newenvironment
. 환경의 높이를 평가한 다음 한 페이지에 맞는 만큼 여러 번(텍스트 높이/높이) 인쇄합니다.
다음은 환경을 두 번 인쇄하려는 시도입니다.
\documentclass{article}
\newenvironment{double}{\newcommand{\todouble}\bgroup}{\egroup\todouble\todouble}
\begin{document}
\begin{double}
Hello, World!
\end{double}
\end{document}
나의 첫 번째 아이디어는 환경의 내용을 포함하는 명령을 정의하는 데 \newenvironment
사용되는 환경을 정의 하는 것입니다. 마지막에는 환경이 두 번 호출됩니다.\newcommand
\todouble
\todouble
그러나 이것은 오류와 함께 실패합니다.
! Extra }, or forgotten \endgroup.
\enddouble ->\egroup
\todouble \todouble
l.6 \end{double}
어떻게 해결할 수 있나요?
답변1
\bgroup
필수 인수를 구분하는 데는 사용할 수 없습니다 . 그리고 당신은 지도자들이 당신이 흡수한 내용의 사본으로 페이지를 채우기를 원합니다.
\documentclass{article}
\newenvironment{double}
{%
\par % be in vertical mode
\setbox0=\vbox\bgroup % start a box
\strut % ensure good height for the first line
\ignorespaces % ignore the end of line
}
{%
\egroup % end the box
\hrule height0pt % vertical analog of \leavevmode
\cleaders\copy0\vfill % repeat as much as necessary
}
\begin{document}
\begin{double}
Hello, World!
\end{double}
\end{document}
최소 두 개의 상자 복사본이 페이지에 맞는지 확인하고 그렇지 않은 경우 상자를 인쇄하는 확장 버전입니다.
\documentclass{article}
\usepackage{lipsum}
\newenvironment{double}
{%
\par % be in vertical mode
\setbox0=\vbox\bgroup % start a box
\strut % ensure good height for the first line
\ignorespaces % ignore the end of line
}
{%
\ifhmode\strut\fi\egroup % end the box
% see if at least two copies of the box fit in the page
\ifdim\ht0 < \dimexpr .5\textwidth-4ex\relax
\hrule height0pt % vertical analog of \leavevmode
\cleaders\copy0\vfill % repeat as much as necessary
\clearpage
\else
\unvbox0
\clearpage
\fi
}
\begin{document}
\begin{double}
Hello, World!
\end{double}
\begin{double}
\lipsum*[2]
\end{double}
\begin{double}
\lipsum
\end{double}
\end{document}