如何在 BibLaTeX 中的“ed. by”后添加不间断空格?

如何在 BibLaTeX 中的“ed. by”后添加不间断空格?

我尝试过这个:

\DefineBibliographyStrings{english}{%
  byeditor={ed.~by\penalty10000},
}

但它不起作用。还有其他想法吗?

答案1

假设您使用的是标准样式之一,除了重新定义字符串之外,还需要更改三个不同的宏:byeditorbyeditor+othersbyeditorx。在这三个宏中,我们需要将字符串byeditor和之间的分隔符editor(通常是\addspace)替换为不间断空格(\addnbspace)。

请注意,您可能需要对三个类似的翻译器宏执行类似的操作。

展示这个工作原理有点困难,但请尝试以下示例:

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\DefineBibliographyStrings{english}{%
  byeditor = {ed\adddot\addnbspace by},
}

\renewbibmacro*{byeditor}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{bytypestrg}{editor}{editor}%
     \setunit{\addnbspace}%
     \printnames[byeditor]{editor}%
     \newunit}%
  \usebibmacro{byeditorx}}

\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{byeditor+othersstrg}%
     \setunit{\addnbspace}%
     \printnames[byeditor]{editor}%
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\renewbibmacro*{byeditorx}{%
  \ifnameundef{editora}
    {}
    {\usebibmacro{bytypestrg}{editora}{editor}%
     \setunit{\addnbspace}%
     \printnames[byeditora]{editora}%
     \newunit}%
  \ifnameundef{editorb}
    {}
    {\usebibmacro{bytypestrg}{editorb}{editor}%
     \setunit{\addnbspace}%
     \printnames[byeditorb]{editorb}%
     \newunit}%
  \ifnameundef{editorc}
    {}
    {\usebibmacro{bytypestrg}{editorc}{editor}%
     \setunit{\addnbspace}%
     \printnames[byeditorc]{editorc}%
     \newunit}}

\begin{document}
\nocite{aristotle:anima,gaonkar:in,salam}
\parbox{5cm}{%
  \printbibliography}
\end{document}

无中断输出

为了进行比较,以下是没有重新定义字符串和宏的输出:

中断输出

相关内容