我正在尝试在我的文档中使用 2 个单独的“引用样式”,利用 customX 现有文档类型(扩展将拥有单独的文档类型,但我暂时不想使用 lbx 文件)。
所以我在测试中使用了该类型customc
。在自定义引用中,没有作者,引用应为“title, postnote”,如果定义了注释字段,则可选引用模式为“{title} {note}, postnote”。
我在为文档类型 customc 重新定义“customc:cite”时遇到了困难。我以为它和 一样,DeclareBibliographyDriver
但我找不到让它们工作的方法。我该如何实现这一点?以下是我目前得到的结果
这是我的 MWE:
\documentclass[11pt]{memoir}
\usepackage{filecontents}
\begin{filecontents}{test.bib}
@book{book1,
author = {Author, Roberto B.},
title = {The Writing of History in Ancient Egypt during the First Millennium BC (ca. 1070-180 BC). Trends and Perspectives},
shorttitle = {A short title},
}
@customc{atf1,
title = {A title},
note = {= Un titre},
}
@customc{atf2,
title = {Another title},
}
\end{filecontents}
\usepackage[style=authortitle,backend=biber,language=french]{biblatex}
\addbibresource{test.bib}
\UndefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
\newcommand{\no}{n\textsuperscript{o}\addnbthinspace}
\newcommand{\nos}{n\textsuperscript{os}\addnbthinspace}
\newcommand{\considerant}{consid.\addnbthinspace}
\renewcommand*{\mkbibnamefamily}{\textsc}
\renewcommand*{\revsdnamepunct}{}
\DeclareFieldFormat*{citetitle}{\mkbibemph{#1}}
\renewcommand*{\multicitedelim}{\addsemicolon\space}
\newcommand{\ucites}{\parencites}
\DeclareFieldFormat[customc]{title}{#1}
\DeclareFieldFormat[customc]{citetitle}{#1}
\DeclareFieldFormat[customc]{note}{#1}
\DeclareFieldFormat[customc]{postnote}{\considerant #1}
\DeclareBibliographyDriver{customc}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{title}%
\newunit\newblock
\printfield{note}%
\usebibmacro{finentry}
}
\newbibmacro*{customc:cite}{%
\usebibmacro{cite:title}%
\iffieldundef{note}{}{\printfield{note}}%
}
\begin{document}
a first test as demo \ucites[1]{book1}. a second text which also has some references \ucites[\nos 1, 2, 5]{book1}.
Finally a test using the custom citation style \ucites[2.a \& 2.b]{atf1}[5.1]{atf2}. However the display should be "A title = Un titre, consid. 2.a \& 2.b".
\end{document}
答案1
与参考书目输出不同,标准样式中的引文输出不依赖于类型biblatex
。这意味着只有一个cite
宏控制所有类型的引文,并且没有像\DeclareBibliographyDriver{<type>}
或 这样的方便的宏cite:<type>
来更改特定类型的引文格式。
在这种情况下,最直接的方法就是重新定义cite
宏(如中定义authortitlte.cbx
)为
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\printnames{labelname}%
\setunit*{\printdelim{nametitledelim}}%
\usebibmacro{cite:title}%
\ifentrytype{customc}
{\setunit{\addspace}%
\printfield{note}}
{}}%
{\usebibmacro{cite:shorthand}}}
这只是为类型添加一个测试,如果我们有一个条目,@customc
则打印该字段。note
@customc
如果您还想为其他条目类型添加更复杂的定义,您可能需要考虑不同的设置。以下允许您定义特定于类型的引用宏并返回到标准定义。
% save the "default" cite macro in cite:default.
% That means we can overwrite cite later
% and still use the old definition within the new one
\letbibmacro*{cite:default}{cite}
\renewbibmacro*{cite}{%
\ifbibmacroundef{cite:\strfield{entrytype}}
{\usebibmacro{cite:default}}
{\usebibmacro*{cite:\strfield{entrytype}}}}
\newbibmacro*{cite:customc}{%
\usebibmacro{cite:title}%
\setunit{\addspace}%
\printfield{note}}