1

suppose I have a page with 3 short sections. And I want the footer to say "This page contains Section 1,2,3" How to achieve it with Fancyhdr? Right now it can only say "This page contains Section 3" in the footer. Thank you.

Ideally it is automatic, so if a page contains 2 sections, it will say "This page contains Section 1,2", and if a page contains only 1 section, it will say "This page contains Section 1" Thanks.

\documentclass{article}

\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{This page contains Section \arabic{\section{#1}}}}
\fancyhf{}
\rfoot{\fancyplain{}{\rightmark }} 
\cfoot{\fancyplain{}{\thepage}}

\begin{document}
\chapter{Foo}
\section{short1}
haha
\section{short2}
jaja
\section{short3}
lala
\end{document}

0

You must log in to answer this question.

Browse other questions tagged .