它看起来应该是这样的:
盖茨,比尔和梅琳达·盖茨基金会,2018年5月4日,“拯救世界……”
如果技术上可行,则“...”应该出现在 3 或 4 个单词之后。
我怎样才能做到这一点?
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{gates,
author = {Bill Gates},
title = {Save the world!},
url = {https://www.gatesfoundation.org/de/},
date = {2016-07-04},
organization = {Bill and Melinda Gates Foundation},
}
\end{filecontents*}
\documentclass{article}
\usepackage[style=verbose]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\footcite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \footcite{gates}
\printbibliography
\end{document}
答案1
类似地自定义类型在后续引用中消失您需要分支代码以cite:short
获得不同的条目格式@online
。可以在字段中指定标题的简短版本shorttitle
。但这需要手动干预,使用 Biber 的源映射,您可以自动执行此操作。我强烈建议在这种情况下仔细检查输出,因为代码非常简单,在第三个单词处截断了所有内容。
MWE 建立在以下代码之上:使用 biblatex 将日期移到参考书目中的标题之前使完整引用的输出与简短引用的样式相匹配。
\documentclass{article}
\usepackage[style=verbose, autocite=footnote]{biblatex}
\DeclareFieldFormat[online]{shorttitle}{\mkbibquote{#1\dots\isdot}}
\newbibmacro*{cite:short:online}{%
\printnames{labelname}%
\setunit{\addcomma\space}%
\printlist{organization}%
\setunit{\addcomma\space}%
\printdate
\setunit{\addcomma\space}%
\printtext[bibhyperlink]{%
\iffieldundef{shorttitle}
{\printfield[citetitle]{labeltitle}}
{\printfield{shorttitle}}}}
% cite:short is really 'cite:subsequent'
\renewbibmacro*{cite:short}{%
\ifbibmacroundef{cite:short:\strfield{entrytype}}
{\printnames{labelname}%
\setunit*{\printdelim{nametitledelim}}%
\printtext[bibhyperlink]{%
\printfield[citetitle]{labeltitle}}}
{\usebibmacro*{cite:short:\strfield{entrytype}}}}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=false]{
\step[fieldsource=title, match=\regexp{\A(\w+\s+){2}(\w+)}, final]
\step[fieldset=shorttitle, origfieldval, final]
\step[fieldsource=shorttitle, match=\regexp{\A(\w+\s+)(\w+\s+)(\w+).*}, replace={$1$2$3}]
}
}
}
\DefineBibliographyStrings{english}{
urlseen = {visited at}
}
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}
\DeclareListWrapperFormat{organization}{\mkbibemph{#1}}
\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\newunit\newblock
\printlist{organization}%
\newunit\newblock
\usebibmacro{date}%
\newunit\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\usebibmacro{url+urldate}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{gates,
author = {Bill Gates},
title = {Save the world!},
url = {https://www.gatesfoundation.org/de/},
urldate = {2016-07-04},
organization = {{Bill and Melinda Gates Foundation}},
}
@online{gates2,
author = {Bill Gates},
title = {Save the moon with even longer titles},
shorttitle = {Save the moon},
date = {2016-05-04},
url = {https://www.gatesfoundation.org/de/},
urldate = {2016-07-04},
organization = {Bill {and} Melinda Gates Foundation},
}
@online{ex:one,
author = {Anne Elk},
title = {One},
url = {https://example.com/~elk/1},
}
@online{ex:two,
author = {Anne Elk},
title = {Two Words},
url = {https://example.com/~elk/2},
}
@online{ex:three,
author = {Anne Elk},
title = {Three Words Title},
url = {https://example.com/~elk/3},
}
@online{ex:four,
author = {Anne Elk},
title = {Four Words in Title},
url = {https://example.com/~elk/4},
}
@online{ex:five,
author = {Anne Elk},
title = {Five Words in a Title},
url = {https://example.com/~elk/5},
}
@online{ex:long,
author = {Anne Elk},
title = {This Title Is Very Long to Test the Feature},
url = {https://example.com/~elk/long},
}
@online{ex:override,
author = {Anne Elk},
title = {A Long Title That Will Be Overridden},
shorttitle = {A Different Title},
url = {https://example.com/~elk/over},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\autocite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \autocite{gates2}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\autocite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \autocite{gates2}
Lorem\autocite{ex:one} ipsum\autocite{ex:one}.
Lorem\autocite{ex:two} ipsum\autocite{ex:two}.
Lorem\autocite{ex:three} ipsum\autocite{ex:three}.
Lorem\autocite{ex:four} ipsum\autocite{ex:four}.
Lorem\autocite{ex:five} ipsum\autocite{ex:five}.
Lorem\autocite{ex:override} ipsum\autocite{ex:override}.
Lorem\autocite{ex:long} ipsum\autocite{ex:long}.
\printbibliography
\end{document}
在match
– replace
RegExp 中,我使用了简单的
match=\regexp{\A(\w+\s+)(\w+\s+)(\w+).*}, replace={$1$2$3}
如果你想要一个更复杂、更容易扩展的解决方案,你可以尝试
match=\regexp{\A((?:\w+\s+){2})(\w+).*}, replace={$1$2}
其中((?:\w+\s+){2})
捕获前两个单词和(\w+)
后面的一个单词。