自定义 BibLaTeX 书目条目略微缩进

自定义 BibLaTeX 书目条目略微缩进

我使用 自定义了一些参考书目条目类型的格式biblatex。由于未知原因,参考书目中每个自定义条目类型的第一行相对于相邻的非自定义条目类型略有缩进。下面显示了一个示例:

在此处输入图片描述

以下是重新创建上述输出的 MWE:

\documentclass[12pt,a4paper,oneside]{report}

\usepackage{filecontents}
\usepackage[
hyperref=true,
firstinits=true, % render first and middle names as initials
maxcitenames=3,
maxbibnames=99,
style=authoryear,
dashed=false, % re-print recurring author names in bibliography
natbib=true,
useprefix=true, % for inclusion of 'de' 'da' in surname
url=false,
urldate=long,
backend=biber
]{biblatex}



% No unit separator after publication year:
\usepackage{xpatch}\xapptobibmacro{date+extrayear}{\nopunct}{}{}

% No month for publication year:
\AtEveryBibitem{\clearfield{month}}

% Use single quotes around titles:
\usepackage[british]{babel}
\usepackage{csquotes}

\DeclareNameAlias{author}{last-first}
%\renewcommand*{\mkbibnamefirst}[1]{{\let~\,#1}} % insert thin spaces between author initials
%\renewcommand*{\bibnamedelimd}{\addlpthinspace} % insert thin spaces between author initials
\renewcommand*{\bibinitdelim}{} % no spaces between author initials (requires biber)
\renewcommand*{\nameyeardelim}{\addcomma\addspace} % insert a comma between author and year in-text citations
\renewcommand*{\newunitpunct}{\addcomma\addspace} % comma as separator in bibliography, not full stop
\renewbibmacro{in:}{} % remove 'in:' preceding article title

% Place volume number within parentheses:
\renewbibmacro*{volume+number+eid}{
    \printfield{volume}
    \setunit*{\addnbspace}% NEW (optional); there's also \addnbthinspace
    \printfield{number}
    \setunit{\addcomma\space}
    \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

% Spacing in bibliography:
\setlength{\bibitemsep}{12pt}
\setlength{\bibhang}{16pt}% the hanging indent

\DeclareFieldFormat{year}{\mkbibparens{#1}}
\DeclareFieldFormat{type}{\mkbibbrackets{#1}}
\DeclareFieldFormat{url}{Available at: \url{#1}}

% Customised `image' entry:
\DeclareBibliographyDriver{image}{
    \printnames{author}
    \newblock
    \printfield{year}
    \newblock
    \printfield{title}
    \newblock
    \printfield{type}
    \addperiod\newunit\newblock
    \printlist{publisher}
    \newblock
    \printfield{url}
    \newblock
    \printfield{addendum}
\finentry}



\begin{filecontents}{\jobname.bib}

@Article{Example_Article_1,
  Title                    = {Title 1},
  Author                   = {Smith, A. B. and Jones, D. C.},
  Year                     = {2012},
  Month                    = {Oct},
  Number                   = {1},
  Pages                    = {42},
  Volume                   = {10},
  Journal                  = {Example Journal},
}

@Article{Example_Article_2,
  Title                    = {Title 2},
  Author                   = {Smith, A. B. and Jones, D. C.},
  Year                     = {2012},
  Month                    = {Oct},
  Number                   = {1},
  Pages                    = {42},
  Volume                   = {10},
  Journal                  = {Example Journal},
}

@Image{Example_Image_1,
  Title                    = {Title 1},
  Url                      = {example.com},
  Addendum                 = {(Accessed: 1 January 2013)},
  Type                     = {Photograph},
  Author                   = {Doe, J. D.},
  Year                     = {2009},
}

@Image{Example_Image_2,
  Title                    = {Title 2},
  Url                      = {example.com},
  Addendum                 = {(Accessed: 2 January 2013)},
  Type                     = {Photograph},
  Author                   = {Doe, J. D.},
  Year                     = {2009},
}

\end{filecontents}


\addbibresource{\jobname.bib}


\begin{document}

\printbibliography[title=References]

\end{document}

我是否需要使用 明确定义书目环境\defbibenvironment{bibliography},然后调整\setlength\itemindent\leftmargin来纠正这些缩进?

提前感谢您,

鲍德温

答案1

您的重新定义遗漏了一些内容%

它应该是

\renewbibmacro*{volume+number+eid}{%
    \printfield{volume}%
    \setunit*{\addnbspace}% NEW (optional); there's also \addnbthinspace
    \printfield{number}%
    \setunit{\addcomma\space}%
    \printfield{eid}}

\DeclareBibliographyDriver{image}{%
    \printnames{author}%
    \newblock
    \printfield{year}%
    \newblock
    \printfield{title}%
    \newblock
    \printfield{type}%
    \addperiod\newunit\newblock
    \printlist{publisher}%
    \newblock
    \printfield{url}%
    \newblock
    \printfield{addendum}%
\finentry}

否则,LaTeX 会在条目开头插入这些不需要的空格@image(这就是您所注意到的),尽管biblatex会竭尽全力避免多余的空格。

也可以看看行末百分号(%)有什么用?

请注意,不需要手动设置\bibitemsep\bibhangbiblatex可以很好地自行找到正确的值。

相关内容