在 \newrefsection 重置 \shorthandwidth

在 \newrefsection 重置 \shorthandwidth

编辑找到了答案,见下文。

编辑2\setlength{\shorthandwidth}{0pt}不幸的是,我直接调用的解决方案\newrefsection没有按预期工作——它只是将\shorthandwidth整个文档设置为 0。


我目前正在排版一本包含多个参考节的书。不幸的是,biblatex 似乎只对整个文档进行\shorthandwidth一次计算,这导致文档中某些速记节的速记标签和书目条目之间存在巨大的差距(见图)。

是否可以重置\shorthandwidth\newrefsection让 biblatex\shorthandwidth为每个参考部分重新计算?

\documentclass{article}

\usepackage{fontspec}
\usepackage[style=authoryear, backend=biber]{biblatex}

\begin{filecontents*}{problematic.bib}
  @book{short,
    author = {Knuth, Donald E.},
    year = {1986},
    title = {The \TeX book},
    shorthand = {TTB}
  }

  @book{long,
    author = {Atkins, Tom},
    year = {2016},
    title = {Problematically Long Shorthands},
    shorthand = {PrblmtcllLngShrthnds}
  }
\end{filecontents*}

\addbibresource{problematic.bib}

\begin{document}

Text. \cite{long}

\printshorthands

\newrefsection

Text. \cite{short}

\printshorthands

\end{document}

答案1

对于你的例子来说,这有效……但我必须承认我不知道为什么。我基本上是在尝试获取\shorthandwidth每个的不同值时偶然发现它的refsection

鉴于此,请务必仔细检查是否有不良副作用。

\documentclass{article}

\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{short,
  author = {Knuth, Donald E.},
  year = {1986},
  title = {The \TeX book},
  shorthand = {TTB}
}
@book{long,
  author = {Atkins, Tom},
  year = {2016},
  title = {Problematically Long Shorthands},
  shorthand = {PrblmtcllLngShrthnds}
}
@book{mid,
  author = {Author, Some},
  year = {2016},
  title = {Mid length Shorthands},
  shorthand = {MLShrthnds}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\pagestyle{empty}

\makeatletter
\def\blx@bbl@labelfields{%
  \def\do##1{%
    \ifcsundef{abx@field@##1}
      {}
      {\ifcsundef{##1@\the\c@refsection @width}
         {\expandafter\newlength\expandafter{\csname ##1@\the\c@refsection
          @width\endcsname}}
         {}%
       \blx@setlabwidth{\csname ##1@\the\c@refsection @width\endcsname}{%
         \csuse{abx@ffd@*@##1@\the\c@refsection @width}{%
         \csname abx@field@##1\endcsname}}}}%
  \abx@dolabelfields}

\defbibenvironment{shorthand}
  {\list
     {\printfield[shorthandwidth]{shorthand}}
     {\setlength{\labelwidth}{%
        \csname shorthand@\the\c@refsection @width\endcsname}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}
\makeatother

\begin{document}

Text. \cite{short}

\printshorthands

\newrefsection

Text. \cite{long}
Text. \cite{mid}

\printshorthands

\newrefsection

Text. \cite{short}
Text. \cite{mid}

\printshorthands

\end{document}

在此处输入图片描述

相关内容