18

In my document I emphasize names that are mentioned and now I want to provide some additional information about them in an appendix. Currently I do something like:

\documentclass{scrartcl}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{STIXGeneral}
\def\name#1{{\texorpdfstring{\smaller\MakeUppercase{#1}}{#1}}}
\begin{document}
    Look at the works of \name{Alexandrov} and \name{Atkinson}.
    \clearpage
    \begin{section}*{Index of People}
        \begin{itemize}
            \item \name{Alexandrov}: Па́вел Серге́евич Алекса́ндров (Pavel Sergeyevich Alexandrov), \mbox{1896-05-07} – \mbox{1982-11-16}
            \item \name{Atkinson}: Frederick Valentine Atkinson, \mbox{1916-01-25} – \mbox{2002-11-13}
        \end{itemize}
    \end{section}
\end{document}

Is it possible to keep the information about the people in some database file like it is done with bibliographies and have it automatically formatted? Are there any tools available or can it be done with bibtex?

JLDiaz's answer seems like a good point to start. To be a bit more concrete, the data file should look something like:

@person{alexandrov,
    name = {Па́вел Серге́евич Алекса́ндров},
    latin = {Pavel Sergeyevich Alexandrov},
    birthdate = {1896-05-07},
    deathdate = {1982-11-16}
}

And it may certainly happen, that more fields will be added (e.g. profession, places of birth and death, nationality). So it seems whether I am using bibtex or the gloss package, I have to define my own style file. What is the difference between those two approaches?

As for defining the custom entry type I found Biblatex and custom bibtex entries - is it possible?, but the explanation there does not seem well structured / complete and possibly outdated. Maybe somebody can elaborate on that.

1
  • Perhaps you could keep the information in a .csv database and use the datatool package.
    – jon
    Jul 11, 2012 at 17:54

3 Answers 3

8

The datatool package is designed for this sort of thing. You could even use it with a .bib file if you liked. See the (very detailed) package documentation for further details. I'll give a simpler version.

Imagine you have a file namedb.csv that looks like this:

"Name","Latin","Birthdate","Deathdate"
"Па́вел Серге́евич Алекса́ндров","Pavel Sergeyevich Alexandrov","1896--05--07","1982--11--16"
"Па́вел","Pavel","1896--01--01","1982--01--01" 

Then you could do an itemize environment or (better, I think) a (long)table:

\documentclass{article}

\usepackage{libertineotf}% don't have your STIX font
\usepackage[margin=2cm]{geometry}
\usepackage{longtable,datatool}
\usepackage{enumitem}
\usepackage{parskip}
\parindent0pt
% ------------------------------8<------------------------------ %
\begin{document}
\DTLloaddb{namedb}{namedb.csv}%

% --- Itemize version
\begin{itemize}
\DTLforeach{namedb}{%
% "Name","Latin","Birthdate","Deathdate"
\name=Name,%
\latinname=Latin,%
\birthdate=Birthdate,%
\deathdate=Deathdate% pay attention to spacing in this command
}%
{%
 \item \name: \latinname, \birthdate\,---\,\deathdate
}
\end{itemize}

% --- Longtable version (for tables longer than one page)
\DTLdisplaylongdb[%
% caption={Index of People},%
 label={peopleindex},%
 contcaption={Index of People (continued)},% <-- if more than one page
 foot={\em Continued on next page},%
 lastfoot={},%
 ]{namedb}

\end{document}

A lot more could be done, in fact. But as I don't know your precise needs, I'm going to keep it simple.

2
  • When using the csv file this seems like a good approach. But it looks like the databib part of datatools does not allow arbitrary entry types and relies on bibtex to be run with a special databib style file. Thus I will now try to keep a database in bibtex format, so I may later use biblatex 2.0, and convert it with a script to a csv file. That in turn can be processed by datatool as you described. When it works I will probably accept this answer. (Unfortunately you have to choose exactly one.)
    – bodo
    Jul 12, 2012 at 5:36
  • @canaaerus -- Well pick the answer that works for you. (Biber+biblatex is the way of the future, after all!)
    – jon
    Jul 12, 2012 at 5:50
19

You might want to look at biblatex 2.0 with biber 1.0 as the bibtex replacement backend. The new \DeclareDatamodel functionality will allow you to define such entries in your .bib files and as long as you write a bit of style code to format them, you could then print such a list with a \printbibliography filter. Here is a rough example which works - I haven't fine-tuned the font switching etc.

\begin{filecontents}{test.bib}
@PERSON{alexandrov,
  NAME      = {Па́вел Серге́евич Алекса́ндров},
  LATINNAME = {Pavel Sergeyevich Alexandrov},
  DATE      = {1896-05-07/1982-11-16},
} 
\end{filecontents}
\begin{filecontents}{person.dbx}
\DeclareDatamodelEntrytypes{person}
\DeclareDatamodelFields[type=list, datatype=name]{name, latinname}
\DeclareDatamodelEntryfields[person]{
name,
latinname,
day,
endday,
month,
endmonth,
year,
endyear}
\end{filecontents}

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc} 
\usepackage[english,russian]{babel}
\usepackage[datamodel=person,style=authoryear]{biblatex}

\DeclareLabelname{shortauthor,author,shorteditor,editor,translator,name,latinname}

\newbibmacro*{personname}{%
  \printnames{name}%
  \ifnameundef{latinname}
    {}
    {\addspace\mkbibparens{\printnames{latinname}}}}

\DeclareBibliographyDriver{person}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{personname}%
  \setunit{\labelnamepunct}\newblock
  \printdate
  \usebibmacro{finentry}}

\addbibresource{test.bib}

\begin{document}
\cite{alexandrov}
\printbibliography[title=People,type=person]
\end{document}

Datamodel example

5
  • That sounds nice. Unfortunately those things are not available on Gentoo stable yet. I will try it as soon as possible.
    – bodo
    Jul 11, 2012 at 19:00
  • 3
    They will both be in TexLive 2012 as updates very shortly, or you can just get them from SourceForge.
    – PLK
    Jul 11, 2012 at 19:08
  • 1
    I have updated the answer with example code showing how to do this with biblatex 2.0/biber 1.0
    – PLK
    Jul 12, 2012 at 8:33
  • Great, I'll try it as soon as I have the software installed. One other thing still: why does \cite give the output "Алекса́ндров 1896-1982"; maybe because of datatype=name?
    – bodo
    Jul 12, 2012 at 14:14
  • 1
    Because \cite prints labelname and I included name in the labelname search using \DeclareLabelname. You could change this or redefine \cite if you need something else.
    – PLK
    Jul 12, 2012 at 14:19
6

Technically, what you are asking for is a list of pairs name-definition, so it can be done with any tool to manage glossaries.

But since you mention the use of bibtex, I think you can be interested in package gloss, which stores the pairs name-definition in a .bib file and uses bibtex to extract the list lf names referenced in the latex document.

You must log in to answer this question.

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