
나는 이 작업을 수행하는 방법을 알 수 없었고 다음을 살펴보았습니다.etoolbox 문서
문제는 설명하기 간단합니다. etoolbox를 사용하여 큰 문서의 \clearpage
앞에 a를 추가하여 \section
각 섹션이 새 페이지에서 시작되도록 했습니다. (북 스타일의 문서이지만 아래 MWE는 기사입니다)
작은 섹션이 거의 없고 다음 섹션에서는 이 작업을 수행하지 않도록 etoolbox에 지시한 다음 해당 섹션이 끝난 후 다시 시작하도록 지시하고 싶습니다.
어떻게 해야 하나요? 이에 대한 etoolbox 또는 Latex 명령은 무엇입니까?
여기 MWE가 있습니다
\documentclass[12pt]{article}%
\usepackage{etoolbox}\preto\section{\clearpage}
\usepackage{lipsum}
\begin{document}
\section{A}
\lipsum[75]
\section{B}
\lipsum[75]
%do not add \clearpage here, how?
\section{C}
\lipsum[75]
%now start adding \clearpage, it is ok
\section{D}
\lipsum[75]
\end{document}
Texlive 2013, 리눅스 민트.
답변1
스위치를 생성하고 스위치가 true인지 false인지에 따라 \clearpage
명령을 실행하는 것도 가능합니다.
\documentclass[12pt]{article}%
\usepackage{etoolbox}
\usepackage{lipsum}
\newtoggle{clearpagebeforesection}
\preto{\section}{\iftoggle{clearpagebeforesection}{\clearpage}{}}
\begin{document}
\toggletrue{clearpagebeforesection}
\section{A}
\lipsum[75]
\section{B}
\lipsum[75]
%do not add \clearpage here, how?
\togglefalse{clearpagebeforesection}
\section{C}
\lipsum[75]
%now start adding \clearpage, it is ok
\toggletrue{clearpagebeforesection}
\section{D}
\lipsum[75]
\section{E}
\lipsum[75]
\end{document}
답변2
한 가지 가능성은 로컬에서(읽기) 명령을 생성하는 것입니다.그룹에서) relax
예 \clearpage
:
% locally disable clearpage
\newcommand{\specialsection}[1]{
\begingroup
\let\clearpage\relax
\section{#1}
\endgroup
}
이 방법은 \clearpage
문서의 모든 섹션에 기본적으로 설정되지만 s에는 \specialsection
적용되지 않습니다.
전체 예:
\documentclass[12pt]{article}%
\usepackage{etoolbox}
\preto\section{\clearpage}
% locally disable clearpage
\newcommand{\specialsection}[1]{
\begingroup
\let\clearpage\relax
\section{#1}
\endgroup
}
\usepackage{lipsum}
\begin{document}
\section{A}
\lipsum[75]
\section{B}
\lipsum[75]
% we use the new command
\specialsection{C}
\lipsum[75]
\section{D}
\lipsum[75]
\end{document}