我目前正在(再次)尝试实现一种自定义引用样式,该样式应以出版物列表结尾,并且通常有效。我的 tex 文件非常简单:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[datamodel=reference_class_definitions,backend=biber,maxbibnames=99,giveninits=true,style=science]{biblatex}
\addbibresource{publication_data.bib}
\input{citation_style_definitions}
\begin{document}
\begin{refsection}
\begin{enumerate}
\item \fullcite{Author1981}.
\end{enumerate}
\end{refsection}
\end{document}
它使用文件reference_class_definitions.dbx
(citation_style_definitions.tex
以某种方式定义自定义输出样式,请参阅下文了解其内容)和publication_data.bib
(包含一篇论文的书目数据):
@Article{Author1981,
author = {Author, One and Author, Two},
journal_name = {Journal of Fancy Research},
title = {Some paper title},
year = {1981},
number = {6},
pages = {1247-1260},
volume = {20},
doi = {10.someRandomNumber},
type = {Journal Article},
}
输出正是我想要的:
但是,当我尝试将 中的字段“journal_name”的名称更改为“journal”时,我观察到一种奇怪的行为。当然,我也将和publication_data.bib
中的所有“journal_name”实例更改为“journal”,但输出不显示日志名称:reference_class_definitions.dbx
citation_style_definitions.tex
我无法理解这种行为,所以我的问题是:将“journal_name”更改为“journal”后,期刊名称为什么不显示?任何其他名称都可以,例如,使用“published_in”代替“journal_name”完全没有问题。但我更喜欢“journal”,因为据我所知,它是标准书目样式识别的字段之一。
reference_class_definitions.dbx
包含:
\DeclareDatamodelEntrytypes{article}
\DeclareDatamodelFields[type=field,datatype=literal]{
title,
journal_name,
volume,
pages,
ISSN,
DOI,
url,
year,
type
}
\DeclareDatamodelFields[type=list,datatype=name]{
author
}
\DeclareDatamodelEntryfields[article]{
author,
title,
journal_name,
volume,
pages,
ISSN,
DOI,
url,
year,
type}
citation_style_definitions.tex
包含:
\DeclareFieldFormat[article]{author}{#1\isdot}
\DeclareFieldFormat[article]{title}{\mkbibquote{\textit{#1}}\isdot}
\DeclareFieldFormat[article]{journal_name}{\textit{#1}\isdot}
\DeclareFieldFormat[article]{volume}{\textit{#1}\isdot}
\DeclareFieldFormat[article]{pages}{#1\isdot}
\DeclareFieldFormat[article]{DOI}{#1\isdot}
\DeclareFieldFormat[article]{year}{\textbf{#1}\isdot}
\DeclareBibliographyDriver{article}{%
\printnames{author}%
\addcomma\setunit{\addspace}%
\printfield{title}%
\addcomma\setunit{\addspace}%
\printfield{journal_name}%
\setunit{\addspace}%
\printfield{year}%
\addcomma\setunit{\addspace}%
\printfield{volume}
\addcomma\setunit{\addspace}%
\printfield{pages}
\addcomma\addspace%
DOI:\setunit{\addspace}\printfield{DOI}
\addperiod\setunit{\addspace}%
}
答案1
journal
是一个有点棘手的字段。它实际上不是标准数据模型的一部分。相反,它journaltitle
通过默认驱动程序源映射 (ll. 1339-1371 在biblatex.def
)。在您的示例中,journal
源映射被执行并重新映射journal
到journaltitle
,然后您的数据模型就再也看不到任何journal
。
您可以用它清除默认驱动程序源图\DeclareDriverSourcemap[datatype=bibtex]{}
(或者您可以只复制您喜欢的部分,并从上面链接的定义中删除您不喜欢的部分)。
\begin{filecontents}{reference_class_definitions.dbx}
\DeclareDatamodelEntrytypes{article}
\DeclareDatamodelFields[type=field,datatype=literal]{
title,
journal,
volume,
pages,
ISSN,
DOI,
url,
year,
type
}
\DeclareDatamodelFields[type=list,datatype=name]{
author
}
\DeclareDatamodelEntryfields[article]{
author,
title,
journal,
volume,
pages,
ISSN,
DOI,
url,
year,
type}
\end{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{Author1981,
author = {Author, One and Author, Two},
journal = {Journal of Fancy Research},
title = {Some paper title},
year = {1981},
number = {6},
pages = {1247-1260},
volume = {20},
doi = {10.someRandomNumber},
type = {Journal Article},
}
\end{filecontents}
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[datamodel=reference_class_definitions,backend=biber,maxbibnames=99,giveninits=true,style=science]{biblatex}
\DeclareDriverSourcemap[datatype=bibtex]{}
\DeclareFieldFormat[article]{author}{#1\isdot}
\DeclareFieldFormat[article]{title}{\mkbibquote{\textit{#1}}\isdot}
\DeclareFieldFormat[article]{journal_name}{\textit{#1}\isdot}
\DeclareFieldFormat[article]{volume}{\textit{#1}\isdot}
\DeclareFieldFormat[article]{pages}{#1\isdot}
\DeclareFieldFormat[article]{DOI}{#1\isdot}
\DeclareFieldFormat[article]{year}{\textbf{#1}\isdot}
\DeclareBibliographyDriver{article}{%
\printnames{author}%
\addcomma\setunit{\addspace}%
\printfield{title}%
\addcomma\setunit{\addspace}%
\printfield{journal}%
\setunit{\addspace}%
\printfield{year}%
\addcomma\setunit{\addspace}%
\printfield{volume}
\addcomma\setunit{\addspace}%
\printfield{pages}
\addcomma\addspace%
DOI:\setunit{\addspace}\printfield{DOI}
\addperiod\setunit{\addspace}%
}
\addbibresource{\jobname.bib}
\begin{document}
\begin{refsection}
\begin{enumerate}
\item \fullcite{Author1981}.
\end{enumerate}
\end{refsection}
\end{document}
至少在这个例子中,我完全不明白为什么你需要新的数据模型。除了你定义的所有字段(以及我们刚刚讨论的/type
问题)之外,标准数据模型中已经知道了。使用 已经暗示了,但如果你需要更细粒度的控制,可以使用。journal_name
journal
@article
type = {Journal Article},
@article
entrysubtype
\addcomma
在参考书目驱动程序或 bibmacros 中,不鼓励在 and 朋友之外使用裸标点符号(如\setunit
and 朋友),因为它们会绕过标点符号缓冲区,并可能导致不良(双重)标点符号。同样,通常不鼓励在那里使用像“DOI:”这样的裸文本,而应将其移至\DeclareFieldFormat
and 朋友。