0

I am a new Latex user, I would be grateful if you could help me to clear the header in the second page in my list of contents, I use \thispagestyle{plain} but unfortunately it isn't work to clear the header, my code is:

\documentclass[12pt]{report}
\usepackage{fancyhdr} 
\pagestyle{fancy}
\fancyhead{} 
\fancyfoot{}
\fancyhead[L]{Chapter \thechapter}
\fancyhead[R]{\leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} 
\fancyfoot[C]{\thepage}
\begin{document}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\thispagestyle{plain}
\newpage

\addcontentsline{toc}{chapter}{\listtablename}
\listoftables\thispagestyle{plain}
\newpage

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\thispagestyle{plain}
\newpage

\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\end{document}

enter image description here

1

Maybe this could help:

\documentclass[12pt]{report}
\usepackage{fancyhdr} 
\pagestyle{fancy}
\fancyhead{} 
\fancyfoot{}
\fancyhead[L]{Chapter \thechapter}
\fancyhead[R]{\leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} 
\fancyfoot[C]{\thepage}
\pagestyle{plain}
\begin{document}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents

\newpage

\addcontentsline{toc}{chapter}{\listtablename}

\newpage

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\newpage

\pagestyle{fancy}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\end{document}

\thispagestyle should set the style for the current page. As can you see from the example I set a \pagestyle{plain} at the beginning of the file and then I changed it after the toc elements. This should fix your issue.

  • thanks but there is a problem when I use \pagestyle{headings} before the chapters, my format of heading style is change. – Jamal Wafi Aug 4 '18 at 23:39
  • Oh sorry, I didn't notice it. Use \pagestyle{fancy} instead of \pagestyle{headings} – Source Aug 5 '18 at 4:28
  • working 100%, you are the best – Jamal Wafi Aug 5 '18 at 21:09
0

Just use this:

\documentclass[12pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{Chapter \thechapter}
\fancyhead[R]{\leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyfoot[C]{\thepage}
\usepackage{lipsum}

\begin{document}

\addcontentsline{toc}{chapter}{Contents}
\pagestyle{plain}
\tableofcontents
\newpage

\addcontentsline{toc}{chapter}{\listtablename}
\listoftables
\newpage

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\clearpage

\pagestyle{fancy}

\chapter{test}
\section{test}
\lipsum
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}
\chapter{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\subsection{test}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.