biblatex 删除参考文献中的系列后的空格

biblatex 删除参考文献中的系列后的空格

我正在通过自定义我的硕士论文的 standard.bbx 文件来创建新的参考书目样式。到目前为止,我没有遇到什么大麻烦,但现在我想调整宏系列号,因为这应该放在括号中。由于缺乏信息,我有时只有一个系列号或数字。

到目前为止,效果还不错,除非我只有系列。然后系列的最后一个单词和右括号之间会出现一个空格。

这是我的新宏

\newbibmacro*{series+number}{%
    \iffieldundef{series}% Überprüfen ob series vorhanden
        {}
        {   \setunit{\addspace\bibopenparen}
            \printtext{Reihe \addcolon\space}%
            \printfield{series}
            \iffieldundef{number} % Überprüfen ob noch Bd kommt
                {\printtext{\bibcloseparen}}
                {\setunit{\addcomma\space}}
        }%
    \iffieldundef{number}%
        {}
        {   \iffieldundef{series}%
                {\setunit{\addspace\bibopenparen}}
                {}
            \printtext{Bd \adddot}
            \printfield{number}%
            \printtext{\bibcloseparen\space}
        }
  \newunit}

这是 MWE

\RequirePackage{filecontents}

\begin{filecontents*}{my_bibfile.bib}
    @incollection{Akyar.2008,
        author = {Akyar, Bedia},
        title = {Dual Quaternions in Spatial Kinematics in an Algebraic Sense},
        pages = {373--391},
        bookpagination = {page},
        publisher = {T{\"u}bitak},
        isbn = {1010-7622},
        editor = {{Scientific and Technological Research Council of Turkey}},
        booktitle = {Turkish journal of mathematics},
        year = {2008},
        abstract = {},
        shorthand = {AKYA08},
        location = {Ankara},
        edition = {32},
        number = {4}
    }

    @book{Angeles.2007,
        author = {Angeles, Jorge},
        year = {2007},
        title = {Fundamentals of Robotic Mechanical Systems},
        url = {http://site.ebrary.com/lib/alltitles/docDetail.action?docID=10229254},
        edition = {Third Edition},
        publisher = {{Springer Science+Business Media LLC}},
        isbn = {0-387-29412-0},
        subtitle = {Theory, Methods, and Algorithms},
        shorthand = {ANGE07},
        language = {eng},
        location = {Boston, MA, USA},
        series = {Mechanical Engineering Series},
        abstract = {},
        doi = {10.1007/978-0-387-34580-2},
        file = {http://gso.gbv.de/DB=2.1/PPNSET?PPN=546653987},
        file = {http://external.dandelon.com/download/attachments/dandelon/ids/DEAGI363052149B0CFDDDC125715B0045ACDA.pdf},
        file = {http://zbmath.org/?q=an:1140.70001}
    }
\end{filecontents*}

\documentclass[fleqn]{scrreprt}

\usepackage[scaled]{helvet}
\renewcommand{\familydefault}{\sfdefault} 
\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}

\usepackage[style=alphabetic, % Use this style 
isbn=false,
doi=false,
url=false,
maxbibnames = 4,
minbibnames = 3,
language = ngerman,
giveninits=true]{biblatex}


\bibliography{my_bibfile}

\begin{document}

\nocite{*}

\printbibliography

\end{document}

第一个参考文献只有一个数字(这里(Bd. 4))。第二个参考文献有一个序列。但是在结束括号之前有一个不必要的空格。

在此处输入图片描述

答案1

%您忘记了后面一个非常重要的空格\printfield{series}。将其添加到宏中,可以消除不需要的空格:

\renewbibmacro*{series+number}{%
    \iffieldundef{series}% Überprüfen ob series vorhanden
        {}
        {   \setunit{\addspace\bibopenparen}
            \printtext{Reihe \addcolon\space}%
            \printfield{series}% <- here
            \iffieldundef{number} % Überprüfen ob noch Bd kommt
                {\printtext{\bibcloseparen}}
                {\setunit{\addcomma\space}}
        }%
    \iffieldundef{number}%
        {}
        {   \iffieldundef{series}%
                {\setunit{\addspace\bibopenparen}}
                {}
            \printtext{Bd \adddot}
            \printfield{number}%
            \printtext{\bibcloseparen\space}
        }
  \newunit}

上面的版本强调了生成不需要的空格的点。但事实上,您的代码还有其他潜在的不需要的空格实例。下面的版本是我放置尾随%以避免宏中出现不需要的空格的地方:

\renewbibmacro*{series+number}{%
    \iffieldundef{series} % Überprüfen ob series vorhanden
        {}
        {\setunit{\addspace\bibopenparen}%
         \printtext{Reihe\addcolon\space}%
         \printfield{series}%
         \iffieldundef{number} % Überprüfen ob noch Bd kommt
             {\printtext{\bibcloseparen}}
             {\setunit{\addcomma\space}}%
        }%
    \iffieldundef{number}
        {}
        {\iffieldundef{series}
             {\setunit{\addspace\bibopenparen}}
             {}%
         \printtext{Bd\adddot}%
         \printfield{number}%
         \printtext{\bibcloseparen\space}%
        }%
  \newunit}

我必须补充一点,将字符串“Reihe”和“Bd”硬编码到宏中可能会让人不悦。Biblatex 提供了本地化的 bibstring,它们也是可扩展的。此外,要重新定义现有宏,您应该使用\renewbibmacro

相关内容