TransWikia.com

remove pagebreak after part

TeX - LaTeX Asked on November 23, 2021

I am use the book documentclass with various parts. For a part, I’d like the Part number and title followed by a paragraph on the same page. Currently, I’m getting the Part number and title on a page, with the rest of the page blank, the following page blank and then a page with the paragraph.

Also, I’m using the titlesec package to reformat them and realize there is spacing in the titleformat command, but it appears that no control over the spacing will remove the page break.

I also tried refining @endpart, however that didn’t work. I wonder if this conflicts with the titlesec package.

Edited Below

With the answer below, here’s a twist on the code with titleformat defined which shows that redefining @endpart doesn’t seem to work:

documentclass{book}
usepackage{titlesec}
usepackage{lipsum}

titleformat{part}
  {hugesffamilyslshape}
  {Part~thepart:}{1em}{}

begin{document}

makeatletter
renewcommand{@endpart}{}
makeatother

part{A part}
vspace{2baselineskip}
lipsum[1]

cleardoublepage
lipsum[2]

end{document}

2 Answers

The titlesec package hardwires the new page after the title without using the @endpart mechanism.

Here's a patch:

documentclass{book}
usepackage{titlesec}
usepackage{etoolbox}
usepackage{lipsum}

makeatletter
patchcmd{ttl@page@ii}{newpageif@twoside}{iffalse}{}{}
makeatother

titleformat{part}
  {hugesffamilyslshape}
  {Part~thepart:}{1em}{}

begin{document}

part{A part}
vspace{2baselineskip}
lipsum[1]

cleardoublepage
lipsum[2]

end{document}

enter image description here

Answered by egreg on November 23, 2021

This works for me

% partpageprob.tex  SE 553544
documentclass{book}
usepackage{titlesec}
usepackage{lipsum}

begin{document}

makeatletter
renewcommand{@endpart}{}
makeatother

part{A part}
vspace{2baselineskip}
lipsum[1]

cleardoublepage
lipsum[2]

end{document}

If you are using twocolumns, and possibly some pagestyles, the definition of @endpart may need modifying instead of just cancelling its effect.

I would have found it useful if you had provided an MWE; I had to make one up but it does not necessarily have much to do with your actual code.

Answered by Peter Wilson on November 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP