I want to have different headers/footers, depending on what "part" I have, which is defined in the "mPart" variable...

I'm using the following code to distinguish between the parts:


    \rofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageEinleitung}}
        \rofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageHauptteil}}

The error is:

Missing number, treated as zero. \ifnum\mPart=

Hope you can help me, thank you!

  • 1
    Have you tried \ifx instead of \ifnum?
    – TeXnician
    Commented Dec 3, 2017 at 18:40
  • 1
    I think it should be \rehead*{\ifx\mPart\PartHauptteil\headmark\fi}. At the time you're trying to set those headers your variables don't have the intended contents.
    – Skillmon
    Commented Dec 3, 2017 at 18:52
  • Don't use \ifnum in LaTeX; see the ifthen package or the etoolbox package. And I'm sure expl3 also offers constructs. Commented Dec 4, 2017 at 15:50
  • See tex.stackexchange.com/q/5894/5763 Commented Dec 4, 2017 at 15:51
  • @MartinSchröder Why no \ifnum in LaTeX? I use it all the time, in preference to the the ifthen package. Commented Dec 4, 2017 at 15:52

1 Answer 1


Here's how I solved it:


    \KOMAoptions{footsepline=true, plainfootsepline=true}
    \ofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageEinleitung}}
    \KOMAoptions{headsepline=true, plainheadsepline=true}
    \ofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageHauptteil}}
    \KOMAoptions{headsepline=false, plainheadsepline=false}
    \ofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageAppendix}}

Instead of using if else, i just change the Header and Footer using a command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .