%
% \iffalse
%
% scrpage.dtx Copyright (C) 1994-1996 Markus Kohm
%
% This file is part of the LaTeX2e KOMA-Script-Bundle
%
% It should be distributed UNCHANGED and together with all other
% files in the KOMA-Script-Bundle. The file readme.txt contains a list
% of all these files.
%
% A modified version of this file may be distributed, but it should
% be distributed with a DIFFERENT name. Changed files must be
% distributed TOGETHER WITH A COMPLETE AND UNCHANGED distribution
% of these files.
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%<*dtx>
            \ProvidesFile{scrpage.dtx}
%</dtx>
%<scrpage>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%<driver>   \ProvidesFile{scrpage.drv}
%<scrpage>\ProvidesPackage{scrpage}
                [1995/07/08 v1.2 LaTeX2e KOMA
%<scrpage>                 package]
%<*driver>
                 driver]
\documentclass{ltxdoc}
\usepackage{scrpage}
\usepackage[a4paper]{typearea}
\typearea{11}
\pagestyle{headings}
\begin{document}
 \DocInput{scrpage.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{521}
% \GetFileInfo{scrpage.dtx}
% \title{The \textsf{KOMA}-pagestyle-package\thanks{This file has
%        version number \fileversion, last revised \filedate.}}
% \author{Markus Kohm}
% \date{\filedate}
% \maketitle
%
% \def\oarg#1{{\ttfamily[}{\em#1\/}{\ttfamily]}}
% \def\arg#1{{\ttfamily\char`\{}{\em#1\/}{\ttfamily\char`\}}}
% \def\star{{\ttfamily*}}
% \makeatletter
% \def\Describe@Macro#1{\endgroup
%              \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
% \def\Describe@Env#1{\endgroup
%              \setbox0=\lastbox\llap{\PrintDescribeEnv{#1}}}%
% \makeatother
% \marginparsep0pt
% \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%
%                  \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}
%
% \begin{abstract}
% This is \texttt{scrpage.sty}. This package is part of the
% \textsf{KOMA}-script-bundle. It defines a new user-interface for
% pagestyle-definition. It's something like \texttt{fancyheadings}
% but not the same. You may use \texttt{scrpage} or \texttt{fancyheadings}.
% You may use \texttt{scrpage} with standard classes, too.
% \end{abstract}
%
% \tableofcontents
%
% \section{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.
%
%
% \subsection{Interface for all users}
%
% \DescribeMacro
% \headfont\\
% This font is used to write pageheads and -foots. You may change it using
% |\renewcommand|, e.g. |\renewcommand\headfont{\normalfont\slshape}|.
%
% \DescribeMacro
% \headmark\\
% Using \texttt{twoside}-option this is |\leftmark| at left/even pages and
% |\rightmark| at right/odd pages. Using \texttt{oneside}-option there are
% only right pages, so it is |\rightmark|.
%
% \DescribeMacro
% \pnumfont\\
% This font is used to write pagenumbers at |\pagemark|. You may change it
% using |\renewcommand| (see |\headfont|).
%
% \DescribeMacro
% \pagemark\\
% This is the number of the actual page written with |\pnumfont|.
%
% \DescribeMacro
% \deftripstyle\arg{name}\oarg{olw}\oarg{ilw}%
%              \arg{headleft}\arg{headmiddle}\arg{headright}%
%              \arg{footleft}\arg{footmiddle}\arg{footright}\\
% Defines a new pagestyle. You can activate this pagestyle using
% |\pagestyle| or |\thispagestyle|. Without optional argument this defines a
% page like this:
% \begin{center}\unitlength1mm\begin{picture}(120,82)
% \put(0,0){\dashbox{2}(58,82){~}}
% \put(1,78){\makebox(0,0)[l]{\emph{headright}}}
% \put(29,78){\makebox(0,0){\emph{headmiddle}}}
% \put(57,78){\makebox(0,0)[r]{\emph{headleft}}}
% \put(29,41){\makebox(0,0){left page}}
% \put(1,3){\makebox(0,0)[l]{\emph{footright}}}
% \put(29,3){\makebox(0,0){\emph{footmiddle}}}
% \put(57,3){\makebox(0,0)[r]{\emph{footleft}}}
% \put(60,0){\dashbox{2}(58,82){~}}
% \put(61,78){\makebox(0,0)[l]{\emph{headleft}}}
% \put(89,78){\makebox(0,0){\emph{headmiddle}}}
% \put(117,78){\makebox(0,0)[r]{\emph{headright}}}
% \put(89,41){\makebox(0,0){right page}}
% \put(61,3){\makebox(0,0)[l]{\emph{footleft}}}
% \put(89,3){\makebox(0,0){\emph{footmiddle}}}
% \put(117,3){\makebox(0,0)[r]{\emph{footright}}}
% \end{picture}\end{center}
% Using one optional argument \oarg{ilw} (means \emph{i}nner \emph{l}ine
% \emph{w}idth) you get a separationline between head and text and between
% text and foot like this (\emph{ilw}=0.5pt):
% \begin{center}\unitlength1mm\begin{picture}(120,82)
% \put(0,0){\dashbox{2}(58,82){~}}
% \put(1,78){\makebox(0,0)[l]{\emph{headright}}}
% \put(29,78){\makebox(0,0){\emph{headmiddle}}}
% \put(57,78){\makebox(0,0)[r]{\emph{headleft}}}
% \put(1,76){\rule{56\unitlength}{0.5pt}}
% \put(29,41){\makebox(0,0){left page}}
% \put(1,5){\rule{56\unitlength}{0.5pt}}
% \put(1,3){\makebox(0,0)[l]{\emph{footright}}}
% \put(29,3){\makebox(0,0){\emph{footmiddle}}}
% \put(57,3){\makebox(0,0)[r]{\emph{footleft}}}
% \put(60,0){\dashbox{2}(58,82){~}}
% \put(61,78){\makebox(0,0)[l]{\emph{headleft}}}
% \put(89,78){\makebox(0,0){\emph{headmiddle}}}
% \put(117,78){\makebox(0,0)[r]{\emph{headright}}}
% \put(61,76){\rule{56\unitlength}{0.5pt}}
% \put(89,41){\makebox(0,0){right page}}
% \put(61,5){\rule{56\unitlength}{0.5pt}}
% \put(61,3){\makebox(0,0)[l]{\emph{footleft}}}
% \put(89,3){\makebox(0,0){\emph{footmiddle}}}
% \put(117,3){\makebox(0,0)[r]{\emph{footright}}}
% \end{picture}\end{center}
% Using both optional arguments \oarg{olw} (means \emph{o}uter \emph{l}ine
% \emph{w}idth) and \oarg{ilw} you get a separationline between head and
% text and between text and foot and a line above head and below foot like
% this (\emph{olw}=2pt, \emph{ilw}=0.5pt):
% \begin{center}\unitlength1mm\begin{picture}(120,82)
% \put(0,0){\dashbox{2}(58,82){~}}
% \put(1,80){\rule{56\unitlength}{2pt}}
% \put(1,78){\makebox(0,0)[l]{\emph{headright}}}
% \put(29,78){\makebox(0,0){\emph{headmiddle}}}
% \put(57,78){\makebox(0,0)[r]{\emph{headleft}}}
% \put(1,76){\rule{56\unitlength}{0.5pt}}
% \put(29,41){\makebox(0,0){left page}}
% \put(1,5){\rule{56\unitlength}{0.5pt}}
% \put(1,3){\makebox(0,0)[l]{\emph{footright}}}
% \put(29,3){\makebox(0,0){\emph{footmiddle}}}
% \put(57,3){\makebox(0,0)[r]{\emph{footleft}}}
% \put(1,1){\rule{56\unitlength}{2pt}}
% \put(60,0){\dashbox{2}(58,82){~}}
% \put(61,80){\rule{56\unitlength}{2pt}}
% \put(61,78){\makebox(0,0)[l]{\emph{headleft}}}
% \put(89,78){\makebox(0,0){\emph{headmiddle}}}
% \put(117,78){\makebox(0,0)[r]{\emph{headright}}}
% \put(61,76){\rule{56\unitlength}{0.5pt}}
% \put(89,41){\makebox(0,0){right page}}
% \put(61,5){\rule{56\unitlength}{0.5pt}}
% \put(61,3){\makebox(0,0)[l]{\emph{footleft}}}
% \put(89,3){\makebox(0,0){\emph{footmiddle}}}
% \put(117,3){\makebox(0,0)[r]{\emph{footright}}}
% \put(61,1){\rule{56\unitlength}{2pt}}
% \end{picture}\end{center}
%
% 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 \texttt{headings} to. If you want to
% change pagestyle \texttt{myheadings}, you should use the star-version of
% the command:\\
% \DescribeMacro
% \deftripstyle\star\arg{name}\oarg{olw}\oarg{ilw}%
%               \arg{headleft}\arg{headmiddle}\arg{headright}%
%               \arg{footleft}\arg{footmiddle}\arg{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 |\deftripstyle| are almost the same.
%
%
% \subsection{Interface for experts}
%
% \DescribeMacro
% \defpagestyle\arg{name}\arg{head-definition}\arg{foot-definition}\\
% defines a new pagestyle \emph{name}. \emph{head-definition} defines the
% head at the new pagestyle. It contains five part:\\
% (\emph{toplinelength},\emph{toplinewidth})%
% \arg{evenpagehead}\arg{oddpagehead}\arg{onesidepagehead}%
% (\emph{headseplinelength},\emph{headseplinewidth})\\
% These five parts have to be \textbf{one} argument! So you should put them
% together in group-braces (``|{|'' and ``|}|'').
%
% \emph{foot-definition} analogous defines the foot at the new pagestyle.
%
% \DescribeMacro
% \newpagestyle\arg{name}\arg{head-definition}\arg{foot-definition}\\
% defines a real new pagestyle. If there's already a pagestyle named
% \emph{name}, you'll get an error. Otherwise it's the same like
% |\defpagestyle|.
%
% \DescribeMacro
% \renewpagestyle\arg{name}\arg{head-definition}\arg{foot-definition}\\
% redefines a old pagestyle. If there isn't a pagestyle named
% \emph{name}, you'll get an error. Otherwise it's the same like
% |\defpagestyle|.
%
% \DescribeMacro
% \providepagestyle\arg{name}\arg{head-definition}\arg{foot-definition}\\
% defines a new pagestyle, if it is realy new. If there is already a
% pagestyle named \emph{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.
%
%
% \subsection{Configuration file}
% There's a configuration file \texttt{scrpage.cfg}, included at the end
% of \texttt{scrpage.sty}, if it exists. There you can define your own
% default pagestyles using all the commands above.
%
%
% \subsection{Example}
% The pagestyles of this documentation was defined using:
% \begin{verbatim}
% \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%
%                  \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
% \end{verbatim}
%
%
% \StopEventually
%
% \section{Implementation}
%    \begin{macrocode}
%<*scrpage>
%    \end{macrocode}
% \changes{v1.1}{1995/06/27}{\cs{hbox to} changed into \cs{hb@xt@}.}
%
% \subsection{Options}
% \texttt{scrpage} knows some options. They are similar to the
% \textsf{KOMA}-script-classes. To work with and without
% the \textsf{KOMA}-script-classes their definitions are not quite simple.
%
%    \begin{macrocode}
\DeclareOption{headinclude}{\PassOptionsToPackage{headinclude}{typearea}}
\DeclareOption{headexclude}{\PassOptionsToPackage{headexclude}{typearea}}
\DeclareOption{footinclude}{\PassOptionsToPackage{footinclude}{typearea}}
\DeclareOption{footexclude}{\PassOptionsToPackage{footexclude}{typearea}}
%    \end{macrocode}
% We do so, because we want so set |headinclude|, |footinclude| by default!
%    \begin{macrocode}
\ExecuteOptions{headinclude,footinclude}
%    \end{macrocode}
% But you may set other Options:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
%
%
% \subsection{Some Initialisation}
%
% For easier handling of the differences between article-, report- and
% book-classes we define some more switches.
%
%  \begin{macro}{\if@chapter}
% First distinguish between article and others.
%    \begin{macrocode}
\newif\if@chapter
\ifx\chapter\undefined \@chapterfalse\else\@chaptertrue\fi
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\if@mainmatter}
% \changes{v1.2}{1995/07/08}{Definition ge"andert}
% Next distinguish between matter- and nomatter-classes.
%    \begin{macrocode}
\def\@tempa{\newif\if@mainmatter\@mainmattertrue}
\ifx\mainmatter\undefined\else\let\@tempa\relax\fi
\@tempa
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Predefinitions}
% There are some commands, you can use at pagestyle-definition.
%
%  \begin{macro}{\headmark}
% This macro is |\rightmark| or |\leftmark|. But outside pagestyle-definition
% it's nothing.
%    \begin{macrocode}
\let\headmark\relax
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\pagemark}
% This macro is the number of the page at the pagenumberfont:
%    \begin{macrocode}
\DeclareRobustCommand\pagemark{{\pnumfont\thepage}}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{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.
%
%  \begin{macro}{\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.
%    \begin{macrocode}
\def\defpagestyle{%
%    \end{macrocode}
% We have to decide, wether it is a my-version or not:
%    \begin{macrocode}
  \@ifstar
  {\@defpagestyle[-]}%
  {\@defpagestyle[+]}}
%    \end{macrocode}
% Now the we can define the head and the foot. First at twoside-mode:
% \changes{v1.0b}{1995/05/25}{Dot deleted after number at
%                             chapter- and sectionmark}
% \changes{v1.0b}{1995/05/25}{Use CJK at {\cmd\chaptermark},
%                             {\cmd\sectionmark} and {\cmd\subsectionmark}.}
%    \begin{macrocode}
\if@twoside
  \def\@defpagestyle[#1]#2#3#4{%
    \expandafter\def\csname ps@#2\endcsname{%
      \def\@tempa{+}%
      \def\@tempb{#1}%
      \ifx\@tempa\@tempb
        \let\@mkboth\markboth
        \if@chapter
          \def\chaptermark####1{%
            \markboth {\ifnum \c@secnumdepth >\m@ne%
              \if@mainmatter\chaptermarkformat\fi\fi ####1}{%
              \ifnum \c@secnumdepth >\m@ne%
              \if@mainmatter\chaptermarkformat\fi\fi ####1}}%
          \def\sectionmark####1{%
            \markright {\ifnum \c@secnumdepth >\z@%
              \sectionmarkformat\fi ####1}}
        \else
          \def\sectionmark####1{%
            \markboth {\ifnum \c@secnumdepth >\z@%
              \sectionmarkformat\fi ####1}{%
              \ifnum \c@secnumdepth >\z@%
              \sectionmarkformat\fi ####1}}
          \def\subsectionmark####1{%
            \markright {\ifnum \c@secnumdepth >\@ne%
              \subsectionmarkformat\fi ####1}}
        \fi
      \else
        \let\@mkboth\@gobbletwo
        \if@chapter
          \def\chaptermark####1{}
        \else
          \def\subsectionmark####1{}
        \fi
        \def\sectionmark####1{}
      \fi
      \def@twosidehead#3
      \def@twosidefoot#4
    }
  }
\else
%    \end{macrocode}
% Then the oneside-mode:
%    \begin{macrocode}
  \def\@defpagestyle[#1]#2#3#4{%
    \expandafter\def\csname ps@#2\endcsname{%
      \def\@tempa{+}%
      \def\@tempb{#1}%
      \ifx\@tempa\@tempb
        \let\@mkboth\markboth
        \if@chapter
          \def\chaptermark####1{%
            \markright {\ifnum \c@secnumdepth >\m@ne%
              \if@mainmatter\chaptermarkformat\fi\fi ####1}}%
          \def\sectionmark####1{}
        \else
          \def\sectionmark####1{%
            \markright{\ifnum \c@secnumdepth >\z@%
              \sectionmarkformat\fi ####1}}
          \def\subsectionmark####1{}
        \fi
      \else
        \let\@mkboth\@gobbletwo
        \if@chapter
          \def\chaptermark####1{}
        \else
          \def\subsectionmark####1{}
        \fi
        \def\sectionmark####1{}
      \fi
      \def@onesidehead#3
      \def@onesidefoot#4
    }
  }
\fi
%    \end{macrocode}
% This was real simple, but we already have to do the real definition of the
% heads and foots. First the twosided head:
%  \begin{macro}{\def@twosidehead}
%    \begin{macrocode}
\def\def@twosidehead(#1,#2)#3#4#5(#6,#7){
  \def\@evenhead{\let\headmark\leftmark%
    \vbox{\hsize=\textwidth
      \hf@rule{#1}{#2}\vskip#2
      \vskip\baselineskip\hb@xt@\textwidth{{\headfont\strut #3}}
      \hf@rule{#6}{#7}
  }}
  \def\@oddhead{\let\headmark\rightmark%
    \vbox{\hsize=\textwidth
      \hf@rule{#1}{#2}\vskip#2
      \vskip\baselineskip\hb@xt@\textwidth{{\headfont\strut #4}}
      \hf@rule{#6}{#7}
  }}
}
%    \end{macrocode}
%  \end{macro}
% Next the onesided head:
%  \begin{macro}{\def@onesidehead}
%    \begin{macrocode}
\def\def@onesidehead(#1,#2)#3#4#5(#6,#7){
  \def\@evenhead{}
  \def\@oddhead{\let\headmark\rightmark%
    \vbox{\hsize=\textwidth
      \hf@rule{#1}{#2}\vskip#2
      \vskip\baselineskip\hb@xt@\textwidth{{\headfont\strut #5}}
      \hf@rule{#6}{#7}
  }}
}
%    \end{macrocode}
%  \end{macro}
% And last twosided and onesided foot:
%  \begin{macro}{\def@twosidefoot}
%    \begin{macrocode}
\def\def@twosidefoot(#1,#2)#3#4#5(#6,#7){
  \def\@evenfoot{\let\headmark\leftmark%
    \vbox{\hsize=\textwidth
      \topfoot@rule{#1}{#2}\hb@xt@\textwidth{{\headfont\strut #3}}
      \botfoot@rule{#6}{#7}}}
  \def\@oddfoot{\let\headmark\rightmark%
    \vbox{\hsize=\textwidth
      \topfoot@rule{#1}{#2}\hb@xt@\textwidth{{\headfont\strut #4}}
      \botfoot@rule{#6}{#7}}}
}
%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\def@onesidefoot}
%    \begin{macrocode}
\def\def@onesidefoot(#1,#2)#3#4#5(#6,#7){
  \def\@evenfoot{}
  \def\@oddfoot{\let\headmark\rightmark%
    \vbox{\hsize=\textwidth
      \topfoot@rule{#1}{#2}\hb@xt@\textwidth{{\headfont\strut #5}}
      \botfoot@rule{#6}{#7}}}
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% We now define the rules used at head and foot.
%  \begin{macro}{\topfoot@rule}
%    \begin{macrocode}
\newcommand\topfoot@rule[2]{%
  \@tempdima\baselineskip\advance\@tempdima by-.7\normalbaselineskip
  \advance\@tempdima by -#2
  \vskip\@tempdima\hf@rule{#1}{#2}\vskip-\@tempdima}
%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\botfoot@rule}
%    \begin{macrocode}
\newcommand\botfoot@rule[2]{%
  \@tempdima-\baselineskip\advance\@tempdima by .3\normalbaselineskip
  \advance\@tempdima by #2
  \vskip\@tempdima\hf@rule{#1}{#2}}
%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\hf@rule}
%    \begin{macrocode}
\newcommand\hf@rule[2]{%
  \@tempdimb#1
  \hb@xt@\textwidth{\hfill%
    \llap{\vrule\@depth#2\@height\z@\@width.5\@tempdimb}%
    \rlap{\vrule\@depth#2\@height\z@\@width.5\@tempdimb}%
    \hfill}}
%    \end{macrocode}
%  \end{macro}
%
% Using these definitions, we can define the testing macros.
%
%  \begin{macro}{\newpagestyle}
% First the simple star/starless-selection:
%    \begin{macrocode}
\def\newpagestyle{%
%    \end{macrocode}
% We have to decide, wether it is a my-version or not:
%    \begin{macrocode}
  \@ifstar
  {\@newpagestyle[-]}%
  {\@newpagestyle[+]}}
%    \end{macrocode}
%  \begin{macro}{\@newpagestyle}
% There we have to distinguish, wether the pagestyle is already defined or not.
%    \begin{macrocode}
\def\@newpagestyle[#1]#2#3#4{
  \expandafter\ifx\csname ps@#2\endcsname\relax
%    \end{macrocode}
% Then we can use the already defined |\@defpagestyle|.
%    \begin{macrocode}
    \@defpagestyle[#1]{#2}{#3}{#4}
  \else
    \PackageError{scrpage}{Your command was ignored}%
      {There is already a pagestyle named ``#1''.\MessageBreak%
       Use \protect\defpagestyle\space, \protect\renewpagestyle or
       \protect\provide\pagestyle.}
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\renewpagestyle}
% First the simple star/starless-selection:
%    \begin{macrocode}
\def\renewpagestyle{%
%    \end{macrocode}
% We have to decide, wether it is a my-version or not:
%    \begin{macrocode}
  \@ifstar
  {\@renewpagestyle[-]}%
  {\@renewpagestyle[+]}}
%    \end{macrocode}
%  \begin{macro}{\@renewpagestyle}
% There we have to distinguish, wether the pagestyle is already defined or not.
%    \begin{macrocode}
\def\@renewpagestyle[#1]#2#3#4{
  \expandafter\ifx\csname ps@#2\endcsname\relax
    \PackageError{scrpage}{Your command was ignored}%
      {There is no pagestyle named ``#1''.\MessageBreak%
       Use \protect\defpagestyle\space, \protect\newpagestyle or
       \protect\provide\pagestyle.}
  \else
%    \end{macrocode}
% Then we can use the already defined |\@defpagestyle|.
%    \begin{macrocode}
    \@defpagestyle[#1]{#2}{#3}{#4}
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\providepagestyle}
% First the simple star/starless-selection:
%    \begin{macrocode}
\def\providepagestyle{%
%    \end{macrocode}
% We have to decide, wether it is a my-version or not:
%    \begin{macrocode}
  \@ifstar
  {\@providepagestyle[-]}%
  {\@providepagestyle[+]}}
%    \end{macrocode}
%  \begin{macro}{\@providepagestyle}
% There we have to distinguish, wether the pagestyle is already defined or not.
%    \begin{macrocode}
\def\@providepagestyle[#1]#2#3#4{
  \expandafter\ifx\csname ps@#2\endcsname\relax
%    \end{macrocode}
% Then we can use the already defined |\@defpagestyle|.
%    \begin{macrocode}
    \@defpagestyle[#1]{#2}{#3}{#4}
  \else
    \PackageInfo{scrpage}{\protect\providepagestyle\protect{#1\protect}
                          ignored.}
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
% \subsection{User-Pagestyle-Definition-Interface}
% The pagestyle-definition-interface for users is much easier than the
% expert-version. Using the expert-macros, the definition is easy, too.
%
% First we define the selection of star- or starless-version:
%  \begin{macro}{\deftripstyle}
%    \begin{macrocode}
\def\deftripstyle{%
  \@ifstar
  {\@deftripstyle[-]}%
  {\@deftripstyle[+]}}
%    \end{macrocode}
%  \end{macro}
% Next we check, if there is an optional argument:
%  \begin{macro}{\@deftripstyle}
%    \begin{macrocode}
\def\@deftripstyle[#1]#2{%
  \@ifnextchar[
  {\@@deftripstyle[#1]{#2}}%
  {\@@deftripstyle[#1]{#2}[\z@]}}
%    \end{macrocode}
%  \end{macro}
% or perhaps two optional arguments:
%  \begin{macro}{\@@deftripstyle}
%    \begin{macrocode}
\def\@@deftripstyle[#1]#2[#3]{
%    \end{macrocode}
% Ok, now we have the problem, that there can be only 9 arguments. So we
% have to distinguish the star-versions by a macro:
%    \begin{macrocode}
  \def\@tempa{#1}
  \@ifnextchar[
  {\@@@deftripstyle#2[#3]}%
  {\@@@deftripstyle#2[\z@][#3]}}
%    \end{macrocode}
%  \end{macro}
% Now the main-definition:
%  \begin{macro}{\@@@deftripstyle}
%    \begin{macrocode}
\def\@@@deftripstyle#1[#2][#3]#4#5#6#7#8#9{%
  \def\@tempb{+}
  \ifx\@tempa\@tempb%
    \defpagestyle{#1}%
      {(\textwidth,#2)%
       {\rlap{#6}\hfill{#5}\hfill\llap{#4}}%
       {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
       {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
       (\textwidth,#3)}
      {(\textwidth,#3)%
       {\rlap{#9}\hfill{#8}\hfill\llap{#7}}%
       {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
       {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
       (\textwidth,#2)}
  \else
    \defpagestyle*{#1}%
      {(\textwidth,#2)%
       {\rlap{#6}\hfill{#5}\hfill\llap{#4}}%
       {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
       {\rlap{#4}\hfill{#5}\hfill\llap{#6}}%
       (\textwidth,#3)}
      {(\textwidth,#3)%
       {\rlap{#9}\hfill{#8}\hfill\llap{#7}}%
       {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
       {\rlap{#7}\hfill{#8}\hfill\llap{#9}}%
       (\textwidth,#2)}
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Fonts}
%  \begin{macro}{\pnumfont}
% We have to define a macro defining the font, used by |\pagemark|. Because
% of this macro may already be defined by a \textsf{KOMA}-script-class, we
% have to do this, using |\providecommand|
%    \begin{macrocode}
\providecommand\pnumfont{\normalfont}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\headfont}
% There is also a macro used by |\@evenhead|, |\@oddhead| and |\@evenfoot|,
% |\@oddfoot|:
%    \begin{macrocode}
\providecommand\headfont{\normalfont}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Extended multilanguage formats}
%  \begin{macro}{\chaptermarkformat}
% \changes{v1.1}{1995/06/27}{Space after chapternumber increased.}
%  \begin{macro}{\sectionmarkformat}
% \changes{v1.1}{1995/06/27}{Space after sectionnumber increased.}
%  \begin{macro}{\subsectionmarkformat}
% \changes{v1.1}{1995/06/27}{Space after subsectionnumber increased.}
% There are some macros to handle languages like Chinese, Japanese or Korean.
% These macros were defined first by Werner Lemberg at his CJK-bundle. See
% |scrclass.dtx| for further information.
%    \begin{macrocode}
\if@chapter
  \providecommand\chaptermarkformat    {\thechapter\quad}
  \providecommand\sectionmarkformat    {\thesection\quad}
\else
  \providecommand\sectionmarkformat    {\thesection\quad}
  \providecommand\subsectionmarkformat {\thesubsection\quad}
\fi
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%
% \subsection{Configurationfile}
% Last but not least we include the local configuration-file
% \texttt{scrpage.cfg}, if it exists.
%    \begin{macrocode}
\InputIfFileExists{scrpage.cfg}
           {\typeout{*************************************^^J%
                     * Local config file scrpage.cfg used^^J%
                     *************************************}}
           {}
%    \end{macrocode}
% \subsection{End}
%    \begin{macrocode}
%</scrpage>
%    \end{macrocode}
%
% \Finale
%
\endinput
%
% end of file `scrpage.dtx'