[texhax] Insert chapter and section heading into document header
Donald Arseneau
asnd at triumf.ca
Tue Dec 18 11:46:41 CET 2012
Jerry <jerry at seibercom.net> writes:
> I am still very new to Latex. I am in the process of creating a
> document that requires that the "Chapter" + "Section" + "subsection" if
> applicable be included in the document header. This is a large one
> sided report.
[... lots of un-beginnerly complicated stuff ...]
> %Format section numbering
> \def\thesection{\arabic{section}.}
> \def\thesubsection{\arabic{section}.\Alph{subsection}}
> \def\thesubsubsection{\arabic{section}.\Alph{subsection}.\Roman{subsubsection}}
>
> %I am attempting to use this to get the headers correct/=
> \fancyhead{r}{\chaptertitlename\ \thechapter\ \thesection \thesubsection}
First, I don't think you mean for the headings to look like
"The Chapter Title I 2.2.5"... you have repeated the section
number ("2").
I don't belive you want the chapter number after the chapter
title. That was probably sloppy typing/asking though, because
your report of "Article II 1.1.C" below suggests you really used:
\fancyhead{r}{\chaptername\ \thechapter\ \thesection \thesubsection}
> The problem is that it does not stay in sync with the document.
Now the meat of your problem: You have not defined the things that
are supposed to control the headers! They are \chaptermark, \sectionmark,
and \subsectionmark.
% Note that the section number is included in \thesubsection
\renewcommand\chaptermark[1]{\markright{\chaptername\ \thechapter}}
\renewcommand\sectionmark[1]{\markright{\chaptername\ \thechapter\ \thesection}}
\renewcommand\subsectionmark[1]{\markright{\chaptername\ \thechapter\ \thesubsection}}
And your heading should specify:
\fancyhead{r}{\rightmark}
If you want to include the actual title in any of the header marks, use "#1" in the
definition of the relevant mark command.
If you really are a beginner diving into internal macros and document-class
creation, then ask when you get confused about what to define, before getting
pissed off.
--
Donald Arseneau asnd at triumf.ca
More information about the texhax
mailing list