[texhax] Insert chapter and section heading into document header

Jerry jerry at seibercom.net
Sat Dec 15 19:30:04 CET 2012


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.

I have used the "fancyhdr" package to create the footers I required,
but I just cannot get the headers correct.

I used the following to control the vertical spacing or the Chapter
headings.

% Change chapter vertical spacing
\makeatletter
\def\ttl at mkchap@i#1#2#3#4#5#6#7{%
    \ttl at assign\@tempskipa#3\relax\beforetitleunit
    \vspace{\@tempskipa}%<<<<<< REMOVE THE * AFTER \vspace
    \global\@afterindenttrue
    \ifcase#5 \global\@afterindentfalse\fi
    \ttl at assign\@tempskipb#4\relax\aftertitleunit
    \ttl at topmode{\@tempskipb}{%
        \ttl at select{#6}{#1}{#2}{#7}}%
    \ttl at finmarks  % Outside the box!
    \@ifundefined{ttlp@#6}{}{\ttlp at write{#6}}}
\makeatother

I then modified the numbering for my needs.

%Format section numbering
\def\thesection{\arabic{section}.}
\def\thesubsection{\arabic{section}.\Alph{subsection}}
\def\thesubsubsection{\arabic{section}.\Alph{subsection}.\Roman{subsubsection}}

I changed chapter" to "article" which was required since it is a legal
document.

% change chapter to article and center it
\renewcommand{\chaptername}{Article}
\renewcommand{\thechapter}{\Roman{chapter}}
\titleformat{\chapter}[display]{\LARGE\bfseries\centering}{\chaptertitlename\ \thechapter}{-0.125in}{\Large}

I then made sure "fancy" was the default style

% Swap plain for fancy when using "chapter" since chapter set the document style to plain
\makeatletter
\let\ps at plain\ps at fancy % :\Let plain be exactly the same as fancy
\makeatother

\begin{document}

% Create Table of Contents
\clearpage
\thispagestyle{fancy}
\pagenumbering{Roman}
\fancyfoot[r]{{\footnotesize \textbf{Contents:\ \thepage}}}
\fancyfoot[l]{{\footnotesize \textbf{\date{01-08-2013}}}}
\tableofcontents
\clearpage
\setcounter{section}{0}
\setcounter{page}{1}
\thispagestyle{fancy}
\fancyfoot{}
\fancyhead{}
\pagenumbering{arabic}
\fancyfoot[r]{{\footnotesize \textbf{Page \thepage\ of \pageref{LastPage}}}}
\fancyfoot[l]{{\footnotesize \textbf{\date{01-08-2013}}}}

%I am attempting to use this to get the headers correct/=
\fancyhead{r}{\chaptertitlename\ \thechapter\ \thesection \thesubsection}

The problem is that it does not stay in sync with the document. In fact
the first page has:

"Article II 1.1.C" when it should be "Article I 1"

I would really appreciate any assistance that someone might be able to
afford me.

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________



More information about the texhax mailing list