[Tex/LaTex] Footnote numbers in index (e.g., 23n3)

footnotesindexingluatexmemoir

I'm currently weighing indexing options for a book-length project. One of the more surprising hurdles is that there doesn't seem to be a way to create an index (in my case, several indices) that disambiguates references in the text from those that appear in the footnotes. For example, there will be several hundred references to Roman and canon law, but usually these will be in the footnotes, where there will be, on average, several footnotes per page. Thus a generic reference to page 100 in the citation index is not nearly as helpful as a reference to '100n34' (which is standard practice for publishers who still bother to include things like an 'index locorum').

For sorting reasons, it seems like xindy will be the best option, but a solution that can deal with footnote references will trump that since it will be easier to manually sort the .idx file than to manually identify every citation in a footnote versus one in the text. (Note also that the footnotes invariably contain other arbitrary elements, such as text and citations to modern studies, so a 'special' footnote command will probably not work.)

Finally, in case this complicates things any further, this project is tied to the memoir class (page layout) and lualatex (fonts).

Best Answer

Here is my attempt at doing it. I haven't tested extensively, but it seems to work (with two books, two inline citations, and two footnote citations with dummy footnotes in-between).

The idea, following what Paul Stanley said in his comments, is to use BibLaTeX to index things properly. In order to do so, we need to redefine \DeclareIndexFieldFormat (which is used for indexing titles, but it has several variants for names, etc.), and to create a macro that will format the page number by appending the footnote number to it.

I am also renewing two macros because biblatex does some formatting before indexing titles, and we need to preserve it while incorporating the added |note command.

\documentclass{memoir}

\usepackage[backend=biber,indexing=cite]{biblatex}

\makeatletter

\DeclareIndexFieldFormat{indextitle}{%
    \iffootnote%
        {\usebibmacro{index:title}{\index}{#1}{|note{\thefootnote}}}%
        {\usebibmacro{index:title}{\index}{#1}{}}%
}

\renewbibmacro*{index:title}[3]{%
    \usebibmacro{index:field}{#1}{\thefield{indexsorttitle}}{\emph{#2}}{#3}}

\renewbibmacro*{index:field}[4]{%
    \begingroup
    \protected@edef\theindexentry{%
        \unexpanded{#1}{#2\actualoperator\unexpanded{#3#4}}}%
    \theindexentry
    \endgroup}

\newcommand{\note}[2]{#2n#1}

\makeatother

\begin{filecontents}{\jobname.bib}
@book{author:2000,
  author = {Author, A.},
  year = {2000},
  title = {My first title},
}
@book{buthor:2002,
  author = {Buthor, B.},
  year = {2002},
  title = {My second title},
}
\end{filecontents}

\makeindex

\begin{document}

Some inline citation \cite{author:2000}. Some footnote\footnote{A, b and c}. Some footnote citation \footcite{buthor:2002}.

\clearpage

Some footnote\footnote{A, b and c}. Some footnote citation \footcite{author:2000}. Some inline citation \cite{buthor:2002}.

\printindex

\end{document}

Edit: Looking at your first question, I think perhaps you could create an entry using the following code:

@book{digest,
    title = {Digestum},
    indextitle = {Digestum!\emph{Dig.}},
    indexsorttitle = {02},
}
@book{institutes,
    title = {Institutiones},
    indextitle = {Institutiones!\emph{Inst.}},
    indexsorttitle = {01},
}

Don't forget to replace the \emph{#2} by #2 in \renewbibmacro{index:title} at l. 14, otherwise it won't work.

Now, if you want two indexes with one of them being sorted arbitrarily and the other alphabetically, you need to specify things accordingly, by saying where to index which data (see the memoir documentation). If you further want the "Institutiones" and "Digestum" to look like letter headings, I suggest you look for a way to solve your first question with xindy (or wait until someone find it). Sorry I can't help there.

Related Question