这听起来可能有点奇怪:我正在使用 JabRef 来维护一个数据库,它不是首先是内容书目数据:
@Person{caesar,
date = {100-44BC},
comment = {tyran},
description = {rebel},
locationbirth = {Rome},
locationdeath = {Rome},
name = {Iulius Caesar, Caius},
shortname = {Caesar},
works = {Bello Gallico},
}
@Work{bello:gallico,
author = {Caesar},
title = {Bello Gallico},
date = {58-51BC},
}
这非常有效,因为 JabRef 中的所有字段都可以自定义,并且我可以对各种条目进行分组并快速搜索数据库。
现在到了困难的部分:
如何使用和集成 TeX 文档中的数据?
注意:我知道
datatool
哪个工具很好用,还有它的 GUI(datatooltk
),但我无法在我的系统上运行它(...总是 Java 问题),但我想使用 JabRef 和带有其bibtex
格式的数据集。
条目之间可以有关系吗?比如works={\getdata{bello:gallico}{title}},
(参见下面的 MWE)?
首次尝试使用biblatex
乍一看,似乎一个常见的经过修改的\cite
-command 应该可以完成这项工作。我失败了。而且它可能与使用的引用样式相冲突。但也许有人有一个好的解决方案biblatex
?
第二次尝试使用keyval
/xkeyval
另一方面,它也“只是”一个分为多个条目的键值列表。因此,xkeyval
这可能是正确的工具。但我无法集成数据集文档并将值传递给\setkeys...
/\define@key
命令。
以下是 MWE:
\documentclass{scrartcl}
\usepackage{xkeyval}
\usepackage{filecontents}
\newcommand\getdata[2]{%
% load file `datasets.tex` and search for needed values.
% \setkeys{#1}{#2}
% \define@key{#1}{#2}{##1}
}
\begin{filecontents}{datasets.tex}
@Person{caesar,
date = {100-44BC},
comment = {tyran},
description = {rebel},
locationbirth = {Rome},
locationdeath = {Rome},
name = {Iulius Caesar, Caius},
shortname = {Caesar},
works = {\getdata{bello:gallico}{title}},
}
@Person{cicero,
date = {106-43BC},
comment = {great author},
description = {Statesman, rhetor, author},
locationbirth = {Arpinum},
locationdeath = {Formiae},
name = {Tullius Cicero, Marcus},
shortname = {Cicero},
works = {\getdata{de:re:publica}{title}, \getdata{de:amicitia}{title}},
}
@Work{de:re:publica,
author = {\getdata{cicero}{name}},
title = {De re publica},
date = {54-51BC},
}
@Work{de:amicitia,
author = {\getdata{cicero}{name}},
title = {Laelius de amicitia},
date = {44BC},
}
@Work{bello:gallico,
author = {\getdata{caesar}{name}},
title = {Bello Gallico},
date = {58-51BC},
}
\end{filecontents}
\begin{document}
\getdata{caesar}{name} was bon in
\getdata{caesar}{locationbirth}.
He lived \getdata{caesar}{date} and died in
\getdata{casear}{locationdeath}.
Our friend \getdata{cicero}{name} lived longer (\getdata{cicero}{date}) and he can be described as:
\getdata{cicero}{description}.
% if this works it would be awesome!
\getdata{cicero}{name} published many important works: \getdata{cicero}{works}.
\getdata{caesar}{name} however only one big shot:
\getdata{bello:gallico}{title} written in
\getdata{bello:gallico}{date}.
\end{document}