Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
3  
Will you be using Biblatex? I know that sounds like a mad question. But it's good at detecting when something is happening in a footnote, and one might leverage that to patch the index command. –  Paul Stanley May 11 '12 at 20:48
    
@PaulStanley -- yes I do. It is the only sane choice if you work in the humanities. In fact, I wondered --- briefly --- about the very same thing after I posted the question. I suppose I should look at what it does this weekend, but I suspect this will be beyond my expertise to fix. –  jon May 11 '12 at 21:04
    
Just as a follow-up: the default behaviour of biblatex (with option indexing=cite) does not indicate whether the citation is in a footnote or not. –  jon May 11 '12 at 21:11
    
I think you will find that whatever index package you use will at some time write \thepage to its idx file. If one could test whether one was in a footnote at that point, which Biblatex makes simple with \iffootnote one could add a reference to the footnote number at that point. –  Paul Stanley May 11 '12 at 21:14
    
The point is that \iffootnote is just a macro like any other. It uses the fact that Biblatex patches the way footnotes are constructed to set a flag which can then be tested, but I think you could use it for any purpose. Indeed you should be able to play with biblatex's indexing macros to make it an automatic part of a citation. –  Paul Stanley May 11 '12 at 21:21
show 2 more comments

2 Answers

up vote 10 down vote accepted

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.

share|improve this answer
    
This is a great start! I actually started on a similar tact as with your \note command, just not tied to biblatex. One problem with what I need for the legal citations is that I cannot bind my indexing to the index:title macro because two different (multi-volume) works each contain a complicated assortment of legal collections --- see here for an earlier question, which only scratches the surface of the different types of citations (and which is somehow not linked to this account). –  jon May 11 '12 at 23:38
    
That said: I will certainly use this for regular citations! –  jon May 11 '12 at 23:39
    
I used index:title because I thought it would be easier than the author's name for indexing legal citations, but you could use something else. Do you think another field would be more appropriate? As I said, \DeclareIndexFieldFormat has different variants. I'll edit my answer with what could be a solution to your first question. –  ienissei May 12 '12 at 9:24
    
@jon And I'd be very interested in the xindy solution for creating custom alphabetical orders, too, though I can't help much there at the moment. Also if you are interested, perhaps you could contact Paul Stanley, we are trying to gather people who are working on styles for legal citations with biblatex. I would regard some roman law knowledge as a great addition to the endeavour. See here for details. –  ienissei May 12 '12 at 10:39
    
For most cases, I think the index:title field is appropriate, but not necessarily for Roman or canon law. The standard edition for Roman law (3 vols.) contains the Institutes, Digest, Code, and Novels (cited by I./Inst., D./Dig., C./Cod., and N./Nov.), while canon law (in two vols.) contains the Decretum (cited differently depending on which part), Decretals (X.), Sext (VI.), Clementines, (Clem.), Extravagantes Iohannis XXII (usually Ex. Io. XXII), and Extravagantes communes (Ex. comm.). It is easier, and better, to create citation commands not tied to biblatex to cite them. –  jon May 12 '12 at 18:52
show 3 more comments

So far it seems as though the easiest solution is to create two commands, one for in-text citations (which are rare in my case), and one for the citation occurs in a footnote. Here is a simplified example using makeindex (which will end up sorting things incorrectly in a fuller example, but that's a different problem...). Note that I exaggerated the \digtext and \insttext commands for clarity (including how they are indexed); I suppose you could do the same with 'starred' commands, but I prefer expressing the point of the command in its name where possible.

\documentclass[12pt]{memoir}

\usepackage{makeidx}
\makeindex

\newcommand{\nn}[2]{#2n#1}
\newcommand{\inst}[1]{Inst.\,#1\index{Inst. #1@I. #1|nn{\thefootnote}}}
\newcommand{\insttext}[1]{Inst.\,#1\index{Inst. #1@I. #1}}

\newcommand{\digtext}[1]{Dig.\,#1\index{Dig. #1@D. #1}}
\newcommand{\dig}[1]{Dig.\,#1\index{Dig. #1@D. #1|nn{\thefootnote}}}

\begin{document}

Some text.%
\footnote{A footnote with no citations.} %
%
%
\digtext{21.1.3}
\digtext{1.1.5}
\digtext{4.3.15.5}.%
\footnote{%
\inst{2.4.2}
\inst{4.1.1}
\inst{3.17.1}
}

\newpage
\insttext{1.2 pr}
\insttext{2.4.2}
\insttext{3.17.1}.%
\footnote{%
\dig{3.1.9}
\dig{50.17.188}
\dig{12.2.2.2}
\dig{1.1.5}
}

\printindex
\end{document}    

A more automatic, not to mention elegant, solution would be better, but changing a several dozen in-text citations might be the easiest solution.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.