# how to use memoir \ifoddpage

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
\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}

-
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

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}%
}

-
 Thanks Stefan ! – Tim Jacobs Dec 19 '10 at 2:29