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.

Why does \ifoddpage seem to always return false in the following example? This is related to question 6143 on this same forum. I'm using XeLaTeX to produce a pdf file (i.e., xelatex test.tex)

\documentclass[11pt,final,openright]{memoir}
% for Blurb, set this to the actual desired size as indicated by the
% size calculator on their web site
% See the memoir class documentation for an explanation of all the page
% layout parameters.
\setstocksize{594pt}{693pt}
\settrimmedsize{576pt}{684pt}{*}
\settrims{9pt}{9pt}
\setlrmarginsandblock{81pt}{54pt}{*} % calculates \textwidth
\setulmarginsandblock{72pt}{36pt}{*} % calculates \textheight
\setheadfoot{0pt}{18pt}
\setheaderspaces{0pt}{*}{*}
\raggedright     % comment to force even justification
\setlength{\parindent}{0in}   % paragraph indentations
\setlength{\parskip}{1em}   % space between paragraph
\checkandfixthelayout    % Set all the layout values
\usepackage{ifthen}
\newcounter{mycount}
\begin{document}
\whiledo{\themycount<130}{%
  \ifoddpage
    {Odd\\}%
  \else
    {Even\\}%
  \fi
  \stepcounter{mycount}%
}
\end{document}
share|improve this question
1  
Welcome to TeX.SX! For future reference, you can format code by prepending each line with four spaces; this can be automatically done by selecting it all and clicking the 101010 button, or just hitting control-k. –  Antal S-Z Dec 19 '10 at 1:17
    
I added a link to question 6143. To do this, highlight the text and click the little picture of the chain links, and the put the relevant URL in the popup box. –  Seamus Dec 19 '10 at 12:24

1 Answer 1

You have to call \checkoddpage before, which sets \ifoddpage to true or to false. Better do a strict check. This works fine in your code, toggling Odd and Even on page breaks:

\strictpagechecktrue%
\whiledo{\themycount<130}{%
  \checkoddpage%
  \ifoddpage%
    {Odd\\}%
  \else
    {Even\\}%
  \fi
  \stepcounter{mycount}%
}
share|improve this answer
    
Thanks Stefan ! –  Tim Jacobs Dec 19 '10 at 2:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.