![biblatex 参照内の serie の後のスペースを削除する](https://rvso.com/image/370298/biblatex%20%E5%8F%82%E7%85%A7%E5%86%85%E3%81%AE%20serie%20%E3%81%AE%E5%BE%8C%E3%81%AE%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B%20.png)
私は修士論文用に 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))。2 番目にはシリーズがあります。ただし、閉じ括弧の前には不要なスペースがあります。
答え1
非常に重要な%
after を忘れました\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 は、そのためにローカライズされた bibstrings を提供しており、これも拡張可能です。また、既存のマクロを再定義するには、 を使用することをお勧めします\renewbibmacro
。