7

In a LaTeX report I'm working on, I have used \part{title of part} to organise the chapters into parts.

This gives me distinct pages for each \part specified which is what I want. But if I try to add text beneath the part's title, it is printed on the next page.

Is it possible to place text on the \part page directly under the title of the part?

Thanks Christian. The part pages now look something like what you see below with text added. The only other thing will be to try to move the text up a bit.

enter image description here

7

There seems to be a \newpage at the end of part command, which has to be kicked out, by relaxing it temporarily, in a group.

\documentclass{book}

\usepackage{etoolbox}
\usepackage{blindtext}


\makeatletter

\let\LaTeXStandardPart\part%
\newcommand{\unstarredpart@@noopt}[1]{%
  \unstarredpart@@opt[#1]{#1}%
}%

\newcommand{\unstarredpart@@opt}[2][]{%
  \cleardoublepage% (For clearing content before!!!)
  \begingroup%
  \let\newpage\relax%
  \LaTeXStandardPart[#1]{#2}%
  \endgroup%
}%

\newcommand{\starredpart}[1]{%
  \LaTeXStandardPart*{#1}%
}%

\newcommand{\unstarredpart}{%
  \@ifnextchar[{\unstarredpart@@opt}{\unstarredpart@@noopt}%
}%

\renewcommand{\part}{%
  \@ifstar{\starredpart}{\unstarredpart}%
}%

\begin{document}

\part{Some part}%
\blindtext[10]

\chapter{First chapter}

\section{First section}%

\blindtext

\part{Other part}
\chapter{Other chapter}%

\end{document}

enter image description here

  • 1
    @MrMorgan: Please unaccept -- there is an error! – user31729 Sep 20 '14 at 15:43
  • 1
    @MrMorgang: Thanks! I found the error: The ToC wasn't shown due to the relaxing of newpage. Now it's ok (I think!) – user31729 Sep 20 '14 at 15:48
  • Question modified to show the results. – Mr Morgan Sep 20 '14 at 23:22
  • @ChristianHupfer is there a way to fix the position of Part and its title? I wanna put it at a fix poistion at the top of the page. – Mr. D Mar 29 '18 at 13:16
2

Lesser code with xpatch

\documentclass{book}

\usepackage{xpatch}
\usepackage{blindtext}

\makeatletter
\xpatchcmd{\@endpart}{\vfil\newpage}{}{}{}
\xpatchcmd{\@endpart}{\newpage}{}{}{}
\makeatother


\begin{document}
\tableofcontents
\part{Some part}%
\blindtext[10]

\chapter{First chapter}

\section{First section}%

\blindtext

\part{Other part}
\chapter{Other chapter}%

\end{document}

enter image description here

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.