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.

5
  • 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
    Commented Jun 5, 2019 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? Commented Jun 5, 2019 at 21:23
  • 1
    Yes, but you were looking to the wrong manual.
    – egreg
    Commented Jun 5, 2019 at 21:24
  • @egreg What do you mean? Where should I have been looking? Commented Jun 5, 2019 at 21:25
  • The manual of imakeidx
    – egreg
    Commented Jun 5, 2019 at 21:25

1 Answer 1

3

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
  • 1
    Anticipated my follow up question. Excellent, thank you! Commented Jun 5, 2019 at 21:24

You must log in to answer this question.

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