Creating Headers and Footers

Diese Seite existiert momentan nur auf Englisch.

 

Here is a style that allows you to customize your page headers and footers in an easy way.

To use this pagestyle, you must include the fancyhdr - package, and issue the \pagestyle{fancy} command. The header and footer fields can be defined by commands:

\lhead{ ... }                   - header left
   .
   .
   .
\rfoot{ ... }                   - footer right
\setlength{\headrulewidth}{...} - width of the headrule
\setlength{\footrulewidth}{...} - width of the footrule
\setlength{\headwidth}{...}     - width of the head and foot


  1. A simple example result

    \documentclass[12pt]{article}%
    \usepackage{fancyhdr}
    \setlength{\textheight}{10cm}
    \setlength{\topmargin}{3cm}
    \lhead{header-left}%
    \chead{header-centre}%
    \rhead{header-right}%
    \lfoot{foot-left}%
    \cfoot{foot-centre}%
    \rfoot{foot-right}%
    \renewcommand{\headrulewidth}{0.4pt}%        default 0.4pt
    \renewcommand{\footrulewidth}{0.4pt}%        default 0.0pt
    \pagestyle{fancy}%
    \begin{document}
    \begin{itemize}
    \item That is the test for the {\it fancyhdr} - stylefile.
    \end{itemize}
    \end{document}



  2. An example of two-sided printing result

    \documentclass[12pt]{book}%
    \usepackage{verbatim,fancyhdr}
    \fancyhf{}%                                  clear all fields
    \fancyhead[RO,LE]{\bfseries The using of fancyhdr.sty}%
    \fancyhead[C]{\thepage}%
    \fancyfoot[LE,RO]{\thepage}%
    \fancyfoot[LO,CE]{From: K. Schiebel}%
    \fancyfoot[CO,RE]{To: \LaTeX{}-User}
    \renewcommand{\headrulewidth}{0.4pt}%        default 0.4pt
    \renewcommand{\footrulewidth}{0.4pt}%        default 0.0pt
    \pagestyle{fancy}%
    \begin{document}
    That is the test for the {\it fancyhdr} - stylefile.\\[1cm]
    \begin{verbatim}
    \fancyhf{}%                                  clear all fields
    \fancyhead[RO,LE]{\bfseries The using of fancyhdr.sty}%
    \fancyhead[C]{\thepage}%
    \fancyfoot[LE,RO]{\thepage}%
    \fancyfoot[LO,CE]{From: K. Schiebel}%
    \fancyfoot[CO,RE]{To: \LaTeX{}-User}%
    \renewcommand{\headrulewidth}{0.4pt}%        default 0.4pt
    \renewcommand{\footrulewidth}{0.4pt}%        default 0.0pt
    \pagestyle{fancy}
    \end{verbatim}
    \vspace{1cm}%
    \begin{tabular}{p{3cm}p{10cm}}
    E & even page\\
    O & odd page\\
    L & left field\\
    R & right field\\
    C & center field\\
    H & Header\\
    F & Footer
    \end{tabular}
    \newpage
    This is an example for a two-sided document and the even and the odd pages have different layouts.
    \end{document}

 

Documentation

Haben Sie noch weiterführende Fragen, so senden Sie bitte eine Email an latex-service.


Loading...