# Two different bibliographies with different styles and sortings, Vol.2

The answer of moewe appearing in this question is almost what I want to achieve:

• one bibliography containing online references which are numbered and sorted in order of appearence (nothing to change here, moewes code is perfect!)
• one bibliography containing all book and article references, sorted alphabetically (almost what I want!)

For the second bib, instead of only showing three letters of the authors followed by the last two numbers of the year, e.g [Sut68], I would instead like to have the full last name of the first author, followed by a comma, space and then the full year, e.g [Sutherland, 1968].

I have literally no idea how to achieve this, I tried messing around with moewes provided code, but could not find any solution apart from breaking it. I would highly appreciate if someone could just post the changed part to achieve this!

Edit: Here is the code moewe provided in the answer from the question above, if that helps:

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author    = {Author Aaa},
title     = {Some Title},
publisher = {Some Publisher},
year      = 2003,
}
@BOOK{BookB02,
author    = {Author Bbb},
title     = {Some Title},
publisher = {Some Publisher},
year      = 2002,
}
\end{filecontents}

\begin{filecontents}{biblatextest2.bib}
author  = {Author Ccc},
title   = {Some Title},
year    = 2004,
url     = {www.test1.com/bild.jpg},
}
author  = {Author Ddd},
title   = {Some Title},
year    = 2001,
url     = {www.test2.com/bild.jpg},
}
\end{filecontents}

\usepackage[style = alphabetic, labelnumber, defernumbers = true,  backend = biber]{biblatex}

\usepackage{hyperref}

%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary, append]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary, append]
}
}
}

\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifkeyword{secondary}
{\printfield{labelnumber}}
{\printfield{labelalpha}%
\printfield{extraalpha}}}}

\defbibenvironment{bibliographyNUM}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}

\assignrefcontextkeyws[sorting=none]{secondary}
\begin{document}

The first two citations \cite{LinkD01} and \cite{BookB02}.
The others are \cite{LinkC04} and \cite{BookA03}.

\printbibliography[title=Bibliography, keyword=primary]

\newrefcontext[sorting=none]
\printbibliography[env=bibliographyNUM,title=References, keyword=secondary, resetnumbers]
\end{document}


This yields following result (also provided by moewe):

As I already said, I only really want [EXA97] to be changed to [Example, 1997]. Though, it would be much much nicer to not have the whole brackets in the bibliography at all! Here a optimal solution I would love to have (I edited this in photoshop, as I have no Idea how to achieve this):

• Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). – Henri Menke Sep 24 '18 at 1:51
• I edited the post and hope all information is now provided! – LaMahuni Sep 27 '18 at 14:39

The approach is similar to Biblatex: Two bibliographies with different styles and sortings, but this time we take authoryear as a base and copy its definition of cite.

\documentclass{article}
\usepackage[style = authoryear, labelnumber, defernumbers = true, backend = biber, autocite=inline]{biblatex}
\usepackage{hyperref}

\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifkeyword{secondary}
{\printtext[bibhyperref]{%
\printfield{labelprefix}%
\printfield{labelnumber}}}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%
{\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\defbibenvironment{bibliographyNUM}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}

\assignrefcontextkeyws[sorting=none]{secondary}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{BookA03,
author    = {Author Aaa},
title     = {Some Title},
publisher = {Some Publisher},
year      = 2003,
keywords  = {primary},
}
@BOOK{BookB02,
author    = {Author Bbb},
title     = {Some Title},
publisher = {Some Publisher},
year      = 2002,
keywords  = {primary},
}
author    = {Author Ccc},
title     = {Some Title},
year      = 2004,
url       = {www.test1.com/bild.jpg},
keywords  = {secondary},
}
author    = {Author Ddd},
title     = {Some Title},
year      = 2001,
url       = {www.test2.com/bild.jpg},
keywords  = {secondary},
}
\end{filecontents}

\begin{document}

The first two citations \autocite{LinkD01} and \autocite{BookB02}.
The others are \autocite{LinkC04} and \autocite{BookA03}.

\printbibliography[title=Bibliography, keyword=primary]

\newrefcontext[sorting=none]
\printbibliography[env=bibliographyNUM,title=References, keyword=secondary, resetnumbers]
\end{document}


A version that works for the outdated biblatex version on Overleaf can be found at https://v1.overleaf.com/read/cppjsymdshwd. The necessary changes were minute: It is enough to replace cite:labeldate+extradate with cite:labelyear+extrayear.

• You, Sir, are the best!!! – LaMahuni Sep 27 '18 at 16:04
• @LaMahuni If the answer solved your question you may want to consider accepting it tex.stackexchange.com/help/someone-answers – moewe Sep 27 '18 at 16:21
• I was probably happy to early.. If I copy your code into a new project, it gives me the error "Package biblatex Error: Bibliography macro 'cite:labeldate+extradate' undefined." Also one more change if possible: I would like to still have the brackets around the numbers and name/year in the text itself! Just not in the first bibliography. – LaMahuni Sep 27 '18 at 16:28
• @LaMahuni Then your biblatex version is too old. Can you make an update? – moewe Sep 27 '18 at 16:34
• I am using the online version of overleaf, this should be the newest version, shouldn't it? – LaMahuni Sep 27 '18 at 17:05