我在工作中使用了很多多卷百科全书的文章。为此,我使用crossref
参考书目文件中的属性设置了文章。使用的引用样式authoryear-icomp
基本上是可以的。
引用我(\citetitle[\emph{ML:}][]{ml:thermoskanne})
目前使用的百科全书文章,其结果是:
(ML:Thermoskanne)
相反,我希望能够说类似这样的话\parencitetitle{ml:thermoskanne}
,并自动获得这个(Biblatex 同时查看@incollection
以及@mvcollection
:
(ML:Thermoskanne)
首字母取自@mvcollection
'stitle
属性,且不带空格。是否有 Biblatex 命令可用于此类操作?如果没有,如何编写新命令?
编辑:这是使用 cfr 答案的完整 MWE,它似乎运行完美!
\documentclass{scrartcl}
\usepackage{csquotes}
\usepackage{polyglossia}
\setmainlanguage[spelling=new]{german}
% example bib file
\begin{filecontents}{test.bib}
@mvcollection{ml,
title = {Müllers Lexikon},
}
@incollection{ml:thermoskanne,
crossref = {ml},
title = {Thermoskanne},
volume = {2},
}
\end{filecontents}
\usepackage[backend=biber,citestyle=authoryear-icomp]{biblatex}
\addbibresource{test.bib}
% no quotes, italic font instead
\DeclareFieldFormat*{citetitle}{\emph{#1}}
% cfr's first suggestion
\usepackage{xparse}
\NewDocumentCommand \parencitetitle { > { \SplitArgument { 1 } { : } } m }
{%
\myparencitetitle #1}
\NewDocumentCommand \myparencitetitle { m m }
{%
\parentext {\mkbibemph{\MakeUppercase{#1}}:\citetitle{#1:#2}}}
% some sample text, etc.
\begin{document}
Some things need to be said, some things need to be written. One place to put them in is an encyclopedia.
This is what it should look like, just without the space: (\citetitle[\emph{ML:}][]{ml:thermoskanne}).
And this is what it looks like right now: \parencitetitle{ml:thermoskanne}.
Wow! It already works!
\printbibliography
\end{document}
答案1
如果我们用@inreference
来正确区分参考文献,那么我们就可以使用\ifentrytype{inreference}
。另外,我会将这两个字母添加ML
为 的简写ml
。
@mvreference{ml,
title = {Müllers Lexikon},
shorthand = {ML},
options = {skipbib},
}
@inreference{ml:thermoskanne,
crossref = {ml},
title = {Thermoskanne},
volume = {2},
}
这里我还添加了skipbib
,ml
这样它就不会显示在参考书目中,当然你可以把它删除。
然后我们定义 bibmacro 来引用,以@inreference
不同的方式处理
\makeatletter
\renewbibmacro*{cite}{%
\ifboolexpr{test {\ifentrytype{inreference}} and not test {\iffieldundef{crossref}}}
{\entrydata{\thefield{crossref}}{%
\printfield[citetitle]{shorthand}}%
\setunit{\addcolon}%
\usebibmacro{cite:label}}%
{%
\iffieldundef{shorthand}
{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{\usebibmacro{cite:ibid}}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}}%
\setunit{\multicitedelim}}
\makeatother
authoryear-icomp.cbx
这只是一开始的副本加上一些修改。
因为我们使用crossref
机制,所以我们也需要mincrossrefs=1
。
平均能量损失
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@mvreference{ml,
title = {Müllers Lexikon},
shorthand = {ML},
options = {skipbib},
}
@inreference{ml:thermoskanne,
crossref = {ml},
title = {Thermoskanne},
volume = {2},
}
\end{filecontents*}
\usepackage[backend=biber,citestyle=authoryear-icomp,mincrossrefs=1]{biblatex}
\addbibresource{\jobname.bib}
% no quotes, italic font instead
\DeclareFieldFormat*{citetitle}{\emph{#1}}
\makeatletter
\renewbibmacro*{cite}{%
\ifboolexpr{test {\ifentrytype{inreference}} and not test {\iffieldundef{crossref}}}
{\entrydata{\thefield{crossref}}{%
\printfield[citetitle]{shorthand}}%
\setunit{\addcolon}%
\usebibmacro{cite:label}}%
{%
\iffieldundef{shorthand}
{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
{\usebibmacro{cite:ibid}}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}}%
\setunit{\multicitedelim}}
\makeatother
\begin{document}
And this is what it looks like right now \cite{ml:thermoskanne}.
\printbibliography
\end{document}
答案2
尝试一下,但是没有适当的示例我无法测试,并且biblatex-examples.bib
不包含任何合适的内容。
\usepackage{xparse}
\NewDocumentCommand \parencitetitle { > { \SplitArgument { 1 } { : } } m }
{%
\myparencitetitle #1}
\NewDocumentCommand \myparencitetitle { m m }
{%
\parentext {\mkbibemph{\MakeUppercase{#1}}:\citetitle{#1:#2}}}