2

Why doesn't the index have the same header/footer as the entire document? Here is an MWE:

\documentclass{article}

\usepackage{fancyhdr,imakeidx,lipsum}      
\makeindex

\lhead{Lorem Ipsum}
\rhead{Cicero}

\begin{document}
    \pagestyle{fancy}

   \section{Lorem Ipsum}
   \index{lorem}
   \lipsum[1]

   \subsection{Nam dui Lingua}
   \index{nam}
   \lipsum[2]

   \printindex 
\end{document}

I have been playing around with \indexsetup{othercode={...}} but I haven't managed to get anywhere. I can't find anything helpful in the documentation either. I appreciate any assistance.

  • If I change \usepackage{lipsum} into \usepackage[index]{kantlipsum} and the document body into \kant[1-200] \printindex, I get the expected headers on the second page of the index. Do you need them also on the first page? – egreg Jun 5 at 21:20
  • @egreg I was actually suspecting that may be it, but I didn't know of a way to get the index to be longer than one page apart from adding manual entries! Seeing as the style of the index heading is similar to that of a section, I think it makes sense that the usual header/footers apply too (even on the first page). Do you know how this can be done? – Luke Collins Jun 5 at 21:23
  • 1
    Yes, but you were looking to the wrong manual. – egreg Jun 5 at 21:24
  • @egreg What do you mean? Where should I have been looking? – Luke Collins Jun 5 at 21:25
  • The manual of imakeidx – egreg Jun 5 at 21:25
2

The first page of the index uses page style plain. You can modify it with \indexsetup:

\documentclass{article}

\usepackage{fancyhdr,imakeidx}
\usepackage[index]{kantlipsum}

\makeindex
\indexsetup{firstpagestyle=fancy}

\lhead{Lorem Ipsum}
\rhead{Cicero}

\pagestyle{fancy}

\begin{document}

\section{Lorem Ipsum}

\kant[1-200]

\printindex

\end{document}

enter image description here

  • 1
    Anticipated my follow up question. Excellent, thank you! – Luke Collins Jun 5 at 21:24

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.