TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Header/Footer
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


Author-/Titlename in header |  Examples  |  fancyheader |  letter class |  plain pagestyle for fancyhdr |  short headers  |  Table in the header/footer | 


Links:
  • Creating Headers and Footers Using LaTeX
  • Page Layout in LaTeX

  • Author-/Titlename in header
    Write in latex preamble:

    \let\oldAuthor\author
    \renewcommand{\author}[1]{\newcommand{\myAuthor}{#1}\oldAuthor{#1}} 
    \let\oldTitle\title
    \renewcommand{\title}[1]{\newcommand{\myTitle}{#1}\oldTitle{#1}} 
    %
    % for example title on the left and author on the right (with package fanyhdr)
    %
    \lhead{\myTitle}
    \rhead{\myAuthor}


    plain style for fancyhdr
    For chapters latex always uses the \thispagestyle{plain} command to switch from the actual headerstyle to plain. This can be modified by fancyhdr. For example write in latex preamble:

    \fancypagestyle{plain}{%
      \fancyhf{}
      \fancyfoot[C]{\bfseries \thepage}
      \renewcommand\headrulewidth{0pt}
      \renewcommand\footrulewidth{0pt}
    }
    This gives a bold centered pagenumber.


    Short Headers
    just under your chapter write in tex(red)

    \chaptermark{My short Title} 
    or for a section
    \sectionmark{myTitle}


    Footer and header with fyncyhdr
    Package fancyhdr gives the possibility to define own header and/or footer.
    First some definitions:
    even (left) pages:

    LE CE RE
    Text (even page)
    LE CE RE
    odd (right) pages:
    LO CO RO
    Text (odd page)
    LO CO RO
    the contents of header and/or footer is set by:
    \fancyhead[LE,...]{ the headertext } \fancyfoot[LE,...]{ the footertext }
    \fancyhead[CE,...]{ the headertext } \fancyfoot[CE,...]{ the footertext }
    \fancyhead[RE,...]{ the headertext } \fancyfoot[RE,...]{ the footertext }
    remember that there is a difference between the first pages of chapters, which are in plain-style and the other ones in fancy style:
    \fancyplain{plain_value}{normal_value}
    You can redefine the plain style in another way.

    A header- and a footline are the defaults. No lines are given by the width 0pt.
    Example:

    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0pt}
    \renewcommand{\plainheadrulewidth}{0pt}
    \renewcommand{\plainfootrulewidth}{0pt}
    Example for special header and footer (\chaptermark is rewritten for twoside-option, where on the left page the chapter and on the right page the section are part of the header:
    \renewcommand{\chaptermark}[1]{% twoside and 
      \markboth{%
        \ifnum \c@secnumdepth >\m@ne
        \hfill\thechapter\quad \if @mainmatter
            \@chapapp\ \thechapter\quad
          \fi
        \fi
         #1%
      }{%
        \ifnum \c@secnumdepth >\m@ne
          \if @mainmatter
            \@chapapp\ \thechapter\quad
          \fi
        \fi
        #1%
      }%
    }%
    \renewcommand\sectionmark[1]{\markright{\thesection\ #1}}
    \renewcommand\headrulewidth{0pt}
    \renewcommand\footrulewidth{0pt}
    % positioning
    \usepackage{color}
    \definecolor{myColor}{rgb}{0.9,0.9,0.9}
    \fancyhead{}% delte the defaults
    \fancyhead[RE,LO]{\bf\large\thepage} % right-even and left-odd
    \fancyhead[LE]{\colorbox{myColor}{\parbox{0.9\columnwidth}{\leftmark}}} % even pages!
    \fancyhead[RO]{\colorbox{myColor}{\parbox{0.9\columnwidth}{\rightmark}}} % odd pages!
    \fancyfoot{} % clear

    local time: Fri Apr 26 17:37:30 CEST 2024 ; file is: 1766.03064814815 days old
    contact webmaster _at_ TeXnik.de