3

I'm writing a report and I want to make sure that each new chapter starts in an odd page. So I wrote the following script which I put before each chapter:

...    
%-- to make sure that a new chapter starts on the right side (odd page) %
\ifodd \thepage
{\newpage
\thispagestyle{empty}
\mbox{}
}
\else
{}
\fi
%-----------------------------------------------------------------------%
\chapter{Chap_name}
...

It works as following:

If the page before my new chapter is odd, it means that I have to add a blank page in order to start to start the new chapter in the next odd page number.

It works fine if the previous page is a normal page.

But when I have a figure in the page before it, which was moved to a new page since it did not fit in the page and there is not text in the page alongside with the float, then this script does not work.

The command \thepage returns a wrong page number (apparently it does not increment if the page only contains a float) and so it does not add a blank page in case the last page was indeed odd.

I dont know how to solve this issue. any ideas?

thanks for helping.

1 Answers1

9

Remarks:

  • \thepage can be anything, roman numerals, complex page numbers (1-2), … However, \ifodd only expects an arabic number. Better is the use of the counter value \value{page}.

  • The output routine is called asynchronous. Therefore at the time of \ifodd somewhere it is not clear, what the pages will be. Much more safe is the place at the top of a page.

  • Many document classes provide option twoside and command \cleardoublepage. For instance, KOMA-Script classes provide lots of options and commands. Also a chapter usually starts with \cleardoublepage if twoside is given.

For the standard classes, \cleardoublepage can be redefined to set empty headers and footers for empty pages:

\makeatletter
\renewcommand*{\cleardoublepage}{%
  \clearpage % output floats if necessary
  % new page starts here
  \if@twoside
    \ifodd\value{page}%
    \else
      \begingroup
        \pagestyle{empty}%
        \hbox{}\newpage
        \if@twocolumn
          \hbox{}\newpage
        \fi
      \endgroup
    \fi
  \fi
}
\makeatother
Heiko Oberdiek
  • 271,626