1

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:

\newcommand{\PartEinleitung}{0}
\newcommand{\PartHauptteil}{1}
\newcommand{\PartAppendix}{2}
\newcommand{\mPart}{}
\newcommand{\setPart}[1]{\renewcommand{\mPart}{#1}}
\newcommand{\mWriter}{}
\newcommand{\setWriter}[1]{\renewcommand{\mWriter}{#1}}

\ifnum\mPart=\PartEinleitung
    \rofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageEinleitung}}
\fi
\ifnum\mPart=\PartHauptteil
        \rehead*{\headmark}
        \lehead*{\mWriter}
        \rofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageHauptteil}}
\fi

The error is:

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

Hope you can help me, thank you!

9
  • 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

0

Here's how I solved it:

\usepackage{scrlayer-scrpage}
\automark*{chapter}
\automark*{section}
\setkomafont{pageheadfoot}{\sffamily}
\setkomafont{pagination}{}

\newcommand{\PartEinleitung}{
    \clearpairofpagestyles
    \KOMAoptions{footsepline=true, plainfootsepline=true}
    \ofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageEinleitung}}
}
\newcommand{\PartHauptteil}{
    \clearpairofpagestyles
    \KOMAoptions{headsepline=true, plainheadsepline=true}
    \ihead*{\headmark}
    \ohead*{\mWriter}
    \ofoot*{\small\color{gray} Seite \thepage~von \pageref{LastPageHauptteil}}
}
\newcommand{\PartAppendix}{
    \clearpairofpagestyles
    \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 .