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'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.

share|improve this question
2  
Have you checked \cleardoublepage? –  Alex Aug 28 '12 at 8:29
2  
Use the class options 'twoside' and 'openright'. –  lockstep Aug 28 '12 at 8:33

1 Answer 1

up vote 8 down vote accepted

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
share|improve this answer
    
Thanks Heiko Oberdiek, very informative. –  user18098 Aug 28 '12 at 9:28

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.