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.

Is it possible to add additional information like date of birth and death to an author index which is generated by MakeIndex? When possible, how can I do this?

share|improve this question
    
Do you mean you want to make 'sub-entries' for a main index entry? That is, something like: Smith, John, date of birth, 32. You can use the ! to do this: \index{Smith, John!date of birth}. Or you can change what gets written to the index file with @: \index{Smith, John@Smith, John (born 1950)}. These are two very different things, however, and I'm not sure which one (if any) you mean. –  jon Sep 26 '12 at 21:34
    
@jon: I know the differences between the two proposals. I think the second is the best way. But then have I call every index macro for this author with the additional informations? Or is it enough to do it once? –  Dr. Heiko Voss Sep 27 '12 at 9:18
1  
You'd have to do it every time: otherwise, you'd get two index entries. The best(?) thing to do is to define a command for each name (e.g., \johnsmith) that prints something in the main text and puts the information into the index in the way you want. The xparse package allows you to be pretty clever with how you assign optional and starred arguments (in case you need to provide sub-entries or skip any printing into the index). –  jon Sep 27 '12 at 16:25
    
What a pity! I hoped that there will be an easier way. Could you give a good example for the use of the xparse package in that case? –  Dr. Heiko Voss Sep 28 '12 at 8:59

2 Answers 2

up vote 2 down vote accepted

Here is a simplified example of what I once did. Compile with the option -shell-escape to get the index generated automatically. And read up on xparse and imakeidx so you can modify these examples so they suit your own needs.

\documentclass[openany, 12pt]{memoir}

\usepackage[paperwidth=3.5in, textwidth=3in, paperheight=5.5in, textheight=4.5in, noheadfoot]{geometry}

\usepackage{xparse}
\usepackage[latin, english]{babel}   

\usepackage[splitindex]{imakeidx}%
\makeindex[% noautomatic, % <-- uncomment to prevent automatic index generation
name=indexmain, title={Index}, intoc, columns=2]%

% to get a footnote indexed correctly
\newcommand{\fnote}[2]{#2\textsuperscript{#1}}% for 3^39 in index

% basic xparse tests:
% \IfBooleanTF {#1} tests whether the first argument is present; if it is, it does the first 'command' (i.e., the one with the \fnote command); otherwise, it does the second

% writes to index; not to main text
\DeclareDocumentCommand {\authindex} {s m}
  {\IfBooleanTF {#1}%
   {\index[indexmain]{#2|fnote{\thefootnote}}}%
   {\index[indexmain]{#2}}%
  }%

% example of a complicated name: test first for an optional argument, then for whether there is an asterisk

\NewDocumentCommand {\augustine} {s o}
  {\IfNoValueTF {#2}%
    {\IfBooleanTF {#1}% -- with no optional argument
     {\index[indexmain]{Augustine, Saint|fnote{\thefootnote}}}%
     {\index[indexmain]{Augustine, Saint}}%
    }%
    {\IfBooleanTF {#1}% -- with optional argument
      {\index[indexmain]{Augustine, Saint!#2|fnote{\thefootnote}}}%
      {\index[indexmain]{Augustine, Saint!#2}}%
    }%
  }%
  \newcommand\Augustine{Augustine\augustine}% <--- watch how * works here


% example of a word that needs \emph in the index
\NewDocumentCommand {\dominium} {s o}
   {\IfBooleanTF {#1}%
    {\foreignlanguage{latin}{\emph{dominium}}}% * == no index & no opt.arg.
    {\IfNoValueTF {#2}%
     {\foreignlanguage{latin}{\emph{dominium}}%   no optional arg.
       \index[indexmain]{dominium@\string\emph{dominium}}}%
     {\foreignlanguage{latin}{\emph{dominium}}%   optional arg. given
       \index[indexmain]{dominium@\string\emph{dominium}!#2}}%
    }%
  }

\parskip  10pt
\parindent 0pt

\begin{document}\pagestyle{empty}

PAGE ONE:

I want to talk about Smith\authindex{Smith, John}, and
\Augustine[basic thoughts about], and what they
thought about \dominium.

\newpage
PAGE TWO:

But sometimes it needs to be in a footnote.%
\footnote{\Augustine*[dates] lived in the late fourth- and early fifth
  centuries.}

\newpage
PAGE THREE:

You have to be careful about how arguments for indices get
expanded. Compare: \dominium[humanum@\string\emph{humanum}] versus
% Comment out this one to see that it is consistent with the other
% two.  In short, the \string is important when the (sub-)\index
% command is wrapped in another command (e.g., \dominium).
\dominium[humanum@\emph{humanum}] \ldots 

\newpage%
PAGE FOUR:

\ldots{} especially if you do `manual' indexing commands:
\emph{dominium}\index[indexmain]{dominium@\emph{dominium}!humanum@\emph{humanum}}.
(You can see the differences in the \texttt{.ind} file.)

Here's another thing about \Augustine{} and \dominium.%
\footnote{\Augustine* in a footnote.}
% as you can see, the '*' is caught by the \augustine.

One more footnote.%
\footnote{John\authindex*{Smith, John} in another footnote.} %

\printindex[indexmain]
\end{document}

This is a very basic and workmanlike way to do all of this. Had I had more time the first time around, I might've tried to streamline the whole process --- and I've no doubt that others would be more clever in how they did/do it. However, this --- along with a few other commands --- worked for me when I had lots of non-English terminology to index and complex name demands (regnal names, titles, etc.).

This is what the index looks like

share|improve this answer

Here's an alternative that uses glossaries:

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}

\usepackage[nomain,index]{glossaries}
\usepackage{glossary-mcols}

\makeglossaries

\glsaddkey{forename}
 {}% default value
 {\entryforename}% no-link command to access the value
 {\Entryforename}% initial capital version
 {\glsforename}% linking command
 {\Glsforename}% initial capital version
 {\GLSforename}% all caps version

\glsaddkey{surname}
 {}% default value
 {\entrysurname}% no-link command to access the value
 {\Entrysurname}% initial capital version
 {\glssurname}% linking command
 {\Glssurname}% initial capital version
 {\GLSsurname}% all caps version

\glsaddkey{dateofbirth}
 {}% default value
 {\entrydateofbirth}% no-link command to access the value
 {\Entrydateofbirth}% initial capital version
 {\glsdateofbirth}% linking command
 {\Glsdateofbirth}% initial capital version
 {\GLSdateofbirth}% all caps version

\glsaddkey{dateofdeath}
 {}% default value
 {\entrydateofdeath}% no-link command to access the value
 {\Entrydateofdeath}% initial capital version
 {\glsdateofdeath}% linking command
 {\Glsdateofdeath}% initial capital version
 {\GLSdateofdeath}% all caps version

% syntax: \newperson[options]{label}{forename}{surname}{date of birth}{date
% of death}
\newcommand{\newperson}[6][]{%
  \newterm
  [
    name={#4, #3},%
    sort={#4, #3},%
    text={#3 #4},%
    forename={#3},%
    surname={#4},%
    dateofbirth={#5},%
    dateofdeath={#6},%
    #1%
  ]{#2}%
}

\newglossarystyle{people}%
{%
  \setglossarystyle{mcolindexgroup}%
  \renewcommand*{\glossentry}[2]{%
     \item\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}%
     \ifglshasfield{dateofbirth}{##1}%
     {%
        \space (\entrydateofbirth{##1}--%
        \ifglshasfield{dateofdeath}{##1}{\entrydateofdeath{##1}}{})%
     }%
     {% 
       \ifglshasfield{dateofdeath}{##1}{\space (d.~\entrydateofdeath{##1})}{}%
     }%
     ,\space ##2%
  }%
  \renewcommand{\subglossentry}[3]{%
    \ifcase##1\relax
      % level 0
      \item
    \or
      % level 1
      \subitem
      \glssubentryitem{##2}%
    \else
      % all other levels
      \subsubitem
    \fi
    \glstarget{##2}{\glossentryname{##2}}%
    ,\space ##3%
  }%
}

\newperson{lewiscarroll}{Lewis}{Carroll}{1832}{1898}

\newterm[name={Alice's Adventures},parent=lewiscarroll]{alice}

\newperson{charlesdickens}{Charles}{Dickens}{1812}{1870}

\newterm[name={\emph{Bleak House}},parent=charlesdickens]{bleakhouse}

% non-people related terms:
\newterm{aardvark}
\newterm{zebra}
\newterm{jabberwocky}
\newterm[plural=mice]{mouse}

\begin{document}

\gls{charlesdickens} was born in \glsdateofbirth{charlesdickens}
and died in \glsdateofdeath{charlesdickens}. One of his many novels
was \gls{bleakhouse}.

\gls{lewiscarroll} was born in \glsdateofbirth{lewiscarroll} and
died in \glsdateofdeath{lewiscarroll}. His most stories include 
the adventures of a girl called \glsdisp{alice}{Alice}. He invented
the \gls{jabberwocky} but didn't invent \glspl{aardvark},
\glspl{mouse} or \glspl{zebra}.

\printglossary[type=index,style=people]

\end{document}

This produces:

Image of resulting document

share|improve this answer

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.