czwartek, 13 października 2011

Dictionary-style headers in LaTeX

It is pretty simple to define dictionary-style headers in LaTeX. Look at the example below:


\documentclass[twoside]{report}
\usepackage{multicol}

%%% \leftmark/\rightmark inserts appropriate \mark{...}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhead{}
\fancyhead[LE]{\normalfont \small\itshape \rightmark }
\fancyhead[RE]{\normalfont \small\itshape \leftmark }
\fancyhead[RO]{\normalfont \small\itshape \leftmark }
\fancyhead[LO]{\normalfont \small\itshape \rightmark }
\fancyfoot[CO,CE]{\thepage}

\title{Vocabulary layout -- example}

\newcommand{\Entry}[2]{\par \leavevmode
\ignorespaces\markboth{#1}{#1} #1 #2}

\begin{document}
\maketitle

\begin{multicols}{2}

\Entry{AA BB CC DD00001}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00001 zz.}
\Entry{AA BB CC DD00002}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00002 zz.}
\Entry{AA BB CC DD00003}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00003 zz.}

... ... ...

\Entry{AA BB CC DD00299}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00299 zz.}
\Entry{AA BB CC DD00300}{aa bb cc dd ee ff gg hh ii jj mm nn oo pp qq rr ss tt uu vx 00300 zz.}


\end{multicols}

\end{document}

Crucial commands are \markboth, \leftmark and \rightmark. See also Typesetting a Dictionary with LaTeX.

Brak komentarzy:

Prześlij komentarz