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.

The commands \newpage and \clearpage both force a page break. In addtion, the latter command also "flushes" all pending floats from the stack, i.e., forces them to be typeset starting on the page that follows the page break.

My question is: Is it ever a mistake to use \clearpage rather than \newpage, other than in cases where one might not want any pending floats to be flushed? From a casual inspection of the definitions of the two commands (see below), I can't tell if there's any trouble lurking in always using \clearpage.

For ease of reference, here's the definition of \newpage (from latex.ltx):

\def \newpage {%
  \if@noskipsec
    \ifx \@nodocument\relax
      \leavevmode
      \global \@noskipsecfalse
    \fi
  \fi
  \if@inlabel
    \leavevmode
    \global \@inlabelfalse
  \fi
  \if@nobreak \@nobreakfalse \everypar{}\fi
  \par
  \vfil
  \penalty -\@M}

and here's the definition of \clearpage -- note that it invokes \newpage:

\def\clearpage{%
  \ifvmode
    \ifnum \@dbltopnum =\m@ne
      \ifdim \pagetotal <\topskip
        \hbox{}%
      \fi
    \fi
  \fi
  \newpage
  \write\m@ne{}%
  \vbox{}%
  \penalty -\@Mi
}
share|improve this question
add comment

2 Answers

up vote 65 down vote accepted

Technically there is nothing wrong with using \clearpage instead of \newpage. However, the two commands have different semantics and the question is which of the semantics you are interested in.

First of all, as you already mentioned \clearpagenot only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with \newpage you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast \clearpagewould also output this float but on a page of its own.

So in situations like a chapter start it is advisable to end the previous chapter with a \clearpage (or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.

A second difference is \clearpage actually always starts a new "page" while \newpagereally only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:

\documentclass[twocolumn]{article}
\begin{document}
A test
\newpage              % ends first column but not page
A second test
\newpage

A clearpage test
\clearpage             % ends page (which has one column)
A second clearpage test
\end{document}
share|improve this answer
    
Ok, I must claim I didn't think of twocolumn in my answer. But honestly: using \newpage or \clearpage inside a text block like chapter is really frowned upon in my opinion and should be done very carefully. –  tohecz Feb 24 '12 at 13:27
3  
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary. –  Frank Mittelbach Feb 24 '12 at 13:39
    
Yes, I know and somehow agree. And the truth is, \newpage is more appropriate in that case probably. –  tohecz Feb 24 '12 at 14:00
1  
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz, \newpage forces a new column whereas \clearpage forces a new page. –  Mico Feb 24 '12 at 14:01
add comment

In my opinion, you can use \clearpage anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:

  • a really empty page, then you call for instance \newpage\leavevmode\thispagestyle{empty}\newpage
  • something placed on a specific page or whatever (\clearpage may add more than one pagebreak if there's a lot of queued floats, whereas \newpage adds only one)
  • when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use \newpage after typesetting the chapter title).

Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my \chapter mentioned above) or in preamble/...

share|improve this answer
add comment

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.