\clearpage after every subsubsection
Solution 1
You could include the following instructions in your document's preamble:
\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}
This will insert a page break every time a \section
, \subsection
, or \subsubsection
command is encountered if the corresponding counter is greater than 1. I.e., every \section
command after the very first such command will trigger a page break; every \subsection
command after the very first such command within a given section will trigger a page break, etc.
This method assumes that your document class uses "plain" counter variables for section
, subsection
and subsubsection
. If that's not the case, please indicate how you've set up those variables.
Solution 2
The following doesn't require titlesec
:
\makeatletter
\newif\[email protected] \@subsubsectionusedfalse
\let\oldsection\section
\let\oldsubsection\subsection
\let\oldsubsubsection\subsubsection
\renewcommand{\section}{\[email protected]\clearpage\@subsubsectionusedfalse\fi\oldsection}
\renewcommand{\subsection}{\[email protected]\clearpage\@subsubsectionusedfalse\fi\oldsubsection}
\renewcommand{\subsubsection}{\[email protected]\clearpage\fi\@subsubsectionusedtrue\oldsubsubsection}
\makeatother
It inserts a \clearpage
before calling the traditional sectioning command based on a condition \[email protected]
. This condition is set to true whenever a \subsubsection
is used, and to false otherwise.
An example of code like
\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}
would yield a layout of
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
Related videos on Youtube
user28291
Updated on April 13, 2020Comments
-
user28291 about 3 years
I'd like to clear the page at the end of every
\subsubsection
. I tried\usepackage{titlesec} \newcommand{\subsubsectionbreak}{\clearpage}
But this appears to force a
\clearpage
at the start of every\subsubsection
. Is it possible to force a\clearpage
at the end?-
Mico about 10 yearsJust to clarify: Do you also want page breaks between subsections that do not include subsubsections, and between sections that do not include subsections? Please advise.
-
user28291 about 10 years@Mico Yes I also want page breaks between subsections and sections (even if they don't include subsub or subsections).
-
Werner about 10 yearsWhat do your current definitions of the sectional units
\section
,\subsection
and\subsubsection
usingtitlesec
look like? -
Werner about 10 yearsAccording to @Mico's comment and your response, it seems like you just want a
\clearpage
at every sectional level (\section
,\subsection
and\subsubsection
). Correct? -
user28291 about 10 years@Werner Sorry for the confusion. I don't just want page breaks everywhere. That could be accomplished by adding
\clearpage
for every*sectionbreak
command. When I do that I have way to many almost blank pages. I really just want to force aclearpage
at the end of every subsubsection.
-
-
user28291 about 10 yearsIt works if I add a \fi at the end of the macro definition, otherwise I get a bunch of warnings
-
Mico about 10 years@user28291 - Thanks for pointing out this omission - I've added the
\fi
instructions.