How to use if-then-else structure in LaTeX?
I need an example of odd and even page.
if odd then
command 1
else
command 2
conditionalspage-numbering
How to use if-then-else structure in LaTeX?
I need an example of odd and even page.
if odd then
command 1
else
command 2
Best Answer
You can use the
changepage
package, a minimal working example isIf you use the
memoir
class, then this feature is built in automatically, but you should write\strictpagecheck
in the preamble to make the test robust.Note that if the
\checkoddpage
falls between two pages the result of the test could still be wrong even if strict mode is on. E.g., you finish a paragraph, you're on the end of page 4, write\checkoddpage
which gives false, then insert something which breaks over to the next page. In that case you need to write\leavevmode\checkoddpage
or somehow get the check into whatever is being typeset next, rather than before it.However, most of the time
\checkoddpage
is used in contexts were this isn't an issue so it shouldn't be a major concern.