每個小節之後的 \clearpage

每個小節之後的 \clearpage

我想在每個末尾清除頁面\subsubsection。我試過

\usepackage{titlesec}
\newcommand{\subsubsectionbreak}{\clearpage}

但這似乎\clearpage迫使開始每一個\subsubsection.是否可以\clearpage在最後強制使用 a ?

答案1

您可以在文件的序言中包含以下說明:

\usepackage{titlesec}
\newcommand\sectionbreak{\ifnum\value{section}>1\clearpage\fi}
\newcommand\subsectionbreak{\ifnum\value{subsection}>1\clearpage\fi}
\newcommand\subsubsectionbreak{\ifnum\value{subsubsection}>1\clearpage\fi}

這將在每次遇到\section\subsection、 或命令時插入分頁符\subsubsection如果對應的計數器大於1 \section\subsection第一個命令之後的每個命令之內給定的部分將觸發分頁符號等。

此方法假設您的文件類別使用「普通」計數器變數sectionsubsectionsubsubsection。如果那是不是在這種情況下,請說明您如何設定這些變數。

答案2

以下不需要titlesec:

\makeatletter
\newif\if@subsubsectionused \@subsubsectionusedfalse
\let\oldsection\section
\let\oldsubsection\subsection
\let\oldsubsubsection\subsubsection
\renewcommand{\section}{\if@subsubsectionused\clearpage\@subsubsectionusedfalse\fi\oldsection}
\renewcommand{\subsection}{\if@subsubsectionused\clearpage\@subsubsectionusedfalse\fi\oldsubsection}
\renewcommand{\subsubsection}{\if@subsubsectionused\clearpage\fi\@subsubsectionusedtrue\oldsubsubsection}
\makeatother

\clearpage在基於條件調用傳統分段命令之前插入一個\if@subsubsectionused。只要\subsubsection使用a,此條件就設為 true ,否則設為 false。

程式碼範例如下

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\subsubsection{A subsubsection}
\subsection{A subsection}
\subsubsection{A subsubsection}
\subsubsection{A subsubsection}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\subsubsection{A subsubsection}
\subsection{A subsection}
\subsection{A subsection}
\subsubsection{A subsubsection}
\subsubsection{A subsubsection}

會產生一個佈局

1 A section
1.1 A subsection
1.1.1 A subsubsection
-----------< page break >--------------------
1.1.2 A subsubsection
-----------< page break >--------------------
1.2 A subsection
1.2.1 A subsubsection
-----------< page break >--------------------
1.2.2 A subsubsection
-----------< page break >--------------------
2 A section
2.1 A subsection
2.1.1 A subsubsection
-----------< page break >--------------------
2.1.2 A subsubsection
-----------< page break >--------------------
2.2 A subsection
2.3 A subsection
2.3.1 A subsubsection
-----------< page break >--------------------
2.3.2 A subsubsection

相關內容