-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample14.tex
54 lines (36 loc) · 1.07 KB
/
example14.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
\documentclass{article}
\usepackage{lipsum}
\usepackage{boxedminipage}
\usepackage{fancyhdr, extramarks}
\fancyhead[R]{\leftmark}
\pagestyle{fancy}
\begin{document}
\section{Introduction}
\begin{boxedminipage}{\textwidth}
This is example 14 in the fancyhdr documentation.\\
\textbf{Problem: The header is the LAST section title, not the first one.}\\
This demonstrates that \verb|\leftmark| uses the \textbf{last} mark on the page, which sometimes isn't nice. This can be solved by using the \texttt{extramarks} package and the command \verb|\firstleftmark|.
\begin{verbatim}
\usepackage{extramarks}
. . .
\fancyhead[R]{\firstleftmark}
\end{verbatim}
\end{boxedminipage}
\subsection{The Problem}
\label{sec:problem}
\lipsum[1]
\subsection{Evaluation}
\lipsum[2]
\section{Another section}
Some more text.
\newpage
\fancyhead[R]{\firstleftmark}
\section{Introduction}
{\bfseries Solution: Use \verb+\firstleftmark+\verb+: \fancyhead[R]{\firstleftmark}+}
\subsection{The Problem}
\lipsum[1]
\subsection{Evaluation}
\lipsum[2]
\section{Another section}
\lipsum[3-5]
\end{document}