1

I have received a great customized code for my bibliography and it's great but now (suddenly?) there are big spaces in front of the year in the bibliography (biblatex). How can I get rid of those?

\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{caption}
\usepackage{filecontents}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{CJKutf8}
\usepackage[footnote,printonlyused]{acronym}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,ngerman]{babel}
\usepackage{tipa}
\usepackage{csquotes}

\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}
\addbibresource{graphematik.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{\iffieldundef{\thefield{datelabelsource}year}{}{\printtext[parens]{ \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}      \iffieldsequal{year}{\thefield{datelabelsource}year}{\printdateextralabel}{\printfield{labelyear} \printfield{extrayear}}}}}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{\ifnameundef{editor}{}{\printnames[byeditor]{editor}\setunit{\addspace} \usebibmacro{byeditor+othersstrg}\clearname{editor}\newunit}\usebibmacro{byeditorx}  \usebibmacro{bytranslator+others}}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{\iffieldundef{#1type}{\bibstring{#2}}{\ifbibxstring{\thefield{#1type}}     {\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}}}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

\begin{document}

A book.\parencite[][]{altmann2010}
@Book{altmann2010,
  Title                    = {Prüfungswissen Phonetik, Phonologie und Graphemik. Arbeitstechniken – Klausurfragen – Lösungen},
  Author                   = {Altmann, Hans and Ziegenhain, Ute},
  Location                 = {Göttingen},
  Publisher                = {Vandenhoeck \& Ruprecht},
  Year                     = {2010},

  Edition                  = {3}
}

An article.\parencite[][]{berg2012}
@Article{berg2012,
  Title                    = {Identifying graphematic units. Vowel and consonant letters},
  Author                   = {Berg, Kristian},
  Journal                  = {Written Language \& Literacy},
  Pages                    = {26--45},
  Volume                   = {15},
  Year                     = {2012}
}

An inbook.\parencite[][]{fayol2014}

@Inbook{fayol2014,
  Title                    = {Written Language: Learning to Read and to Spell},
  Author                   = {Fayol, Michael},
  Booktitle                = {Manual of Language Acquisition (Manuals of Romance Linguistics 2)},
  Location                 = {Berlin/Boston},
  Pages                    = {162--178},
  Publisher                = {de Gruyter},
  Year                     = {2014},
  Editor                   = {Christiane Fäcke}
}

\printbibliography[heading=bibintoc]

\end{document}
Jagath
  • 4,287
LajosH
  • 379
  • This "compactified" version of the macro redefinitions can introduce spurious spaces, if you don't get rid of all white space. (Check also byeditor+others for example, it could be that some space is introduced there as well.) You can learn more about this and why there are so many %s in my original code in this question. This compact code format also has the huge drawback that it becomes much, much harder to understand what is actually going on. – moewe Jul 20 '16 at 08:08

1 Answers1

4

The problem is the space in the following line:

\renewbibmacro*{date+extrayear}{\iffieldundef{\thefield{datelabelsource}year}{}{\printtext[parens]{ \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}      \iffieldsequal{year}{\thefield{datelabelsource}year}{\printdateextralabel}{\printfield{labelyear} \printfield{extrayear}}}}}

i.e.

  1. \printtext[parens]{ and \iffieldnum{edition}
  2. \global\clearfield{edition}}{} and \iffieldsequal{year}

which should be closed up as:

\renewbibmacro*{date+extrayear}{%
  \iffieldundef{\thefield{datelabelsource}year}%
    {}{%
       \printtext[parens]{%
         \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
         \iffieldsequal{year}{\thefield{datelabelsource}year}%
           {\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
       }%
      }%
}

The corrected MWE:

\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{caption}
\usepackage{filecontents}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{CJKutf8}
\usepackage[footnote,printonlyused]{acronym}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,ngerman]{babel}
\usepackage{tipa}
\usepackage{csquotes}

\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}

\begin{filecontents}{graphematik.bib}
@Book{altmann2010,
  Title                    = {Prüfungswissen Phonetik, Phonologie und Graphemik. Arbeitstechniken  Klausurfragen  Lösungen},
  Author                   = {Altmann, Hans and Ziegenhain, Ute},
  Location                 = {Göttingen},
  Publisher                = {Vandenhoeck \& Ruprecht},
  Year                     = {2010},
  Edition                  = {3}
}

@Article{berg2012,
  Title                    = {Identifying graphematic units. Vowel and consonant letters},
  Author                   = {Berg, Kristian},
  Journal                  = {Written Language \& Literacy},
  Pages                    = {26--45},
  Volume                   = {15},
  Year                     = {2012}
}


@Inbook{fayol2014,
  Title                    = {Written Language: Learning to Read and to Spell},
  Author                   = {Fayol, Michael},
  Booktitle                = {Manual of Language Acquisition (Manuals of Romance Linguistics 2)},
  Location                 = {Berlin/Boston},
  Pages                    = {162--178},
  Publisher                = {de Gruyter},
  Year                     = {2014},
  Editor                   = {Christiane Fäcke}
}
\end{filecontents}

\addbibresource{graphematik.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{%
  \iffieldundef{\thefield{datelabelsource}year}%
    {}{%
       \printtext[parens]{%
         \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
         \iffieldsequal{year}{\thefield{datelabelsource}year}%
           {\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
       }%
      }%
}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
   {}{%
      \printnames[byeditor]{editor}%
      \setunit{\addspace}%
      \usebibmacro{byeditor+othersstrg}%
      \clearname{editor}\newunit%
   }%
   \usebibmacro{byeditorx}%
   \usebibmacro{bytranslator+others}%
}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{%
  \iffieldundef{#1type}{\bibstring{#2}}{%
    \ifbibxstring{\thefield{#1type}}%
      {\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}%
  }%
}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

\begin{document}

A book. \parencite[][]{altmann2010}

An inbook. \parencite[][]{fayol2014}

An article. \parencite[][]{berg2012}


\printbibliography[heading=bibintoc]

\end{document}
Jagath
  • 4,287