在如何使用 Biblatex 以不同于书籍、杂志等的方式引用百科全书文章?,我得到了一个宏的帮助,它解决了所问的问题。
我现在想更改此宏,使其像常规 Biblatex 引用命令一样工作。以下是我迄今为止尝试过的。不幸的是,它无法编译:
\documentclass{scrartcl}
\usepackage{csquotes}
\usepackage{polyglossia}
\setmainlanguage[spelling=new]{german}
% example bib file
\begin{filecontents}{test.bib}
@mvreference{ml,
title = {Müllers Lexikon},
}
@inreference{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}}
% shot at a solution based on cfr's original answer
\usepackage{xparse}
\NewDocumentCommand{\parencitetitle}
{ > { \SplitArgument { 1 } { : } } m }
{ \myparencitetitle #1 }
\NewDocumentCommand{\myparencitetitle}
{ m m }
{
\boolfalse{citetracker}
\boolfalse{pagetracker}
\usebibmacro{prenote}
\parentext{\mkbibemph{\MakeUppercase{#1}}:\citetitle{#1:#2}}
\usebibmacro{postnote}
}
% 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: (cf. \citetitle[\emph{ML:}][]{ml:thermoskanne}, 234).
And this is what it looks like right now: \parencitetitle[cf.][234]{ml:thermoskanne}.
\printbibliography
\end{document}
据我目前的理解,尝试使用 Biblatexprenotes
和postnotes
命令是错误的(也是不可能的),而SplitArgument
应该进一步利用(但是如何利用?)
答案1
Biblatex 解决方案可能更优雅、更高效。我想我会把这个留给 moewe ;)。这是一个非 Biblatex 解决方案,用于xparse
模拟引用命令的行为。我知道您表示更喜欢 Biblatex 解决方案(聊天中的选项 2)而不是模拟(选项 1),但也许这对某些人有用。无论如何,我很好奇,从好的方面来说,这不需要对您的.bib
文件进行任何更改,因为从坏的方面来说,它对这些东西一无所知。
请注意,这会在冒号后添加一个空格。但是,如果您不想要这个空格,只需取消注释相应的行并注释其上方的行。我不确定您希望没有哪个空格。
\begin{filecontents}{\jobname.bib}
@mvreference{ml,
title = {Müllers Lexikon},
}
@inreference{ml:thermoskanne,
crossref = {ml},
title = {Thermoskanne},
volume = {2},
}
\end{filecontents}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,citestyle=authoryear-icomp]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat*{citetitle}{\emph{#1}}
% shot at a solution based on cfr's original answer
\usepackage{xparse}
\NewDocumentCommand\parencitetitle
{ o o > { \SplitArgument { 1 } { : } } m }
{%
\IfNoValueTF {#2}%
{% there is no second optional argument
\IfValueTF {#1}%
{% there's a first optional argument - pass as a postnote
\myparencitetitle [] [#1] #3%
}{% neither pre- or postnotes
\myparencitetitle #3%
}%
}{% there's a second optional argument, so there must be a first as well
\myparencitetitle [#1\addspace] [#2] #3%
}%
}
\NewDocumentCommand{\myparencitetitle}
{ O {} O {} m m }
{\parentext{#1\mkbibemph{\MakeUppercase{#3}}\addcolon\addspace\citetitle[#2]{#3:#4}}}
%{\parentext{#1\mkbibemph{\MakeUppercase{#3}}\addcolon\citetitle[#2]{#3:#4}}}% use this line if you don't want a space after the colon (I'm not sure which space you want to be without)
\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: (cf. \citetitle[\emph{ML:}][]{ml:thermoskanne}, 234).
And this is what it looks like right now: \parencitetitle[cf.][234]{ml:thermoskanne}.
\parencitetitle[cf.][234]{ml:thermoskanne}
\parencitetitle[cf.][]{ml:thermoskanne}
\parencitetitle[234]{ml:thermoskanne}
\parencitetitle{ml:thermoskanne}
\printbibliography
\end{document}
答案2
xparse
这是与 Biblatex融合的尝试。
\begin{filecontents}{\jobname.bib}
@mvreference{ml,
title = {Müllers Lexikon},
}
@inreference{ml:thermoskanne,
crossref = {ml},
title = {Thermoskanne},
volume = {2},
}
\end{filecontents}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,citestyle=authoryear-icomp]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat*{citetitle}{\emph{#1}}
% shot at a solution based on cfr's original answer
\usepackage{xparse}
\NewDocumentCommand\myparencitetitle
{ > {\SplitArgument{ 1 }{ : } } m }%
{%
\prefixparencitetitle#1}
\NewDocumentCommand\prefixparencitetitle
{ m m }%
{%
\mkbibemph{\MakeUppercase{#1}\addcolon}\addspace}
\DeclareCiteCommand{\parencitetitle}
[\mkbibparens]%
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\iffieldundef{prenote}
{}%
{\printfield{prenote}%
\newunit{\prenotedelim}}}%
{\ifciteindex%
{\indexfield{indextitle}}%
{}%
\myparencitetitle{#3}%
\printfield[citetitle]{labeltitle}}%
{\multicitedelim}%
{\usebibmacro{postnote}}
\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: (cf. \citetitle[\emph{ML:}][]{ml:thermoskanne}, 234).
And this is what it looks like right now: \parencitetitle[cf.][234]{ml:thermoskanne}.
\parencitetitle[cf.][234]{ml:thermoskanne}
\parencitetitle[cf.][]{ml:thermoskanne}
\parencitetitle[234]{ml:thermoskanne}
\parencitetitle{ml:thermoskanne}
\printbibliography
\end{document}
编辑
我认为间距问题已经修复!