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 want my report to have the first few sections with roman numbering (i, ii, iii...), and the body of the report with arabic numbering (1, 2, 3...) for the page numbers.

The problem is that the switch appears to be occurring a page earlier than I would expect from my code:

\documentclass{report}
\begin{document}
% === Abstract etc ===
\pagenumbering{roman}
\section*{first section}
Want this to be page i
\pagebreak
\section*{second section} 
Want this to be page ii, but it appears as 1 instead
\pagebreak
% === Body of report ===
\pagenumbering{arabic} %change to arabic for final page
\section*{third section}
Want this to be page 1, but it appears as 2 instead
\section*{fourth section}
\end{document}

I can see that If I put the \pagenumbering{arabic} command on the line below the third section then it fixes the problem, but this is inconvenient because if I have a modular document and comment out a section then I have to keep changing the position of \pagenumbering{arabic}.

Furthermore, If I put a line break before % === Body of report === it fixes the problem in my MWE (but not my actual report for some reason). Very confused at this behaviour.

Is this a bug? and is there a solution around it?

share|improve this question
    
Use \clearpage, not \pagebreak: you don't want to say “perhaps break here”, but “do break here”. –  egreg Mar 25 at 11:44
    
@egreg: thanks, that solved my MWE. You can put it as an answer and I'll accept it if you like. I still need to find out why my actual report is behaving in this way though (it doesn't use page breaks) :S Maybe something to do with \input{} –  Eksze Mar 25 at 11:50
    
For anybody with the same problem in modular documents: I solved it by adding \clearpage before \pagenumbering{arabic} and \input{chapter1} on my main tex file to tell it to go to the new page before changing the numbering. –  Eksze Mar 26 at 4:56

1 Answer 1

up vote 8 down vote accepted

The \pagebreak command works differently when given inside a paragraph or when between paragraphs (that is, with a blank line before it).

In your case, the second \pagebreak belongs to the paragraph having the text

Want this to be page ii, but it appears as 1 instead

and it will have effect only after the paragraph has been broken into lines, which happens when LaTeX scans \section*{third section} and already has changed the page numbering to arabic.

Don't be afraid to leave blank lines, but use \clearpage in situations like these; such a command ends the current paragraph, if not preceded by a blank line, so it solves the issue.

\documentclass{report}

\begin{document}

% === Abstract etc ===
\pagenumbering{roman}

\section*{first section}

This is page i

\clearpage


\section*{second section} 

This is page ii

\clearpage

% === Body of report ===
\pagenumbering{arabic} %change to arabic for final page

\section*{third section}

This is page 1


\section*{fourth section}

\end{document}

There is another difference between \pagebreak and \clearpage: if \flushbottom is in force (which it is in the book class), \pagebreak will try to fill up the page with the available text, while \clearpage fills it with blank space.

So \pagebreak is best used for fine tuning the page breaks, while \clearpage or \cleardoublepage are to be used when asking for “end the page here”.

share|improve this answer

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.