6

I'm using the titlesec package for my sectioning. I want to have a \clearpage before every \part however when I put it into the format field of

\titleformat{command}[shape]{format}{label}{sep}{before-code}{after-code}

Then it does what I want, but if the very first part of the document (which is incidentally the first content after the \maketitle command, it will insert a blank page. This is because, to quote the titlesec documentation,

{format} is the format to be applied to the whole title—label and text. This part can contain vertical material (and horizontal with some shapes) which is typeset just after the space above the title

Note the ''just after the space above the title'. So \clearpage should not be put into the format field.

I can do the same thing that I want to do, but with sections, not parts, using

\newcommand{\sectionbreak}{\clearpage}

I know there are other commands just like that for things such as subsubsection or subsection, but I couldn't find one for part that worked. How would I do it?

\documentclass{article}

\usepackage{titlesec}

\titleformat{\part}[display]{\clearpage\itshape\rmfamily\raggedright}{\LARGE Part     \thepart}{0mm}{\Huge}{}
\titlespacing*{\part}{0mm}{30mm}{30mm}

\begin{document}
\part{Part test}
test text
\end{document}
  • You should create a minimal working example (MWE) that the community can play with. It really helps... – Werner Jul 31 '13 at 3:24
  • One suggestion could be to add \partbreak as part of the <format> for your \part, where \newcommand{\partbreak}{}. Then, exactly from where you need to insert the \clearpage, add \renewcommand{\partbreak}{\clearpage}. – Werner Jul 31 '13 at 3:25
  • @Werner Yeap, sorry, I was pressed for time. Updated the question with MWE. Regarding your second comment, I was looking more for some sure way to always have it on a new page, a bit like the effect of \sectionbreakabove. – dcaf Jul 31 '13 at 3:45
2

A more appropriate way of inserting a \clearpage before every \part is to redefine \part in the following way:

\let\oldpart\part% Store \part in \oldpart
\renewcommand{\part}{\clearpage\oldpart}% Insert \clearpage before every \part

Use this after specifying \titleformat for \part.

4

Simplest solution seems to be to declare \part to be of top class; then you can use \partbreak and define it to be \clearpage as desired:

\documentclass{article}
\usepackage{titlesec}

\titleformat{\part}[display]
  {\itshape\rmfamily\raggedright}{\LARGE Part \thepart}{0mm}{\Huge}{}
\titlespacing*{\part}{0mm}{30mm}{30mm}
\titleclass{\part}{top}
\newcommand\partbreak{\clearpage}

\begin{document}
\part{Part test}
test text
\part{Part test}
test text
\end{document}
  • Do you actually need the \newcommand\partbreak{\clearpage} here? \titleclass{\part}{top} seems to do this (although in the wrong order compared with updating the counter, see this question) – mforbes Feb 26 '14 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.