The KOMA-pagestyle-package^{∗}

Markus Kohm

1994/12/31

Abstract

This is scrpage.sty. This package is part of the KOMA-script-bundle. It defines a new userinterface for pagestyle-definition. It’s something like fancyheadings but not the same. You may use scrpage or fancyheadings. You may use scrpage with standard classes, too.

Contents

1 Introduction 1 1.1 Interface for all users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Interface for experts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Implementation 4 2.1 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Some Initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 Predefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.4 Expert-Pagestyle-Definition-Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.5 User-Pagestyle-Definition-Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.6 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.7 Configurationfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.8 End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1 Introduction

There is a simple user-interface and a expert-interface. Using the user-interface you can define a lot of different pagestyles. But there are combinations, you cannot define. Using the expert-interface you can do allmost all you may ever want. To do more, you should learn more about defining macros yourself.

∗This file has version number v1.0a, last revised 1994/12/31.

1. Introduction

1.1 Interface for all users

\headfont

This font is used to write pageheads and -foots. You may change it using \renewcommand, e.g.

\renewcommand\headfont{\normalfont\slshape}.
\headmark

Using twoside-option this is \leftmark at left/even pages and \rightmark at right/odd pages. Using oneside-option there are only right pages, so it is \rightmark.

\pnumfont

This font is used to write pagenumbers at \pagemark. You may change it using \renewcommand (see

\headfont).
\pagemark

This is the number of the actual page written with \pnumfont.

\deftribstyle {name}[olw][ilw] {headleft}{headmiddle}{headright} {footleft}{footmiddle}{footright} Defines a new pagestyle. You can activate this pagestyle using \pagestyle or \thispagestyle. Without optional argument this defines a page like this:

headright headmiddle  headleft left page footright  footmiddle  footleft headleft  headmiddle headright right page footleft  footmiddle  footright

Using one optional argument [ilw] (means inner line width) you get a separationline between head and text and between text and foot like this (ilw=0.5pt):

headright headmiddle  headleft left page footright  footmiddle  footleft headleft  headmiddle headright right page footleft  footmiddle  footright

Using both optional arguments [olw] (means outer line width) and [ilw] you get a separationline between head and text and between text and foot and a line above head and below foot like this (olw=2pt, ilw=0.5pt):

headright headmiddle  headleft left page footright  footmiddle  footleft headleft  headmiddle headright right page footleft  footmiddle  footright

You can define new pagestyles and you can redefine existing pagestyles. If you redefine an active pagestyle, this doesn’t change the actual shown pagestyle. To activate you have to use always a

\pagestyle- or \thispagestyle-command.

You can change the standard pagestyle headings to. If you want to change pagestyle myheadings, you should use the star-version of the command:

\deftribstyle *{name}[olw][ilw] {headleft}{headmiddle}{headright} {footleft}{footmiddle}{footright} this defines a my-version pagestyle. This means, section- and chapter-commands or perhaps \tableofcontents don’t change the marks. Only \markboth and \markright change them. But if

you don’t use \headmark, \leftmark or \rightmark, star- and starless version of \deftribstyle

are almost the same.

1.2 Interface for experts

\defpagestyle {name}{head-definition}{foot-definition} defines a new pagestyle name. head-definition defines the head at the new pagestyle. It contains five part: (toplinelength,toplinewidth) {evenpagehead}{oddpagehead}{onesidepagehead} (headseplinelength,headseplinewidth) These five parts have to be one argument! So you should put them together in group-braces (“{” and “}”).

foot-definition analogous defines the foot at the new pagestyle.

\newpagestyle {name}{head-definition}{foot-definition} defines a real new pagestyle. If there’s already a pagestyle named name, you’ll get an error. Otherwise it’s the same like \defpagestyle.

\renewpagestyle {name}{head-definition}{foot-definition} redefines a old pagestyle. If there isn’t a pagestyle named name, you’ll get an error. Otherwise it’s

the same like \defpagestyle.

\providepagestyle {name}{head-definition}{foot-definition} defines a new pagestyle, if it is realy new. If there is already a pagestyle named name, it does nothing (but writing an info to the log file). Otherwise it’s the same like \defpagestyle.

You may use the user-interface-macros \pagemark and \headmark, too.

1.3 Configuration file

There’s a configuration file scrpage.cfg, included at the end of scrpage.sty, if it exists. There you can define your own default pagestyles using all the commands above.

1.4 Example

The pagestyles of this documentation was defined using:

 \renewpagestyle{headings}{(\textwidth,1pt)%
                 {\headmark\hfill}{\hfill\headmark}{\hfill\headmark\hfill}%
                 (\textwidth,.4pt)}%
                {(\textwidth,.4pt)%
                 {\pagemark\hfill%
                  Copyright $\copyright$ Markus Kohm, 1994-1995}%
                 {Package \texttt{scrpage}\hfill\pagemark}%
                 {\rlap{Package \texttt{scrpage}}\hfill%
                  Copyright $\copyright$ Markus Kohm, 1994-1995\hfill%

2. Implementation

                 \llap\pagemark}%
                (\textwidth,1pt)}
\renewpagestyle{plain}{(\textwidth,1pt)%
                       {\hfill}{\hfill}{\hfill}%
                       (\textwidth,.4pt)}%
                      {(\textwidth,.4pt)%
                       {\pagemark\hfill}%
                       {\hfill\pagemark}%
                       {\hfill\pagemark\hfill}%
                       (\textwidth,1pt)}
\pagestyle{headings} % activate new version

2 Implementation

1 ⟨∗scrpage⟩

2.1 Options

scrpage knows some options. They are similar to the KOMA-script-classes. To work with and without the KOMA-script-classes their definitions are not quite simple.

2 \DeclareOption{headinclude}{\PassOptionsToPackage{headinclude}{typearea}}
3 \DeclareOption{headexclude}{\PassOptionsToPackage{headexclude}{typearea}}
4 \DeclareOption{footinclude}{\PassOptionsToPackage{footinclude}{typearea}}
5 \DeclareOption{footexclude}{\PassOptionsToPackage{footexclude}{typearea}}

We do so, because we want so set headinclude, footinclude by default!

6 \ExecuteOptions{headinclude,footinclude}

But you may set other Options:

7 \ProcessOptions

2.2 Some Initialisation

For easier handling of the differences between article-, report- and book-classes we define some more switches.

\if@chapter First distinguish between article and others.

8 \newif\if@chapter
9 \ifx\chapter\undefined \@chapterfalse\else\@chaptertrue\fi

\if@matter Next distinguish between matter- and nomatter-classes.

10 \ifx\mainmatter\undefined \newif\if@mainmatter\@mainmattertrue\fi

2.3 Predefinitions

There are some commands, you can use at pagestyle-definition.

\headmark This macro is \rightmark or \leftmark. But outside pagestyle-definition it’s nothing.

11 \let\headmark\relax

\pagemark This macro is the number of the page at the pagenumberfont:

12 \DeclareRobustCommand\pagemark{{\pnumfont\thepage}}

2.4 Expert-Pagestyle-Definition-Interface

The pagestyle-definition-interface for experts is not as easy as the simple interface we’ll define later. But it’s more flexible. We’ll later use is to define the pagestyle-definition-interface for users.

\defpagestyle First we define the simple definition-interface. There’s no test, if the pagestyle’s defined twice.

First there has to be the definition of head and foot.

13 \def\defpagestyle{%

We have to decide, wether it is a my-version or not:

14 \@ifstar
15 {\@defpagestyle[-]}%
16 {\@defpagestyle[+]}}

Now the we can define the head and the foot. First at twoside-mode:

17 \if@twoside
18 \def\@defpagestyle[#1]#2#3#4{%
19  \expandafter\def\csname ps@#2\endcsname{%
20  \def\@tempa{+}%
21  \def\@tempb{#1}%
22  \ifx\@tempa\@tempb
23  \let\@mkboth\markboth
24  \if@chapter
25  \def\chaptermark####1{%
26  \markboth {\ifnum \c@secnumdepth >\m@ne%
27  \if@mainmatter\thechapter. \ \fi\fi ####1}{%
28  \ifnum \c@secnumdepth >\m@ne%
29  \if@mainmatter\thechapter. \ \fi\fi ####1}}%
30  \def\sectionmark####1{%
31  \markright {\ifnum \c@secnumdepth >\z@%
32  \thesection\ \fi ####1}}
33  \else
34  \def\sectionmark####1{%
35  \markboth {\ifnum \c@secnumdepth >\z@%
36  \thesection. \ \fi ####1}{%
37  \ifnum \c@secnumdepth >\z@%
38  \thesection. \ \fi ####1}}
39  \def\subsectionmark####1{%
40  \markright {\ifnum \c@secnumdepth >\@ne%
41  \thesubsection\ \fi ####1}}

42  \fi
43  \else
44  \let\@mkboth\@gobbletwo
45  \if@chapter
46  \def\chaptermark####1{}
47  \else
48  \def\subsectionmark####1{}
49  \fi
50  \def\sectionmark####1{}
51  \fi
52  \def@twosidehead#3
53  \def@twosidefoot#4

54 } 55 }

56 \else

Then the oneside-mode:

57 \def\@defpagestyle[#1]#2#3#4{%
58  \expandafter\def\csname ps@#2\endcsname{%
59  \def\@tempa{+}%
60  \def\@tempb{#1}%
61  \ifx\@tempa\@tempb
62  \let\@mkboth\markboth
63  \if@chapter
64  \def\chaptermark####1{%
65  \markright {\ifnum \c@secnumdepth >\m@ne%
66  \if@mainmatter\thechapter. \ \fi\fi ####1}}%
67  \def\sectionmark####1{}
68  \else
69  \def\sectionmark####1{%
70  \markright{\ifnum \c@secnumdepth >\z@%
71  \thesection. \ \fi ####1}}
72  \def\subsectionmark####1{}
73  \fi
74  \else
75  \let\@mkboth\@gobbletwo
76  \if@chapter
77  \def\chaptermark####1{}
78  \else
79  \def\subsectionmark####1{}
80  \fi
81  \def\sectionmark####1{}
82  \fi
83  \def@onesidehead#3
84  \def@onesidefoot#4

85 } 86 }

87 \fi

This was real simple, but we already have to do the real definition of the heads and foots. First the twosided head:

\def@twosidehead
 88 \def\def@twosidehead(#1,#2)#3#4#5(#6,#7){
 89 \def\@evenhead{\let\headmark\leftmark%
 90  \vbox{\hsize=\textwidth
 91  \hf@rule{#1}{#2}\vskip#2
 92  \vskip\baselineskip\hbox to\textwidth{{\headfont\strut #3}}
 93  \hf@rule{#6}{#7}
 94 }}
 95 \def\@oddhead{\let\headmark\rightmark%
 96  \vbox{\hsize=\textwidth
 97  \hf@rule{#1}{#2}\vskip#2
 98  \vskip\baselineskip\hbox to\textwidth{{\headfont\strut #4}}
 99  \hf@rule{#6}{#7}

100 }} 101 }

Next the onesided head:

\def@onesidehead
102 \def\def@onesidehead(#1,#2)#3#4#5(#6,#7){
103 \def\@evenhead{}
104 \def\@oddhead{\let\headmark\rightmark%
105  \vbox{\hsize=\textwidth
106  \hf@rule{#1}{#2}\vskip#2
107  \vskip\baselineskip\hbox to\textwidth{{\headfont\strut #5}}
108  \hf@rule{#6}{#7}

109 }} 110 }

And last twosided and onesided foot:

\def@twosidefoot
111 \def\def@twosidefoot(#1,#2)#3#4#5(#6,#7){
112 \def\@evenfoot{\let\headmark\leftmark%
113  \vbox{\hsize=\textwidth
114  \topfoot@rule{#1}{#2}\hbox to\textwidth{{\headfont\strut #3}}
115  \botfoot@rule{#6}{#7}}}
116 \def\@oddfoot{\let\headmark\rightmark%
117  \vbox{\hsize=\textwidth
118  \topfoot@rule{#1}{#2}\hbox to\textwidth{{\headfont\strut #4}}
119  \botfoot@rule{#6}{#7}}}

120 }

\def@onesidefoot
121 \def\def@onesidefoot(#1,#2)#3#4#5(#6,#7){
122 \def\@evenfoot{}
123 \def\@oddfoot{\let\headmark\rightmark%
124  \vbox{\hsize=\textwidth
125  \topfoot@rule{#1}{#2}\hbox to\textwidth{{\headfont\strut #5}}
126  \botfoot@rule{#6}{#7}}}

127 }

We now define the rules used at head and foot.

\topfoot@rule
128 \newcommand\topfoot@rule[2]{%
129 \@tempdima\baselineskip\advance\@tempdima by-.7\normalbaselineskip
130 \advance\@tempdima by -#2
131 \vskip\@tempdima\hf@rule{#1}{#2}\vskip-\@tempdima}
\botfoot@rule
132 \newcommand\botfoot@rule[2]{%
133 \@tempdima-\baselineskip\advance\@tempdima by .3\normalbaselineskip
134 \advance\@tempdima by #2
135 \vskip\@tempdima\hf@rule{#1}{#2}}
\hf@rule
136 \newcommand\hf@rule[2]{%
137 \@tempdimb#1
138 \hbox to\textwidth{\hfill%
139  \llap{\vrule\@depth#2\@height\z@\@width.5\@tempdimb}%
140  \rlap{\vrule\@depth#2\@height\z@\@width.5\@tempdimb}%
141  \hfill}}

Using these definitions, we can define the testing macros.

\newpagestyle First the simple star/starless-selection:

142 \def\newpagestyle{%

We have to decide, wether it is a my-version or not:

143 \@ifstar
144 {\@newpagestyle[-]}%
145 {\@newpagestyle[+]}}

\@newpagestyle There we have to distinguish, wether the pagestyle is already defined or not.

146 \def\@newpagestyle[#1]#2#3#4{
147 \expandafter\ifx\csname ps@#2\endcsname\relax

Then we can use the already defined \@defpagestyle.

148  \@defpagestyle[#1]{#2}{#3}{#4}
149 \else
150  \PackageError{scrpage}{Your command was ignored}%
151  {There is already a pagestyle named ``#1''.\MessageBreak%
152  Use \protect\defpagestyle\space, \protect\renewpagestyle or
153  \protect\provide\pagestyle.}
154 \fi

155 }

\renewpagestyle First the simple star/starless-selection:

156 \def\renewpagestyle{%

We have to decide, wether it is a my-version or not:

157 \@ifstar
158 {\@renewpagestyle[-]}%
159 {\@renewpagestyle[+]}}

\@renewpagestyle There we have to distinguish, wether the pagestyle is already defined or not.

160 \def\@renewpagestyle[#1]#2#3#4{
161 \expandafter\ifx\csname ps@#2\endcsname\relax
162  \PackageError{scrpage}{Your command was ignored}%
163  {There is no pagestyle named ``#1''.\MessageBreak%
164  Use \protect\defpagestyle\space, \protect\newpagestyle or
165  \protect\provide\pagestyle.}
166 \else

Then we can use the already defined \@defpagestyle.

167  \@defpagestyle[#1]{#2}{#3}{#4}
168 \fi

169 }

\providepagestyle First the simple star/starless-selection:

170 \def\providepagestyle{%

We have to decide, wether it is a my-version or not:

171 \@ifstar
172 {\@providepagestyle[-]}%
173 {\@providepagestyle[+]}}

\@providepagestyle There we have to distinguish, wether the pagestyle is already defined or not.

174 \def\@providepagestyle[#1]#2#3#4{
175 \expandafter\ifx\csname ps@#2\endcsname\relax

Then we can use the already defined \@defpagestyle.

176  \@defpagestyle[#1]{#2}{#3}{#4}
177 \else
178  \PackageInfo{scrpage}{\protect\providepagestyle\protect{#1\protect}
179  ignored.}
180 \fi

181 }

2.5 User-Pagestyle-Definition-Interface

The pagestyle-definition-interface for users is much easier than the expert-version. Using the expertmacros, the definition is easy, too.

First we define the selection of star- or starless-version:

\deftripstyle
182 \def\deftripstyle{%
183 \@ifstar
184 {\@deftripstyle[-]}%
185 {\@deftripstyle[+]}}

Next we check, if there is an optional argument:

\@deftripstyle
186 \def\@deftripstyle[#1]#2{%
187 \@ifnextchar[
188 {\@@deftripstyle[#1]{#2}}%
189 {\@@deftripstyle[#1]{#2}[0pt]}}

or perhaps two optional arguments:

\@@deftripstyle
190 \def\@@deftripstyle[#1]#2[#3]{

Ok, now we have the problem, that there can be only 9 arguments. So we have to distinguish the star-versions by a macro:

191 \def\@tempa{#1}
192 \@ifnextchar[
193 {\@@@deftripstyle#2[#3]}%
194 {\@@@deftripstyle#2[0pt][#3]}}

Now the main-definition:

\@@@deftripstyle
195 \def\@@@deftripstyle#1[#2][#3]#4#5#6#7#8#9{%
196 \def\@tempb{+}
197 \ifx\@tempa\@tempb%
198  \defpagestyle{#1}%
199  {(\textwidth,#2)%
200  {\rlap{#6}\hfill{#5}\hfill\llap{#4}}%
201  {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
202  {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
203  (\textwidth,#3)}
204  {(\textwidth,#3)%
205  {\rlap{#9}\hfill{#8}\hfill\llap{#7}}%
206  {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
207  {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
208  (\textwidth,#2)}
209 \else
210  \defpagestyle*{#1}%
211  {(\textwidth,#2)%
212  {\rlap{#6}\hfill{#5}\hfill\llap{#4}}%
213  {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
214  {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
215  (\textwidth,#3)}
216  {(\textwidth,#3)%
217  {\rlap{#9}\hfill{#8}\hfill\llap{#7}}%
218  {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
219  {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
220  (\textwidth,#2)}
221 \fi

222 }

2.6 Fonts

\pnumfont We have to define a macro defining the font, used by \pagemark. Because of this macro may already be defined by a KOMA-script-class, we have to do this, using \providecommand

          223 \providecommand\pnumfont{\normalfont}
\headfont There is also a macro used by \@evenhead, \@oddhead and \@evenfoot, \@oddfoot:
          224 \providecommand\headfont{\normalfont}

2.7 Configurationfile

Last but not least we include the local configuration-file scrpage.cfg, if it exists.

          225 \InputIfFileExists{scrpage.cfg}
          226  {\typeout{*************************************^^J%
          227  * Local config file scrpage.cfg used^^J%
          228  *************************************}}

229 {}

2.8 End

230 ⟨/scrpage⟩