5

Hi I want to replace the "and" inside the bibliography if there are listed two or more authors. The "and" should be replaced by a simple comma, so:

Name.A, Name.B, Name.C

My following code:

\documentclass[a4paper,12pt]{scrartcl}

\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage
[style=authoryear, sorting=nyt, labelnumber ,maxbibnames=9,maxcitenames=2,uniquelist=false, backend=biber,
doi=false,isbn=false,url=false,
uniquename=false, date=year, giveninits=true]
{biblatex}
\usepackage{filecontents}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{default}{last-first}

\DefineBibliographyStrings{ngerman}{andothers={et\addabbrvspace al\adddot}} 

%Remove Dot and Add Space
\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
%  \setunit*{\adddot}% DELETED
 % \setunit*{\addnbspace}% NEW (optional); there's also \addnbthinspace
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

\renewbibmacro{in:}{}

\DeclareFieldFormat{labelnumberwidth}{[#1]}
\defbibenvironment{bibliography}  % from numeric.bbx
  {\list
    {\printtext[labelnumberwidth]{%
      \printfield{prefixnumber}%
      \printfield{labelnumber}}}
    {\setlength{\labelwidth}{\labelnumberwidth}%
        \setlength{\leftmargin}{\labelwidth}%
        \setlength{\labelsep}{\biblabelsep}%
        \addtolength{\leftmargin}{\labelsep}%
        \setlength{\itemsep}{\bibitemsep}%
        \setlength{\parsep}{\bibparsep}}%
        \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}



\begin{filecontents}{\jobname.bib}
@Book{ISL,
  author    = {James, Gareth and Witten, Daniela and Hastie, Trevor and Tibshirani, Robert},
  title     = {An Introduction to Statistical Learning: With Applications in R},
  year      = {2014},
  publisher = {Springer Publishing Company, Incorporated},
  isbn      = {1461471370, 9781461471370},
}

\end{filecontents}
\addbibresource{\jobname.bib} 

\begin{document}
\textcite{ISL}
\printbibliography
\end{document}
Vala
  • 475

1 Answers1

4
\DeclareDelimAlias{finalnamedelim}{multinamedelim}

should do that.

\documentclass[a4paper,12pt]{scrartcl}

\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage
[style=authoryear, labelnumber, maxbibnames=9, maxcitenames=2, uniquelist=false, backend=biber,
doi=false,isbn=false,url=false,
uniquename=false, date=year, giveninits=true]
{biblatex}
\usepackage{filecontents}

\DeclareNameAlias{default}{family-given}
\DeclareNameAlias{sortname}{default}

\DeclareDelimAlias{finalnamedelim}{multinamedelim}

\DefineBibliographyStrings{ngerman}{andothers={et\addabbrvspace al\adddot}} 

%Remove Dot and Add Space
\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
%  \setunit*{\adddot}% DELETED
 % \setunit*{\addnbspace}% NEW (optional); there's also \addnbthinspace
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}

\renewbibmacro{in:}{}

\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\defbibenvironment{bibliography}  % from numeric.bbx
  {\list
    {\printtext[labelnumberwidth]{%
      \printfield{prefixnumber}%
      \printfield{labelnumber}}}
    {\setlength{\labelwidth}{\labelnumberwidth}%
        \setlength{\leftmargin}{\labelwidth}%
        \setlength{\labelsep}{\biblabelsep}%
        \addtolength{\leftmargin}{\labelsep}%
        \setlength{\itemsep}{\bibitemsep}%
        \setlength{\parsep}{\bibparsep}}%
        \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}



\begin{filecontents}{\jobname.bib}
@book{ISL,
  author    = {James, Gareth and Witten, Daniela and Hastie, Trevor and Tibshirani, Robert},
  title     = {An Introduction to Statistical Learning},
  subtitle  = {With Applications in R},
  year      = {2014},
  publisher = {Springer},
  isbn      = {9781461471370},
}
\end{filecontents}
\addbibresource{\jobname.bib} 

\begin{document}
\textcite{ISL}
\printbibliography
\end{document}

James, G., Witten, D., Hastie, T., Tibshirani, R. (2014). An Introduction to Statistical Learning. With Applications in R. Springer.


If you only want the change to apply to the bibliography you need

 \DeclareDelimFormat[bib,biblist]{finalnamedelim}{\addcomma\space}

instead. Unfortunately, there is no elegant way to solve this with an alias, so we have to have an explicit definition here.

moewe
  • 175,683
  • 1
    @Vala Glad I could help. Is it a usual requirement at your university to number the bibliography even though the citations are author-year and the numbers therefore useless (except for counting the references)? (BTW: You can take the solution from https://tex.stackexchange.com/q/446855/35864, it has slightly less overhead than actually ordering labelnumbers from Biber). – moewe Aug 21 '18 at 15:31
  • Yes unfortunately we have to number it through despite author-year style. This makes it very cumbersome for latex beginners who only know how to write formulas – rook1996 Aug 22 '18 at 07:11
  • @rook1996 It also makes absolutely no sense. If they want to know the number of references you cited, they should just ask you to count them and write the number into a 'postnote' in the bibliography (this could be automated with biblatex, not exactly what I have in mind, but it shows that it is possible: https://tex.stackexchange.com/q/66829/35864) - or they should just count the number themselves. The idea that the number of items in the bibliography can be used to meaningfully assess the scientific quality of a work is also laughable. – moewe Aug 22 '18 at 07:43
  • 1
    ... Finally, in my opinion the added numeric labels make it a bit harder to navigate a bibliography that should be cut out for author-year references. In the standard bibliography output of ´authoryear`, the first line is slightly further to the left than subsequent lines, which are indented, that makes it very easy to find the beginning of an entry and focuses the reader on the first letter of the name (by which the bibliography is sorted). If instead the numeric labels appear they are more prominent and the names don't really jump right at the reader, making thinsg harder to find. ... – moewe Aug 22 '18 at 07:46
  • 1
    ... Since the numbers have absolutely no meaning they just distract from the real sorting. – moewe Aug 22 '18 at 07:47
  • I would totally agree with you. A small modification. I probably wasn't precise. You example is also removing the "And" inside the textcitations. It should only be removed inside the bibliography – Vala Aug 22 '18 at 11:49
  • I will contact my supervisor with the reason you give above. I am curious what he has to say – Vala Aug 22 '18 at 11:51
  • 2
    @Vala Edited the answer with a suggestion that only changes the "and" in the bibliography. When I read 'bibliography' I usually include the entire document, so I misunderstood your question, sorry. In those cases I usually need an explicit mention that the cite behaviour should not be changed as a reminder. I'll be happy to discuss the numbers in author-year bibliographies with your supervisor ;-) – moewe Aug 22 '18 at 12:16