当我尝试进行所有格引用时,出于某种原因,引用前的字符之间会创建 2 个空格,而不是 1 个。你知道我该如何解决这个问题吗?(在文本中不写一个空格可能会有点麻烦,因为我必须记住这一点才能进行所有格引用)
\documentclass[
12pt,
a4paper,
headings=standardclasses,
listof=totoc,
numbers=noenddot
]{scrartcl}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
%----------------------------------------------------------------------------
% BIB
%----------------------------------------------------------------------------
\usepackage[
backend=biber,
style=ext-authoryear,
sorting=nyvt,
datamodel=customstyles,
maxnames=25,
innamebeforetitle=true,
usetranslator=true,
alldates=terse,
labeldate=year,
dashed=false,
doi=false,
isbn=false
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage[hidelinks, pdfencoding=auto]{hyperref}
\DeclareDelimFormat[bib]{nametitledelim}{\addcolon\space}
% possessive citing
\DeclareNameFormat{labelname:poss}{ % based on labelname from biblatex.def
\nameparts{#1} % not needed if using Biblatex 3.4
\ifcase\value{uniquename}%
\usebibmacro{name:family}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefix}{\namepartsuffixi}}
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefixi}{\namepartsuffixi}}%
\or
\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\fi
\usebibmacro{name:andothers}%
\ifnumequal{\value{listcount}}{\value{liststop}}{s}{}}
\DeclareFieldFormat{shorthand:poss}{%
\ifnameundef{labelname}{#1s}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}s}
\DeclareFieldFormat{label:poss}{#1s}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameAlias{labelname}{labelname:poss}%
\DeclareFieldAlias{shorthand}{shorthand:poss}%
\DeclareFieldAlias{citetitle}{citetitle:poss}%
\DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
%--------------------------------------------------------------------
% MAIN
%--------------------------------------------------------------------
\begin{filecontents}{\jobname.bib}
@report{Chafe.1974,
author = {Chafe, Wallace L.},
title = {An Approach to Verbalization and Translation by Machine. Final Report},
month = {10},
year = {1974},
institution = {{California University, Berkely}},
address = {New York}
}
\end{filecontents}
\begin{document}
In \posscite{Chafe.1974} Werk XYZ.
\clearpage
\printbibheading[heading=bibintoc,title={Literaturverzeichnis}]
\printbibliography
\end{document}
答案1
与许多涉及额外空格的问题一样,如果宏定义生成可打印的文本,则需要非常小心,不要在宏定义中的行尾留有空格。行尾被视为空格。因此,您需要删除命令%
前两行中注释标记前的空格\DeclareNameFormat
:
\DeclareNameFormat{labelname:poss}{% based on labelname from biblatex.def
\nameparts{#1}% not needed if using Biblatex 3.4
您可能还应该%
在此行后面添加:
\ifuseprefix
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefix}{\namepartsuffixi}}% <--- added
完整代码:
\documentclass[
12pt,
a4paper,
headings=standardclasses,
listof=totoc,
numbers=noenddot
]{scrartcl}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
%----------------------------------------------------------------------------
% BIB
%----------------------------------------------------------------------------
\usepackage[
backend=biber,
style=ext-authoryear,
sorting=nyvt,
datamodel=customstyles,
maxnames=25,
innamebeforetitle=true,
usetranslator=true,
alldates=terse,
labeldate=year,
dashed=false,
doi=false,
isbn=false
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage[hidelinks, pdfencoding=auto]{hyperref}
\DeclareDelimFormat[bib]{nametitledelim}{\addcolon\space}
% possessive citing
\DeclareNameFormat{labelname:poss}{% based on labelname from biblatex.def
\nameparts{#1}% not needed if using Biblatex 3.4
\ifcase\value{uniquename}%
\usebibmacro{name:family}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefix}{\namepartsuffixi}}%
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefixi}{\namepartsuffixi}}%
\or
\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\fi
\usebibmacro{name:andothers}%
\ifnumequal{\value{listcount}}{\value{liststop}}{s}{}}
\DeclareFieldFormat{shorthand:poss}{%
\ifnameundef{labelname}{#1s}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}s}
\DeclareFieldFormat{label:poss}{#1s}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameAlias{labelname}{labelname:poss}%
\DeclareFieldAlias{shorthand}{shorthand:poss}%
\DeclareFieldAlias{citetitle}{citetitle:poss}%
\DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
%--------------------------------------------------------------------
% MAIN
%--------------------------------------------------------------------
\begin{filecontents}{\jobname.bib}
@report{Chafe.1974,
author = {Chafe, Wallace L.},
title = {An Approach to Verbalization and Translation by Machine. Final Report},
month = {10},
year = {1974},
institution = {{California University, Berkely}},
address = {New York}
}
\end{filecontents}
\begin{document}
In \posscite{Chafe.1974} Werk XYZ.
\clearpage
\printbibheading[heading=bibintoc,title={Literaturverzeichnis}]
\printbibliography
\end{document}
答案2
艾伦·芒恩的回答就文档中虚假空格的来源而言,这是正确的,但我想提供一个略有不同的答案,我们使用新的名称包装器格式来缩短代码。
我们可以避免使用整个\DeclareNameFormat{labelname:poss}
代码块,而是有效地用它替换\DeclareNameWrapperFormat{labelname:poss}{#1s}
并在以后使用。请注意,在下面的示例中,我使用了略有不同的构造,以使代码更加紧凑。
\documentclass{scrartcl}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[
backend=biber,
style=ext-authoryear,
]{biblatex}
\usepackage[hidelinks, pdfencoding=auto]{hyperref}
\DeclareDelimFormat[bib]{nametitledelim}{\addcolon\space}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameWrapperFormat{labelname}{##1s}%
\DeclareFieldFormat{label}{##1s}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
\begin{filecontents}{\jobname.bib}
@report{Chafe.1974,
author = {Chafe, Wallace L.},
title = {An Approach to Verbalization and Translation by Machine. Final Report},
month = {10},
year = {1974},
institution = {California University, Berkely},
address = {New York},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
In \posscite{Chafe.1974} Werk \citetitle{Chafe.1974}.
In \posscite{sigfridsson} Werk \citetitle{sigfridsson}.
In \posscite{ctan} Werk XYZ \citetitle{ctan}.
\printbibliography[heading=bibintoc,title={Literaturverzeichnis}]
\end{document}