-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample34a.tex
57 lines (42 loc) · 1.56 KB
/
example34a.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
\documentclass[oneside]{book}
\usepackage{kantlipsum}
\usepackage{boxedminipage}
\usepackage[twoside]{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\nouppercase{\rightmark}} % Section title
\fancyhead[LO,RE]{\nouppercase{\leftmark}} % Chapter title
\fancyfoot[LE,RO]{\thepage}
\begin{document}
\thispagestyle{plain}
\tableofcontents
\bigskip
\noindent
\begin{boxedminipage}{\textwidth}
This is example 34a in the \texttt{fancyhdr} documentation.
This document has some very long chapter and section titles. These are too long to fit in the header, and therefore they overlap, which is undesirable.
This example shows one way to solve this.
It uses the optional argument of \verb|\chapter| and \verb|\section| to supply shorter titles. However, the short titles will also appear in the table of contents, as you can see above.
\begin{verbatim}
\chapter[This is a not so long chapter title]
{This is a very long chapter title to see if we can give
fancyhdr a shorter one that fits in the header}
\section[Short section title]
{This is a very long section title that will not fit in
the header}
\end{verbatim}
\end{boxedminipage}
\newpage
\pagestyle{fancy}
\chapter[This is a not so long chapter title]
{This is a very long chapter title to see if we can give
fancyhdr a shorter one that fits in the header}
\thispagestyle{fancy}
\kant[1-3]
\section{Normal section title}
\kant[4-5]
\section[Short section title]
{This is a very long section title that will not fit in
the header}
\kant[6-7]
\end{document}