1

I've customised the formatting of some bibliography entry types using biblatex. For reasons unknown, the first line of each customised entry type within the bibliography is slightly indented relative to the adjacent un-customised entry types. An example of this is shown below:

enter image description here

Here is an MWE which recreates the above output:

\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}

Do I need to explicitly define a biliography environment using \defbibenvironment{bibliography} and then adjust \setlength, \itemindent, and \leftmargin to rectify these indentations?

Thanking you in advance,

Baldwin

Baldwin
  • 667

1 Answers1

3

You are missing some % in your redefinitions.

It should be

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

and

\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}

Otherwise LaTeX inserts these unwanted spaces at the beginning of an @image entry (which is what you noticed) even though biblatex goes to great lengths to avoid superfluous whitespaces.

See also What is the use of percent signs (%) at the end of lines?.

Note that it should not be necessary to set \bibitemsep and \bibhang manually, biblatex does a good job finding the right values itself.

moewe
  • 175,683