平均能量损失

平均能量损失

biblatex\shorthandwidth根据shorthand简写列表中包含的所有字段的最大长度自动计算。

我怎样才能从该计算中排除除一种之外的所有条目类型?

笔记:我不想使用该skipbiblist选项,因为这会将该条目从简写列表中完全删除,而我不希望发生这种情况。

(最终目标是正确计算组合缩写列表中所有缩写的宽度。许多条目类型都有shorttitle字段,但我只希望此字段包含在缩写列表中条目类型。因此,我只希望这些条目类型有助于计算\shorttitlewidth,而计算的结果又将用于计算最大缩写宽度。skipbiblist不能使用该选项的原因是因为其他带有的条目类型shorttitle可能仍需要出现在不同标签字段下的缩写列表中。这个问题简化为只需担心shorthand。欢迎提出其他不具体回答这个问题的一般问题的解决方案。)

平均能量损失

在下面的 MWE 中,我想排除除@book计算之外的所有条目类型,而\shorthandwidth无需(必然)从简写列表中排除其他条目。

\documentclass{article}

\begin{filecontents}[overwrite]{\jobname.bib}
@book{test,
  shorthand = {Foo},
  author = {Author},
  title = {Title},
  date = {2020}
}
@misc{test2,
  shorthand = {FooBar},
  author = {Author},
  title = {Foo Bar Title},
  date = {2020}
}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\verb+\the\shorthandwidth+: \the\shorthandwidth

goal for \verb+\the\shorthandwidth+: 21.52785pt (exclude \texttt{@book} entry
type).

\printbiblist{shorthand}
\end{document}

答案1

如果您不打算在简写列表中打印shorthand那些不应该测量的条目,则可以将shorthandwidth字段格式设置为空,并仅为条目设置所需的格式@book

\documentclass{article}

\usepackage{biblatex}

\DeclareFieldFormat{shorthandwidth}{}
\DeclareFieldFormat[book]{shorthandwidth}{#1}

\begin{filecontents}{\jobname.bib}
@book{test,
  shorthand = {Foo},
  author    = {Author},
  title     = {Title},
  date      = {2020},
}
@misc{test2,
  shorthand = {FooBar},
  author    = {Author},
  title     = {Foo Bar Title},
  date      = {2020},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\verb+\the\shorthandwidth+: \the\shorthandwidth

goal for \verb+\the\shorthandwidth+: 21.52785pt (exclude \texttt{@book} entry
type).

\printbiblist{shorthand}
\end{document}

\the\shorthandwidth:15.97227pt

如果您仍想打印shorthand所有条目,您可以重新定义shorthand参考书目环境。

\documentclass{article}

\usepackage{biblatex}

\DeclareFieldFormat{shorthandwidth}{}
\DeclareFieldFormat[book]{shorthandwidth}{#1}

\DeclareFieldFormat{shorthandprint}{#1}

\defbibenvironment{shorthand}
  {\list
     {\printfield[shorthandprint]{shorthand}}
     {\setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\begin{filecontents}{\jobname.bib}
@book{test,
  shorthand = {Foo},
  author    = {Author},
  title     = {Title},
  date      = {2020},
}
@misc{test2,
  shorthand = {FooBar},
  author    = {Author},
  title     = {Foo Bar Title},
  date      = {2020},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\verb+\the\shorthandwidth+: \the\shorthandwidth

goal for \verb+\the\shorthandwidth+: 21.52785pt (exclude \texttt{@book} entry
type).

\printbiblist{shorthand}
\end{document}

答案2

使用\llap会将条目排除在计算之外。它会在缩写周围加上奇怪的括号,但据我了解,您可以使用不带括号的样式。

\documentclass{article}

\begin{filecontents}[overwrite]{\jobname.bib}
@book{test,
  shorthand = {Foo},
  author = {Author},
  title = {Title},
  date = {2020}
}
@misc{test2,
  shorthand = {\llap{FooBar}},
  author = {Author},
  title = {Foo Bar Title},
  date = {2020}
}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\verb+\the\shorthandwidth+: \the\shorthandwidth

goal for \verb+\the\shorthandwidth+: 21.52785pt (exclude \texttt{@misc} entry
type).

\printbiblist{shorthand}
\end{document}

在此处输入图片描述

相关内容