As described here I'm using chappg's \pagenumbering{bychapter} (implicitly via the auto option) to have pages numbered in the style \thechapter-\thepage. But now a \ifodd\thepage fails horribly, as this MWE shows:
\documentclass{scrbook} % same for book, btw
\usepackage[auto]{chappg}
\newcommand*{\whereami}{%
\ifodd\thepage%
odd page
\else
even page
\fi
}
\begin{document}
\whereami\clearpage\whereami
\chapter{new}
\whereami\clearpage\whereami
\chapter{again}
\whereami\clearpage\whereami
\end{document}
While the first two pages (outside a chapter) correctly output "odd page" and "even page" respectively, the first actual chapter yields "-1odd page" and "-2odd page" for its two pages, and the second one "even page" twice.
So it seems chappg overrides \thepage to become e.g. 1-2, and \ifodd\thepage only checks the chapter number's oddness, in which case the -2 becomes part of the then output.
I already tried fixing this by using pageslts's \theCurrentPage instead, but unfortunately that seems to mess around with \thepage (or \pagenumbering?) as well, since by merely including that package in addition I get the error
! Argument of \extract@ has an extra }.
<inserted text>
\par
l.18 \whereami\clearpage
\whereami
So, how can I fix this mess?
\ifodd\thepagefailed – Tobias Kienzler Dec 02 '15 at 15:31\ifodd\thepageis a bad idea - though it probably boils down to "\thepageis the page number label, not the actual number" – Tobias Kienzler Dec 02 '15 at 15:37pagesltsapparently can't when usingchappg. – Tobias Kienzler Dec 02 '15 at 15:46\thepageis not a fixed quantity until page shipout. Thus, testing upon it can lead to spurious results. – Steven B. Segletes Dec 02 '15 at 15:48\thepageis indeed wrong for testing the page number since\thepagemight very well be\roman{page}or something, i.e., it does not have to expand to a number so testing for\value{page}would be better. But this is only a secondary problem. @StevenB.Segletes mentions the real problem: page numbers are only fixed when the page is shipped out – this is the reason for the various ways for checking even/odd pages which in the end all fetch the information from the aux file. – cgnieder Dec 03 '15 at 10:46\AtBeginShipoutone should have a fixed page number – Tobias Kienzler Dec 03 '15 at 10:48