25

I am not sure whether invoking \clearpage is necessary or redundant at many places in my input .tex files.

Here I will ask you, in what condition is invoking \clearpage necessary?

I hope I get a list of all possible condition that might be also useful for others.

In my daily work, I do as follows:

  1. If I need a new page for the next stuff, I put \clearpage right before the stuff.
  2. If I need to change the header/footer style for the next stuff, I put \clearpage followed by \pagestyle right before the stuff.
  3. If I get a "too many floots" error, I put \clearpage at the end of every 5 consecutive floats.
Martin Scharrer
  • 262,582
Display Name
  • 46,933
  • I'm not really sure I understand the question. You should use \clearpage and \newpage whenever you want a new page. When do you think you're using it inappropriately? – Will Robertson Jan 18 '11 at 06:39
  • @Will: thanks for commenting. Please see my update. @Yiannis: It is worth seeing my update too. – Display Name Jan 18 '11 at 06:55
  • 1
    for item 3) if you get this error often it is advisable to use the "morefloats" package, for an explanation see http://tex.stackexchange.com/questions/8212/an-explanation-of-latexs-output-routine/8736#8736 . Classes such as the tufte-book incorporate this package in the class definitions. – yannisl Jan 18 '11 at 07:14
  • 1
    again for 3: you might be underspecifying where your floats can appear. You should always write your document with either [tbp] or [htbp] to give the floats some room and only start constraining them when the document is finished. Or you might just be using too many floats :) – Will Robertson Jan 18 '11 at 07:26

3 Answers3

29

In general, you do not need any \clearpage because page breaking should be done automatically by the TeX engine. However, in some cases, eg having lots of images or equations, one has to insert a manually pagebreak.

  • \newpage ends the page immediately at the current position and starts a new page without any stretching of the page
  • \pagebreak[value] ends the page after the current line and stretches the vertical page to end up on the lower page border, if there is any material with glue
  • \clearpage outputs all active floats and ends the page like \newpage
  • \cleardoublepage same for double sided documents

With the package nextpage one can also use the macros \cleartoevenpage and \cleartooddpage

14

I think others have given good answers, but if you find yourself needing to use \clearpage to flush out floats, then it's usually better to use the afterpage package to clear the floats at the end of the page.

\afterpage{\clearpage}

That way you don't just end the page right there; you end the page at the normal break point.

Martin Scharrer
  • 262,582
TH.
  • 62,639
13

The use of \clearpage in an author's document should be limited to only a few instances. The command should be used in class files normally in places such as the definitions for chapter, title,appendix, bibliography, toc and the like.

With a well written class the author should never really need to insert a \clearpage command. However, there maybe instances (especially when someone has too many floats) that one needs to enforce a pagebreak and the printing of floats. In this case the \clearpage command is recommended.

yannisl
  • 117,160
  • @Yiannis: Your answer is NOT clear when I (as an document author) should use \clearpage in the input file. – Display Name Jan 18 '11 at 04:30
  • @xport Never really! But I will modify the answer:) – yannisl Jan 18 '11 at 04:34
  • @Yiannis: how about when changing the pagestyle? – Display Name Jan 18 '11 at 04:50
  • 1
    @xport Do you want the author to do this? Shouldn't the author for example just type \mainmatter? – yannisl Jan 18 '11 at 04:53
  • @Yiannis: when I change some pages containing long table from potrait to landscape, I must change the page style. – Display Name Jan 18 '11 at 04:54
  • 1
    @xport If you do this often enough, then it is best to define a 'landscapepageorlandscapetable` command and place it in the class file or a package. In general the author should be typing contents and not worry about the looks of the page; that belongs to the class author. – yannisl Jan 18 '11 at 05:06
  • 1
    @xport Just thinking aloud I would give this type of table a more semantic name such as readonceeverytenyearstable as landscape tables are really unreadable and very few people would bother reading them :) – yannisl Jan 18 '11 at 05:10