# BibLaTeX: Replace multiple authors with dashes in authoryear style

I am trying to replicate a bibliography style in BibLaTeX. In the original style, repeated author names are supposed to be replaced by dashes like this:

Sherlock Holmes (2016), ...

————/Watson, John (2017a), ...

————/———— (2017b), ...


However, the current output looks more like this:

Sherlock Holmes (2016), ...

Sherlock Holmes/Watson, John (2017a), ...

——— (2017b), ...


Edit: As it was mentioned in the comments I was able to solve my problem in the meantime thanks to a solution posted by moewe regarding another question. My current adjustments (see below), however, don't "dashify" authors' names correctly if there are entries with several authors inbetween. What causes this behevior and how can it be fixed? Thanks in advance, once more!

MWE:

\documentclass[a4paper,12pt]{scrartcl}

\RequirePackage[english,ngerman]{babel}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{microtype}
\RequirePackage[autostyle=true,german=guillemets]{csquotes}

\usepackage{filecontents}
\usepackage[
natbib=true,
backend=biber,
style=authoryear-comp,
dashed=true,
maxbibnames=99,
maxcitenames=2,
sorting=nyt,
sortlocale=auto,
isbn=false,
doi=false
]{biblatex}

\DeclareNameAlias{author}{last-first}
\DeclareNameAlias{sortname}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DefineBibliographyStrings{ngerman}{%
editor           = {Hg.},
editors          = {Hg.},
}
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}

\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}
\ifnameundef{bookauthor}
{\ifnameundef{editor}
{\printnames{translator}%
\clearname{translator}}
{\printnames{editor}%
\setunit{\space}%
\clearname{editor}}}
{\ifnamesequal{author}{bookauthor}
{}
{\printnames{bookauthor}%
\clearname{bookauthor}}}%
\newunit\newblock}
}

\renewbibmacro*{volume+number+eid}{%
\printfield[bold]{volume}%
\printfield{number}%
\printfield{eid}}

\renewcommand*{\bibnamedash}{\textemdash\textemdash\textemdash}
\newcommand*{\multidashdelim}{\multinamedelim}
\newcommand*{\finaldashdelim}{\finalnamedelim}

\makeatletter
\newcounter{bbx:currnames}
\newcounter{bbx:lastnames}

\InitializeBibliographyStyle{\usebibmacro{dash:cleanup}{0}}

\newbibmacro*{bbx:printlist}[1]{%
\setcounter{bbx:currnames}{0}%
\printnames[dashed:first-last]{#1}%
\usebibmacro{dash:cleanup}{\value{bbx:currnames}+1}%
\setcounter{bbx:lastnames}{\value{bbx:currnames}}}

\newbibmacro*{dash:delim}{%
\ifnumgreater{\value{listcount}}{\value{liststart}}
{\ifboolexpr{
test {\ifnumless{\value{listcount}}{\value{liststop}}}
or
test \ifmorenames
}
{\multidashdelim}
{\finaldashdelim}}
{}}

\DeclareNameFormat{dashed:first-last}{%
\iffieldequalcs{hash}{bbx@lastname@\the\value{listcount}}
{\usebibmacro{dash:delim}\bibnamedash}
\iffirstinits
{\usebibmacro{name:family-given}
{\namepartfamily}%
{\namepartgiveni}%
{\namepartprefix}%
{\namepartsuffix}%
}
{\usebibmacro{name:family-given}
{\namepartfamily}%
{\namepartgiven}%
{\namepartprefix}%
{\namepartsuffix}%
}
}%
\csxdef{bbx@lastname@\the\value{listcount}}{\thefield{hash}}}

\newbibmacro{dash:cleanup}[1]{%
\ifnumgreater{\value{bbx:lastnames}}{#1}
{\global\csundef{bbx@lastname@\the\value{bbx:lastnames}}%
\usebibmacro{dash:cleanup}{0}}
{}}

\renewbibmacro*{author}{%
\ifboolexpr{ test {\ifuseauthor}
and not test {\ifnameundef{author}} }
{\usebibmacro{bbx:printlist}{author}%
{\usebibmacro{dash:cleanup}{0}}}

\renewbibmacro*{bbx:editor}[1]{%
\ifboolexpr{ test {\ifuseeditor}
and not test {\ifnameundef{editor}} }
{\usebibmacro{bbx:printlist}{editor}%
\usebibmacro{#1}%
\clearname{editor}
(\printfield{year})}
{\usebibmacro{dash:cleanup}{0}}}

\renewbibmacro*{bbx:translator}[1]{%
\ifboolexpr{ test {\ifusetranslator}
and not test {\ifnameundef{translator}} }
{\usebibmacro{bbx:printlist}{translator}%
\usebibmacro{#1}%
\clearname{translator}}
{\usebibmacro{dash:cleanup}{0}}}
\makeatother

\AtBeginBibliography{%
\renewcommand{\finalnamedelim}{\multinamedelim}}

\begin{filecontents}{sample.bib}
@article{schmitt_spatial_2013,
title = {Spatial {{Interdependencies}} and {{Welfare State Generosity}} in {{Western Democracies}}, 1960–2000},
volume = {23},
langid = {english},
number = {2},
journaltitle = {Journal of European Social Policy},
author = {Schmitt, Carina and Obinger, Herbert},
date = {2013-05-01},
pages = {119--133},
}

@article{schmitt_explaining_2011,
title = {Explaining {{Convergence}} of {{OECD Welfare States}}: {{A Conditional Approach}}},
volume = {21},
langid = {english},
number = {2},
journaltitle = {Journal of European Social Policy},
author = {Schmitt, Carina and Starke, Peter},
date = {2011-05-01},
pages = {120--135},
}

@article{schmitt_global_2015,
title = {The {{Global Emergence}} of {{Social Protection}}: {{Explaining Social Security Legislation}} 1820–2013},
volume = {43},
langid = {english},
number = {4},
journaltitle = {Politics \& Society},
author = {Schmitt, Carina and Lierse, Hanna and Obinger, Herbert and Seelkopf, Laura},
date = {2015-12-01},
pages = {503--524},
}

@article{rothgang_social_2010,
title = {Social {{Insurance}} for {{Long}}-Term {{Care}}: {{An Evaluation}} of the {{German Model}}},
volume = {44},
timestamp = {2017-02-09T20:38:03Z},
langid = {english},
number = {4},
journaltitle = {Social Policy \& Administration},
author = {Rothgang, Heinz},
date = {2010-08-01},
pages = {436--460},
}

@article{rothgang_solidaritat_2011,
title = {Solidarität in der Pflegeversicherung: Das Verhältnis von Sozialer Pflegeversicherung und Privater Pflegepflichtversicherung},
volume = {60},
langid = {german},
issue = {4–5},
journaltitle = {Sozialer Fortschritt},
author = {Rothgang, Heinz},
date = {2011-04},
pages = {81--87},
}

@article{pickard_modelling_2007,
title = {Modelling an Entitlement to Long-Term Care Services for Older People in                 {{Europe}}: Projections for Long-Term Care Expenditure to 2050},
volume = {17},
langid = {english},
number = {1},
journaltitle = {Journal of European Social Policy},
author = {Pickard, Linda and Comas-Herrera, Adelina and Costa-Font, Joan and Gori, Cristiano and di Maio, Alessandra and Patxot, Concepció and Pozzi, Alessandro and Rothgang, Heinz and Wittenberg, Raphael},
date = {2007-02-01},
pages = {33--48},
options = {useprefix=true},
}

\end{filecontents}

\begin{document}

Happy Valentine's Day.

\nocite{*}

\printbibliography

\end{document}

• I took a look at the code embedded in the makebst utility for replacing the names of repeated authors with dashes. Trying to achieve your formatting objective the the machinery of the makebst utility may not be feasible, I'm afraid. Maybe somebody elase knows how to modify the code in the custom bst file (but I don't...).
– Mico
Feb 5 '17 at 15:05
• The problem is that the language in which .bst files are written is horribly complicated and hardly understood by anybody anymore. What cannot be easily done by makebst is very hard to (meanwhile) impossible to achieve. You may want to have a look at BibLaTeX, if you still have some time to adapt to a new system. This is not saying that achieving what you want will be very easy in BibLaTeX, but it should at least be possible. Feb 7 '17 at 11:17
• BibLaTeX certainly has this facility. \usepackage[style=authoryear,dashed=true]{biblatex} Feb 7 '17 at 12:17
• Have a look at Biblatex/Biber replace author name with dash for each author. The code is a bit more verbose, but it should work for you. Feb 7 '17 at 15:54
• I have re-opened your question and will have a look at the issue. Feb 15 '17 at 9:17

The code in my older answer to Biblatex/Biber replace author name with dash for each author contained a bug that caused the clean-up routine to always delete all names, the correct code is

\newbibmacro{dash:cleanup}[1]{%
\ifnumgreater{\value{bbx:lastnames}}{#1}
{\global\csundef{bbx@lastname@\the\value{bbx:lastnames}}%
\usebibmacro{dash:cleanup}{#1}}
{}}


Note the #1 in \usebibmacro{dash:cleanup}{#1}; the incorrect code had a 0 there.

I have applied a few other modifications to your code. Most importantly to the author, editor and translator macros. You can have a look at them in the MWE below

\documentclass[a4paper,12pt]{scrartcl}

\RequirePackage[english,ngerman]{babel}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{microtype}
\RequirePackage[autostyle=true,german=guillemets]{csquotes}

\usepackage{filecontents}
\usepackage[
natbib=true,
backend=biber,
style=authoryear-comp,
dashed=true,
maxbibnames=99,
maxcitenames=2,
sorting=nyt,
sortlocale=auto,
isbn=false,
doi=false
]{biblatex}

\DeclareNameAlias{author}{last-first}
\DeclareNameAlias{sortname}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DefineBibliographyStrings{ngerman}{%
editor           = {Hg.},
editors          = {Hg.},
}
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}

\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}
\ifnameundef{bookauthor}
{\ifnameundef{editor}
{\printnames{translator}%
\clearname{translator}}
{\printnames{editor}%
\setunit{\space}%
\clearname{editor}}}
{\ifnamesequal{author}{bookauthor}
{}
{\printnames{bookauthor}%
\clearname{bookauthor}}}%
\newunit\newblock}
}

\renewbibmacro*{volume+number+eid}{%
\printfield[bold]{volume}%
\printfield{number}%
\printfield{eid}}

\renewcommand*{\bibnamedash}{\textemdash\textemdash\textemdash}
\newcommand*{\multidashdelim}{\multinamedelim}
\newcommand*{\finaldashdelim}{\finalnamedelim}

\makeatletter
\newcounter{bbx:currnames}
\newcounter{bbx:lastnames}

\InitializeBibliographyStyle{\usebibmacro{dash:cleanup}{0}}

\newbibmacro*{bbx:printlist}[1]{%
\setcounter{bbx:currnames}{0}%
\printnames[dashed:given-family]{#1}%
\usebibmacro{dash:cleanup}{\value{bbx:currnames}+1}%
\setcounter{bbx:lastnames}{\value{bbx:currnames}}}

\newbibmacro*{dash:delim}{%
\ifnumgreater{\value{listcount}}{\value{liststart}}
{\ifboolexpr{
test {\ifnumless{\value{listcount}}{\value{liststop}}}
or
test \ifmorenames
}
{\multidashdelim}
{\finaldashdelim}}
{}}

\DeclareNameFormat{dashed:given-family}{%
\ifboolexpr{togl {bbx:goahead} and not test \iffirstonpage
and test {\iffieldequalcs{hash}{bbx@lastname@\the\value{listcount}}}}
{\usebibmacro{dash:delim}\bibnamedash}
\ifgiveninits
{\usebibmacro{name:family-given}
{\namepartfamily}%
{\namepartgiveni}%
{\namepartprefix}%
{\namepartsuffix}}
{\usebibmacro{name:family-given}
{\namepartfamily}%
{\namepartgiven}%
{\namepartprefix}%
{\namepartsuffix}}}%
\csxdef{bbx@lastname@\the\value{listcount}}{\thefield{hash}}}

\newbibmacro{dash:cleanup}[1]{%
\ifnumgreater{\value{bbx:lastnames}}{#1}
{\global\csundef{bbx@lastname@\the\value{bbx:lastnames}}%
\usebibmacro{dash:cleanup}{#1}}
{}}

\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:printlist}{author}%
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}}%
\setunit{\printdelim{nameyeardelim}}}%
{\usebibmacro{dash:cleanup}{0}%
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extrayear}}

\renewbibmacro*{bbx:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\usebibmacro{bbx:printlist}{editor}%
\usebibmacro{#1}%
\clearname{editor}%
\setunit{\printdelim{nameyeardelim}}}%
{\usebibmacro{dash:cleanup}{0}%
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extrayear}}

\renewbibmacro*{bbx:translator}[1]{%
\ifboolexpr{
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}
{\usebibmacro{bbx:printlist}{translator}%
\usebibmacro{#1}%
\clearname{translator}%
\setunit{\printdelim{nameyeardelim}}}%
{\usebibmacro{dash:cleanup}{0}%
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extrayear}}
\makeatother

\AtBeginBibliography{%
\renewcommand{\finalnamedelim}{\multinamedelim}}

\begin{filecontents}{sample.bib}
@article{schmitt_spatial_2013,
title = {Spatial {{Interdependencies}} and {{Welfare State Generosity}} in {{Western Democracies}}, 1960–2000},
volume = {23},
langid = {english},
number = {2},
journaltitle = {Journal of European Social Policy},
author = {Schmitt, Carina and Obinger, Herbert},
date = {2013-05-01},
pages = {119--133},
}

@article{schmitt_explaining_2011,
title = {Explaining {{Convergence}} of {{OECD Welfare States}}: {{A Conditional Approach}}},
volume = {21},
langid = {english},
number = {2},
journaltitle = {Journal of European Social Policy},
author = {Schmitt, Carina and Starke, Peter},
date = {2011-05-01},
pages = {120--135},
}

@article{schmitt_global_2015,
title = {The {{Global Emergence}} of {{Social Protection}}: {{Explaining Social Security Legislation}} 1820–2013},
volume = {43},
langid = {english},
number = {4},
journaltitle = {Politics \& Society},
author = {Schmitt, Carina and Lierse, Hanna and Obinger, Herbert and Seelkopf, Laura},
date = {2015-12-01},
pages = {503--524},
}

@article{rothgang_social_2010,
title = {Social {{Insurance}} for {{Long}}-Term {{Care}}: {{An Evaluation}} of the {{German Model}}},
volume = {44},
timestamp = {2017-02-09T20:38:03Z},
langid = {english},
number = {4},
journaltitle = {Social Policy \& Administration},
author = {Rothgang, Heinz},
date = {2010-08-01},
pages = {436--460},
}

@article{rothgang_solidaritat_2011,
title = {Solidarität in der Pflegeversicherung: Das Verhältnis von Sozialer Pflegeversicherung und Privater Pflegepflichtversicherung},
volume = {60},
langid = {german},
issue = {4–5},
journaltitle = {Sozialer Fortschritt},
author = {Rothgang, Heinz},
date = {2011-04},
pages = {81--87},
}

@article{pickard_modelling_2007,
title = {Modelling an Entitlement to Long-Term Care Services for Older People in                 {{Europe}}: Projections for Long-Term Care Expenditure to 2050},
volume = {17},
langid = {english},
number = {1},
journaltitle = {Journal of European Social Policy},
author = {Pickard, Linda and Comas-Herrera, Adelina and Costa-Font, Joan and Gori, Cristiano and di Maio, Alessandra and Patxot, Concepció and Pozzi, Alessandro and Rothgang, Heinz and Wittenberg, Raphael},
date = {2007-02-01},
pages = {33--48},
options = {useprefix=true},
}

\end{filecontents}

\begin{document}
Happy Valentine's Day.

\nocite{*}
\printbibliography
\end{document}

• Hmm, although it works mostly very well now, in large bibliographies the dashes are occasionally missing. I wasn't able to create a MWE yet reproducing the problem as it seems to only occur under certain circumstances involving a number of bibliography entries but I included my .bib-file in this overleaf document where the problem is visible – maybe you could have a final look on it?
– JKR
Feb 15 '17 at 16:22
• @JKR Where exactly do I have to look for the problem? The document contains 23 pages. Can you point me to some of the problematic entries? Feb 15 '17 at 17:28
• I cited three of them in the second section, their bibtex-keys are breiter_complexity_2017, haunss_conflicts_2010, and mesa-lago_performance_2012.
– JKR
Feb 15 '17 at 18:12
• @JKR Aha. That is because those entries are the first on a new page and I explicitly disabled the dash there, so your reader doesn't have to skip back a page to read the author. If you don't want that remove the and not test \iffirstonpage bit in \DeclareNameFormat{dashed:given-family} so that the \ifboolexpr reads \ifboolexpr{togl {bbx:goahead} and test {\iffieldequalcs{hash}{bbx@lastname@\the\value{listcount}}}} only. Feb 15 '17 at 18:33
• Ah, so it's a feature, not a bug! :) Fantastic, thank you for the clarification!
– JKR
Feb 15 '17 at 18:48