-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunnumbered.tex
122 lines (105 loc) · 2.99 KB
/
unnumbered.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
\documentclass{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[L]{\leftmark}
\fancyhead[R]{\rightmark}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\usepackage{boxedminipage}
% Redefine the \chapter command:
% \chapter[header]{title}
% \chapter*{title}
% For the \chapter* version, we insert a \markboth command.
% For the non-* version we just pass the arguments to the
% original \chapter command.
\newcommand\originalchapter{}% check that we can define this name
\let\originalchapter\chapter
\RenewDocumentCommand \chapter {som}{%
\IfBooleanTF{#1}
{% \chapter*
\originalchapter*{#3}%
\markboth{#3}{}%
% we can also put it in the Table of Contents
\addcontentsline{toc}{chapter}{#3}
}%
{% normal \chapter
\IfNoValueTF{#2}
{\originalchapter{#3}}
{\originalchapter[#2]{#3}}%
}%
}
\newcommand\originalsection{}% check that we can define this name
\let\originalsection\section
\RenewDocumentCommand \section {som}{%
\IfBooleanTF{#1}
{% \section*
\originalsection*{#3}%
\markright{#3}%
% we can also put it in the Table of Contents
\addcontentsline{toc}{section}{#3}
}%
{% normal \section
\IfNoValueTF{#2}
{\originalsection{#3}}
{\originalsection[#2]{#3}}%
}%
}
\begin{document}
\tableofcontents
\chapter*{Intro}
\noindent
\begin{boxedminipage}{\textwidth}
In this example we show how to get (numbered or unnumbered) chapter titles and unnumbered section titles in the page headers.
We redefine the \verb|\chapter| command. For the \texttt{*} (unnumbered)
version, we add a \verb|\markboth| command and add it to the Table of
Contents. For the non-* (numbered) version we just pass the arguments to
the original \verb|\chapter| command.
%\end{boxedminipage}
%\noindent
%\begin{boxedminipage}{\textwidth}
{\small\begin{verbatim}
\newcommand\originalchapter{}% check that we can define this name
\let\originalchapter\chapter
\RenewDocumentCommand \chapter {som}{%
\IfBooleanTF{#1}
{% \chapter*
\originalchapter*{#3}%
\markboth{#3}{}%
% we can also put it in the Table of Contents
\addcontentsline{toc}{chapter}{#3}
}%
{% normal \chapter
\IfNoValueTF{#2}
{\originalchapter{#3}}
{\originalchapter[#2]{#3}}%
}%
}
\end{verbatim}}
\end{boxedminipage}
\noindent
\begin{boxedminipage}{\textwidth}
{\small\begin{verbatim}
\newcommand\originalsection{}% check that we can define this name
\let\originalsection\section
\RenewDocumentCommand \section {som}{%
\IfBooleanTF{#1}
{% \section*
\originalsection*{#3}%
\markright{#3}%
% we can also put it in the Table of Contents
\addcontentsline{toc}{section}{#3}
}%
{% normal \section
\IfNoValueTF{#2}
{\originalsection{#3}}
{\originalsection[#2]{#3}}%
}%
}
\end{verbatim}}
\end{boxedminipage}
\section*{First (unnumbered) section}
\lipsum
\chapter{Body}
\section{Second (numbered) section}
\lipsum
\end{document}