0

I have a question regarding the fancy header in LaTeX. The header shows up inconsistently with the following code. For example, it doesn't show the section name for the Abstract and it isn't showing at all on the first page of table of contents.

My code:

%from settings
\pagestyle{fancy}
\fancyhf{}
\rhead{\thepage}
\lhead{\nouppercase\leftmark}

%code Abstract
\pagenumbering{roman}
\thispagestyle{fancy}
\section*{Abstract}
\lipsum[1] 
\phantomsection
\addcontentsline{toc}{section}{Abstract}

%code Table of Content
\newpage
\phantomsection
\renewcommand{\contentsname}{Table of Contents}
\addcontentsline{toc}{section}{Table of Contents}
\tableofcontents\thispagestyle{fancy}

1 Answer 1

2

\section* doesn't set up the marks so \leftmark will not have the proper value. Try:

\section*{Abstract}
\markboth{Abstract}{}

See section 15 (The scoop on LATEX’s marks) in the fancyhdr documentation.

\tableofcontents\thispagestyle{fancy} causes the pagestyle to apply only to the last page of the table of contents.

Probably better is

\newpage
\pagestyle{fancy}
\thispagestyle{fancy}
\tableofcontents

Without a complete example document it is difficult to say, however.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .