Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have tried to look through, but I couldn't find a clear solution on this.

I have a document that uses report with multiple \chapters in multiple \parts as:

\part{foo}
\chapter{uno}
\chapter{dos}
\part{bar}...

This results in an entire page that is "Part I Uno". I would like to remove the page break, and have both part foo, and chapter uno on the same page as:

Part I foo
Chapter 1 Uno

How do I do that?

share|improve this question
1  
chapter produces also a page break. However you can use a package like titlesec. –  Marco Daniel Jan 27 '12 at 19:56
    
titlesec package is what you search for, as Marco suggests. The page break can be manually removed by some "low-level" tweak (you can locally redefine the command that makes the page break), but it is really not a nice solution to this. –  yo' Jan 27 '12 at 19:58

2 Answers 2

With the titlesec package, you could define a "title class" without pagebreak:

\titleclass{\part}{top}
\titleclass{\chapter}{straight}

Title classes are:

  • page: a single page like a book part page
  • top: starts a page and places the heading at the top
  • straight: titles in the text, such as by \section

A full example:

\documentclass{book}
\usepackage{titlesec}
\titleclass{\part}{top}
\titleformat{\part}[display]
  {\normalfont\huge\bfseries}{\centering\partname\ \thepart}{20pt}{\Huge\centering}
\titlespacing*{\part}{0pt}{50pt}{40pt}
\titleclass{\chapter}{straight}
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}
\begin{document}
\part{foo}
\chapter{uno}
\end{document}

part and chapter heading

share|improve this answer
    
I was hesitating to go the titlesec route, but this works well, and I am enjoying the flexibility of the package. A follow up question...this removes the page break at the end of the chapter. So a new part/chapter starts on the same page of the text as the previous chapter. I could use something like /eject and start a new page, but is there a nicer way to keep the page-break at the end of the chapter? –  Elmasto Jan 27 '12 at 20:32
    
@Elmasto: use the top class for parts starting on new pages. I updated my answer. –  Stefan Kottwitz Jan 27 '12 at 20:50
    
this does not work work with komascript(scrbook) –  user8868 May 6 '12 at 7:56

To achieve your objective without loading a package such as titlesec, one must (i) modify the command \@endpart and (ii) change the \chapter command because it, too, inserts a page break by default. Although you didn't specify this explicitly, I further assume that you (iii) want to have the "Part xx" material placed at the top of the page rather than in the middle. By the way, I assume that your document is set in "onecolumn" rather than in "twocolumn" mode. Taking care of the twocolumn case isn't all that more difficult, but it does add some overhead which I gather isn't required here.

The following code shows how to do this for the case of the report document class. Note that I've created a command called \nonewpagechapter and have left the standard \chapter command untouched. That way, you can still use the \chapter command for all those occasions when you do want the chapter to start on a new page. Of course, if \nonewpagechapter is too wordy for your taste, you can give it a more succinct name, such as \nchapter...

\documentclass{report}   
\usepackage{etoolbox}

\makeatletter
% First, modify the \@endpart macro.
\def\@endpart{} 

% Next, copy the \chapter macro to \nonewpagechapter, and ...
% ... suppress page-breaking instructions in the modified macro
\let\nonewpagechapter\chapter 
\patchcmd\nonewpagechapter{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}

% Third, suppress vertical whitespace before "Part xx" material
\patchcmd{\part}{\null\vfil}{}{}{}

\makeatother

\begin{document}
\part{foo}
\nonewpagechapter{Uno} % starts on same page as "Part I ... foo" header
\chapter{Dos}          % starts on a new page
\part{bar}             % starts on a new page
\nonewpagechapter{Tres}% starts on same page as "Part II ... bar" header
\end{document}

Addendum If someone were using the scrbook (Koma-Script book) document class instead of the report document class, he/she would have to replace the command

\patchcmd{\part}{\null\vfil}{}{}{}

with

\patchcmd{\part}{\partheadstartvskip}{}{}{}

in order to suppress the insertion of extra whitespace above the "Part xx" line. The other patch commands could be used without modification.

share|improve this answer
    
+1 for adding \nonewpagechapter. –  lockstep Jan 27 '12 at 20:15
    
I liked the idea of modifying the existing commands, but I am having a hard time compiling this (pdflatex). It says 'use of \@ doesn't match definition'. –  Elmasto Jan 27 '12 at 20:36
    
I added a blank line before \makeatletter. The MWE should compile now. –  Mico Jan 27 '12 at 20:43
    
I have tried your answer with koma script (a example is here: pastebin.com/JCKXvzhu), and the problem I have is that the part starts very low on the page. (In the example at about have the page, but in longer documents, it might even start lower). Do you know a fix for that? –  user8868 May 6 '12 at 13:38
    
@user8868: Do note that my answer was geared to the report document class, as that's what the OP specified. Which one of the koma-script classes are you using? Any adaptation of the code I've provided will depend on the document class in use. –  Mico May 6 '12 at 14:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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