27

I saw the command \clearpage{\thispagestyle{empty}\cleardoublepage} on a project and I didn't understand clearly what it was doing so I tried to use it in a minimal project. If I create document of class book I get numbers in the header at the right on odd pages and at the left on even pages.

If I put the command before including fun-1.tex file it will hide the header number of that file. Here is main.tex showing that:

\documentclass[12pt, a4paper]{book}

\begin{document}

\clearpage{\thispagestyle{empty}\cleardoublepage}

\include{fun-1}

\include{fun-2}

\include{fun-3}

\include{fun-4}

\end{document}

If I put the command after the include fun-1.tex file it will add a blank page after this fun-1 file and that blank page will increase count number despite that page having no number. main.tex looks like this:

\documentclass[12pt, a4paper]{book}

\begin{document}

\include{fun-1}

\clearpage{\thispagestyle{empty}\cleardoublepage}

\include{fun-2}

\include{fun-3}

\include{fun-4}

\end{document}

The other files:

fun-1.tex:

This is fun-1

fun-2.tex:

This is fun-2

fun-3.tex:

This is fun-3

fun-4.tex:

This is fun-4

I would like to know how this command works and where it is useful. It's the first time I see two commands inside curly braces, I don't quite get what is going on there.

2
  • 4
    Welcome to TeX.SX! One shouldn't be advised to use that thing, because \usepackage{emptypage} is much easier. Good question nonetheless.
    – egreg
    Mar 28, 2017 at 6:01
  • The curly braces are grouping the two commands. It's the same as if you write {\bfseries this is a group}. They are not any argument to \clearpage if you thought that.
    – Skillmon
    Mar 28, 2017 at 6:12

1 Answer 1

31

Here's what the commands are supposed to do.

  1. \clearpage ends the current page and prepares LaTeX to build a new one

  2. { opens a group

  3. \thispagestyle{empty} tells LaTeX to avoid adorning the current page with headers and footers

  4. \cleardoublepage tells LaTeX to issue a new page if the current one (the fresh page initiated after \clearpage) is odd numbered

  5. } closes the group

What happens is that if the fresh page is odd numbered, \cleardoublepage does add a new page, which will be empty; otherwise, the effect of \thispagestyle{empty} will finish as soon as } is processed, so if the page is even numbered, nothing happens.

Anyway, it's much easier to add

\usepackage{emptypage}

in the document preamble, rather than

\clearpage{\thispagestyle{empty}\cleardoublepage}

before starting each chapter.

2
  • 1
    Should \cleardoublepage end on an odd or even number? On my computer, this macro is (almost) \clearpage \ifodd \c@page \else \hbox {}\newpage \fi, i.e. "clear page ; if page number is even (is not odd), clear another page" — so I'm left on an odd numbered page. Isn't it?
    – audeoudh
    Feb 18, 2020 at 9:16
  • 1
    @ryolait Yes, that's the idea: after \cleardoublepage the next page will be odd-numbered (provided twoside is in effect).
    – egreg
    Feb 18, 2020 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .