GeneralProblems with \listoffigures\thispagestyle{fancy}

LaTeX specific issues not fitting into one of the other forums of this category.
peterd86
Posts: 5
Joined: Fri May 02, 2008 11:33 am

Problems with \listoffigures\thispagestyle{fancy}

Post by peterd86 »

Hello,

i want to create a list of my figures. i use \listoffigures\thispagestyle{fancy} because i have a custom head and tail pagestyle. when the list is only one page big then it works well.
when then number of pages become 2 then my special head will only shown on the second page and on the first page will be shown the normal page-style.
how can i do?
does sb know how to fix this problem?
thx.

Greetings,

Peter

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problems with \listoffigures\thispagestyle{fancy}

Post by Stefan Kottwitz »

Hi Peter,

welcome to the LaTeX Community board!
You can set the pagestyle inside the lof:

Code: Select all

\listoffigures
\addtocontents{lof}{\protect\thispagestyle{fancy}}
In general you could redefine the plain pagestyle to match the fancy layout, see fancyhdr Documentation (\fancypagestyle{plain}{}).

Stefan
LaTeX.org admin
peterd86
Posts: 5
Joined: Fri May 02, 2008 11:33 am

Re: Problems with \listoffigures\thispagestyle{fancy}

Post by peterd86 »

thanks for your help.
it works.
its reakky a nice community with many information here.
greetings,

peter
prdharamshi
Posts: 6
Joined: Sat Apr 14, 2012 7:53 pm

Problems with \listoffigures\thispagestyle{fancy}

Post by prdharamshi »

hello,

i have the same problem. but the code does not work in my case.
can someone hep me?

thanks
parthiv

Code: Select all

\newpage
\phantomsection\label{lof}
\listoffigures
\addtocontents{lof}{\protect\thispagestyle{fancy}}
\addcontentsline{toc}{chapter}{List of Figures}
\setlength{\cftfigindent}{0pt}  % remove indentation from figures in lof
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problems with \listoffigures\thispagestyle{fancy}

Post by Stefan Kottwitz »

Hi,

welcome to the board!
prdharamshi wrote:but the code does not work in my case.
Perhaps provide more information about your case. The best would be a Infominimal working example.

Stefan
LaTeX.org admin
prdharamshi
Posts: 6
Joined: Sat Apr 14, 2012 7:53 pm

Problems with \listoffigures\thispagestyle{fancy}

Post by prdharamshi »

Hi stefan,

I am having trouble of using fancyheader in multipage table of contents and list of figures. I have 2 pages of toc and lof. On the first page of both toc and lof, my fancy header does not work but on the second page it works. So I want fancy header on page 1 of toc and lof.

Then I followed the solution of "Fancyhdr problem with table of contents" and it worked out for toc. I tried following code and it worked.

Code: Select all

\addtocontents{toc}{\protect\thispagestyle{fancy}}


I copied the same for lof but it didn't work out.

Code: Select all

\addtocontents{lof}{\protect\thispagestyle{fancy}}
My code looks like. fancy header is a part of Macros.tex but for your information i have copied it before my main code.

Code: Select all


\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\nouppercase{\leftmark}}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}

\documentclass[12pt,a4paper]{report}

\input Macros.tex

\begin{document}
\pagestyle{fancy}

\input Acknowledgement.tex
\input Declaration.tex
\input Abstract.tex

\newpage
\tableofcontents
\addtocontents{toc}{\protect\thispagestyle{fancy}}

\input ch1.tex
\input ch2.tex
\input ch3.tex
\input ch4.tex

\newpage
\bibliographystyle{alpha}
\bibliography{MasterThesis}
\thispagestyle{fancy}
\addcontentsline{toc}{chapter}{Bibliography}

\newpage
\listoffigures
\addtocontents{lof}{\protect\thispagestyle{fancy}}
\setlength{\cftfigindent}{0pt}  % remove indentation from figures in lof
\addcontentsline{toc}{chapter}{List of Figures}

\newpage
\listoftables
\thispagestyle{fancy}
\setlength{\cfttabindent}{0pt}  % remove indentation from tables in lot
\addcontentsline{toc}{chapter}{List of Tables}

\end{document} 
Sorry I don't have any working example but I think this would be enough.

thnnks,
parthiv
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problems with \listoffigures\thispagestyle{fancy}

Post by Stefan Kottwitz »

Hi Parthiv,

place

Code: Select all

\addtocontents{lof}{\protect\thispagestyle{fancy}}
earlier, i.e. before your figures, so that it comes first in the .lof file.

Stefan
LaTeX.org admin
prdharamshi
Posts: 6
Joined: Sat Apr 14, 2012 7:53 pm

Re: Problems with \listoffigures\thispagestyle{fancy}

Post by prdharamshi »

Hi stefan,

i tried to place it before but it does not work. any other possible solution?

thanks,
parthiv
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Problems with \listoffigures\thispagestyle{fancy}

Post by Stefan Kottwitz »

How does your .lof file look?

Stefan
LaTeX.org admin
prdharamshi
Posts: 6
Joined: Sat Apr 14, 2012 7:53 pm

Re: Problems with \listoffigures\thispagestyle{fancy}

Post by prdharamshi »

hi stefan,

as you said "\thispagestyle {fancy}" comes at the very end. And surprisingly "\thispagestyle {fancy}" line is missing in .lot file but still it has correct page layout.

thanks,
parthiv
Post Reply