Biblatex 格式 - 删除初始之前集合中的多余空间

Biblatex 格式 - 删除初始之前集合中的多余空间

速成课程之后这里关于 biblatex 格式,以及通读 biblatex 文档,我无法删除“in”和编辑器列表之间的额外空格。

格式要求来自国际生产力与绩效管理杂志

我猜我遗漏了一些显而易见的东西。在下面的例子中,我省略了几行以集中精力解决“in”的问题。任何帮助都将不胜感激!

梅威瑟:

\documentclass[12pt]{article}

\usepackage[
backend=biber,
style=authoryear,
uniquename=false,
dashed=false,
natbib=true,
url=false, 
doi=true,
eprint=false,
giveninits=true,
maxcitenames=2,
maxbibnames=99]{biblatex}

 \begin{filecontents}{\jobname.bib}

@INCOLLECTION{Vo2005,
author = {Vo, Huy V and Poole, Marshall Scott and Courtney, James F},
title = {An empirical comparison of collective causal mapping approaches},
booktitle = {Causal Mapping for Research in Information and Technology},
publisher = {Idea Group Publishing, Hershey, PA},
year = {2005},
editor = {Narayanan, V.K. and Armstrong, D.J.},
pages = {142--173},
address = {Hershey, PA}}

@INCOLLECTION{test2007,
author = {McTesty, Test},
title = {The title of the work},
booktitle = {The name of the collection},
publisher = {The publisher},
year = {2007},
editor = {Editor1, M.G. and Editor2, M.A.},
pages = {142--173},
address = {Hershey, PA}
 }
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}

\renewcommand*{\intitlepunct}{}
% remove 'in:' preceding article title
\renewbibmacro{in:}{% suppresses “In:” …
\iffieldequalstr{entrytype}{incollection}
  {\printtext{in}}
  {}
}

\renewbibmacro*{editorstrg}{%from biblatex.def
\printtext[editortype]{%
\iffieldundef{editortype}
  {\ifboolexpr{
     test {\ifnumgreater{\value{editor}}{1}}
     or
     test {\ifandothers{editor}}
   }
     {\bibcpstring{editors}}%
     {\bibcpstring{editor}}}%
  {\ifbibxstring{\thefield{editortype}}
     {\ifboolexpr{
        test {\ifnumgreater{\value{editor}}{1}}
        or
        test {\ifandothers{editor}}
      }
        {\bibcpstring{\thefield{editortype}s}}%
        {\bibcpstring{\thefield{editortype}}}}%
     {\thefield{editortype}}}}}

 \renewbibmacro*{byeditor+others}{%from biblatex.def  
\ifnameundef{editor}
{}
{
 \printnames[byeditor]{editor}%
 \addspace
 \mkbibparens{\usebibmacro{editorstrg}}%
 \clearname{editor}%
 \newunit}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}}

 %Here is where the trouble begins
 \DeclareBibliographyDriver{incollection}{%from standard.bbx
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\setunit{}\newblock
\newunit\newblock
\usebibmacro{in:} %Here is the source of some of my suffering
\usebibmacro{byeditor+others}
\setunit{\addcomma\addspace}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
 \printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
 \usebibmacro{related}}
{}%
\usebibmacro{finentry}}

\begin{document}
\begingroup
    \setlength\bibitemsep{5pt}
    \printbibliography
\endgroup
\end{document}  

答案1

您缺少一些 % 注释,这意味着插入了额外的空格:

\renewbibmacro{in:}{% suppresses “in:” …
\iffieldequalstr{entrytype}{incollection}
  {\printtext{in}}
  {}% <- add this
}

这里还有一个。另外,您不应该\addspace直接使用,因为它可能会弄乱标点符号跟踪——而是将其放在 a 中\setunit。您也不应该\mkbibparens直接在宏中使用。而是使用\printtext[parens]{…}

\renewbibmacro*{byeditor+others}{%from biblatex.def  
\ifnameundef{editor}
{}
{% <- add this
 \printnames[byeditor]{editor}%
 \setunit{\addspace}% <- you should use \setunit here
 \printtext[parens]{\usebibmacro{editorstrg}}% <- change this line
 \clearname{editor}%
 \newunit}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}}

主驱动程序也存在问题:

\DeclareBibliographyDriver{incollection}{%from standard.bbx
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\setunit{}\newblock% <- this line is not doing anything, by the way
\newunit\newblock
\usebibmacro{in:}% (remove space before %) Here is the source of some of my suffering
\setunit{\addspace}% <- add this line
\usebibmacro{byeditor+others}
\setunit{\addcomma\addspace}\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
 \printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
 \usebibmacro{related}}
{}%
\usebibmacro{finentry}}

另外,标题后面有一个句号,然后是小写字母。这是你的本意吗?看起来有点搞笑。你可以这样做:

\renewbibmacro{in:}{% suppresses “in:” …
\iffieldequalstr{entrytype}{incollection}
  {\bibstring{in}}% <- change this line
  {}% <- add this
}

这是最终的图像:

在此处输入图片描述

相关内容