7

I use biblatex with indexing option; moreover, inside the text I have some names to index, with the usual \index{} command. Since I have the same authors in the bibliography and in the text, in the Index I find two occurrences of the same name, the first one coming from text, the second one from bibliography, for example:

Homer, 27, 45, 79
Homer, 107

But it's wrong and confusing. How can I unify the names occurrences?

A minimal example:

\documentclass{article}
\usepackage{fontspec}
\usepackage[style=philosophy-verbose,scauthors=true,classical=true,%
volumeformat=romansc,indexing]{biblatex}
\usepackage{filecontents}
\usepackage{imakeidx}
\indexsetup{othercode=\footnotesize}
\makeindex[intoc=true]
\begin{filecontents*}{\jobname.bib}
@book{strawson:1966,
  author         = {Peter Strawson},
  title          = {The Bounds of Sense},
  publisher      = {Routledge},
  location       = {London},
  year           = {1966},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
De nobis ipsis silemus\footcite{strawson:1966}: De re autem, quae agitur,
petimus, as Strawson\index{Strawson, Peter} told
\newpage
De nobis ipsis silemus: De re autem, quae agitur,
petimus, as Strawson\index{Strawson, Peter} told
\newpage
De nobis ipsis silemus\footcite{strawson:1966}: De re autem, quae agitur,
petimus, as Strawson told
\newpage
De nobis ipsis silemus
De nobis ipsis silemus: De re autem, quae agitur,
petimus, as Strawson\index{Strawson, Peter} told
\newpage
De nobis ipsis silemus\footcite{strawson:1966}: De re autem, quae agitur,
petimus, as Strawson told

\printbibliography
\printindex
\end{document}

where you'll note the double occurrence of Strawson. In example.idx I read

\indexentry{Strawson, Peter}{1}
\indexentry{Strawson, Peter@Strawson, Peter}{1}
\indexentry{Strawson, Peter}{2}
\indexentry{Strawson, Peter@Strawson, Peter}{3}
\indexentry{Strawson, Peter}{4}
\indexentry{Strawson, Peter@Strawson, Peter}{5}
\indexentry{Strawson, Peter@Strawson, Peter}{5}
3
  • 1
    Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – egreg
    Mar 15, 2014 at 20:20
  • the usual reason for multiple index entries is differences in spacing in the different \index{...} inputs. you can take a look at the entries in the .idx file and see how they differ, and from that, usually figure out how to make them the same so that they will combine properly. since the bibliography is generated automatically, however, you may find it necessary to follow a "style" that isn't obvious. Mar 15, 2014 at 21:18
  • I reformatted your question, particularly for the code part (select it and click on the {} button for getting syntax coloring). Thanks for the very good minimal example.
    – egreg
    Mar 15, 2014 at 22:13

3 Answers 3

7

For reasons that I don't really understand, the indexing made by biblatex issues a command of the form

\index{Strawson, Peter@Strawson, Peter}

as you can see by examining the .idx file

\indexentry{Strawson, Peter}{1}
\indexentry{Strawson, Peter@Strawson, Peter}{1}
\indexentry{Strawson, Peter}{2}
\indexentry{Strawson, Peter@Strawson, Peter}{3}
\indexentry{Strawson, Peter}{4}
\indexentry{Strawson, Peter@Strawson, Peter}{5}
\indexentry{Strawson, Peter@Strawson, Peter}{5}

You can work around this behavior by defining

\newcommand{\nindex}[1]{\index{#1@#1}}

and using \nindex{Strawson, Peter} in the text. After the change, here's the .idx file I get:

\indexentry{Strawson, Peter@Strawson, Peter}{1}
\indexentry{Strawson, Peter@Strawson, Peter}{1}
\indexentry{Strawson, Peter@Strawson, Peter}{2}
\indexentry{Strawson, Peter@Strawson, Peter}{3}
\indexentry{Strawson, Peter@Strawson, Peter}{4}
\indexentry{Strawson, Peter@Strawson, Peter}{5}
\indexentry{Strawson, Peter@Strawson, Peter}{5}

and here's the index, with a single entry:

enter image description here

Maybe there is a workaround also on the biblatex side, but I don't know it.

3
  • 4
    The reason is that biblatex has a field called indexname to deal with the possibility that the name (for sorting/index purposes) should be different from the name as it should be printed. The easiest workaround, if it's only a few cases, might be to make the user-entered index entries match biblatex rather than the other way round, just as you have suggested. Mar 15, 2014 at 22:41
  • the workaround from egreg works fine! @ Paul Stanley "to make the user-entered index entries": do you mean a manual index?
    – user41063
    Mar 15, 2014 at 22:49
  • Exactly. Egreg's suggestion is (no surprise!) effective. I was just trying to explain/justify the biblatex behavior which makes it necessary. Mar 15, 2014 at 22:56
4

The result you are seeing has been correctly diagnosed by egreg. But there may be a simpler workaround. It's actually not down to \indexname, as I wrongly speculated, but to the treatment of prefixes "van" "von" "de la" etc.

If biblatex is "using prefixes" (which means it will always print Ludwig van Beethoven as Van Beethoven, Ludwig, with a capital) then it puts both a "printing" and a "sorting" entry into the index, separated by @. It does this so that it can have makeindex sort using "van Beethoven, Ludwig", but print "Van Beethoven, Ludwig". The latter requires the addition of a LaTeX command (\MakeCapital {van}) in the file, which would cause sorting difficulties if it was nakedly included in the index entry.

Simple Solution You can avoid this by setting the option useprefixes=false when loading biblatex. That may solve your problem, unless you need "useprefixes" i.e. you have entries like "van Beethoven" which you want print "Van Beethoven" and sorted under V. In most cases in English conventions of sorting at least this will be a good solution, and probably what you want.

Not so simple solution Alternatively, if you want to keep the "useprefixes" option, the following code tries to make sure that the additional naming (van Beethoven, Ludwig@\MakeCapital{van} Beethoven Ludwig) only gets used when the name actually has a prefix, and therefore solves the problem in your case (but you would then need to use egreg's approach if dealing with a name that did have a prefix, i.e. you would have to ensure that your index entries for names with a prefix took the form given above).

\makeatletter
\renewcommand*{\mkbibindexname}[4]{%
\ifuseprefix
   {\ifblank{#3}% no PREFIX
       {\@firstofone #1% remove spurious braces                                    
       \ifblank{#4}{}{ #4}%                                        
       \ifblank{#2#3}{}{,}%
       \ifblank{#2}{}{ #2}}%
       {#3 % PREFIX                                                      
         \@firstofone #1%removespuriousbraces
         \ifblank{#4}{}{ #4}%
         \ifblank{#2}{}{, #2}%
         \actualoperator
         \ifblank{#3}{}{\MakeCapital{#3} %
         #1%       
         \ifblank{#4}{}{ #4}%
         \ifblank{#2}{}{, #2}}}}
    {\@firstofone #1% NOT "using prefix" remove spurious braces                                    
     \ifblank{#4}{}{ #4}%                                                      
     \ifblank{#2#3}{}{,}%                                                      
     \ifblank{#2}{}{ #2}%                                                      
     \ifblank{#3}{}{ #3}}}
\makeatother
4
  • Thanx for your new solutions. At present, the "simple way" works, for in my index I've no names with prefix. Now going to sleep (here is 1.15am), tomorrow I'll consider the second way.
    – user41063
    Mar 16, 2014 at 0:19
  • Even if you have names with prefixes, the simple solution will work fine, so long as you are happy with "Beethoven, Ludwig van" (sorted as Beethoven) rather than "Van Beethoven, Ludwig" (sorted as van). Mar 16, 2014 at 8:25
  • Maybe it's possible to solve on biblatex side by \DeclareIndexNameFormat macro, even if the manual is very brief about it
    – user41063
    Mar 16, 2014 at 12:17
  • Yes you can do this with \DeclareIndexNameFormat. The information you need is in biblatex.def which is where this is defined. It essentially calls the macro Paul Stanley mentions above so you can redefine it and simplify it a lot if you don't want the default behaviour. The default also deals with spurious spaces so that the index looks like the names it gets but doesn't mess up sorting with different variants with spaces, hence the x@x format for everything.
    – PLK
    Mar 16, 2014 at 14:27
0

I use another solution: defining fake citation commands which print nothing, but add the author of the “cited” reference to the index.

The problem, as already pointed out, is that biblatex is liable to transform author names in various ways before adding them to the index; the @ issue mentioned in the question is just one of them. For instance, I had an annoying problem with special characters, like accents: to index the name “Châtelet, Émilie du”, biblatex would actually call \indexentry on Ch\IeC {\^a}telet, \IeC {\'E}milie du, and a manual call to \index{Châtelet, Émilie du} would therefore create a duplicate entry. So whenever I wanted to add an entry to the index manually, I had to check in the .idx file to see what biblatex had done, and then copy it, as barbara beeton and Paul Stanley suggested. It worked, but on top of being fairly illegible, I felt it wasn't very robust for my (big) document, as any change in biblatex internals or in my options (regarding prefixes, say) might break all of my manual entries.

Now, if I define:

\newbibmacro*{idxauthor}{%
  \ifciteindex
    {\indexnames{author}}
    {}}
\DeclareCiteCommand{\idxauthor}
  {}%
  {\usebibmacro{idxauthor}}
  {}
  {}

\newbibmacro*{idxeditor}{%
  \ifciteindex
    {\indexnames{editor}}
    {}}
\DeclareCiteCommand{\idxeditor}
  {}%
  {\usebibmacro{idxeditor}}
  {}
  {}

\newbibmacro*{idxtransl}{%
  \ifciteindex
    {\indexnames{translator}}
    {}}
\DeclareCiteCommand{\idxtransl}
  {}%
  {\usebibmacro{idxtransl}}
  {}
  {}

then I can call \idxauthor{strawson:1966} to add a manual index entry for Strawson, which relies on biblatex internals to issue exactly the same indexing command as a \cite{strawson:1966} but does nothing else (and in particular does not print Strawson (1966) or whatever).

You must log in to answer this question.

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