是否可以将出生和死亡日期等其他信息添加到 MakeIndex 生成的作者索引中?如果可以,我该怎么做?
答案1
这是我曾经做过的一个简化示例。使用-shell-escape
自动生成索引的选项进行编译。阅读后xparse
,imakeidx
您可以修改这些示例,使其适合您自己的需要。
\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}
这是完成所有这些工作的一种非常基本和熟练的方法。如果我第一次有更多时间,我可能会尝试简化整个过程 --- 而且我毫不怀疑其他人会更聪明地做到这一点。然而,当我有大量非英语术语需要索引和复杂的名称要求(统治名称、头衔等)时,这个 --- 以及其他一些命令 --- 对我来说很有效。
答案2
这是一个替代方案,使用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}
得出的结果为: