[Tex/LaTex] How to add citation number to bibliography when using bibstyle=authoryear and justification issue

biblatex

I am formatting citations for a journal that uses a variation of the Vancouver style. I am having two issues:

  1. I need the citations in the bibliography to appear with their corresponding in-text citation number. For example, if in the text I cite "You are great (1)." I need the bibliography entry to be: "1. Author, B. …"
  2. In the bibliography, I need the citation to start right after the citation number and not indent when going to a second line.

The the first image shows how the citation should be formatted, and the second image shows how they are currently formatted.

First Image

First Image

Second Image

Image 2

Changing bibstyle=authoryear to bibstyle=numeric produces the image below (image 3). I have the citation number, but now I am dealing with spacing issues. In addition, the authors first-name initials appear before their last name, which is the opposite of how I would like it. It would be perfect if I could make the citation information start immediately after the citation number and justify to the left and have the author's first name initials come after their last name, like in image one.

Third Image
Third Image

As you can see, I am quite close, but I just can't figure out these last two issues. Here is my MWE for the second image:

\documentclass [12pt]{article}

\usepackage[
    backend=bibtex8,
    natbib=true,
    citestyle=numeric,
    isbn=false,
    bibstyle=authoryear,
    maxnames=3,
    minnames=3,
    firstinits=true, % Removes period after first name intial 
    terseinits=true, % Removes period after first name intial 
    sorting=none] % List citation in order they appear
    {biblatex}

\DeclareFieldFormat[article]{volume}{\textbf{#1}\addcomma\space} % Bolds volume of citation and adds comma after volume
\DeclareFieldFormat{pages}{#1} % No prefix for the "pages" field in the bibliography
\renewcommand*{\revsdnamepunct}{} % Removing the comma after last name
\renewcommand*{\revsdnamepunct}{} % Removing the periods after first name intial
\renewcommand{\labelnamepunct}{\addspace} % Removes period after year in bibliography
\DeclareFieldFormat[article]{title}{#1}  % Remove quotes from journal title
\DeclareNameAlias{sortname}{last-first} % Lists all authors with last name first
\renewcommand*{\finalnamedelim}{\addspace\bibstring{and}\space}% removes comma after penultimate name

\usepackage{xpatch}

\xpatchbibmacro{name:andothers}{% maked the ``et al'' italicized in the bibliography
\bibstring{andothers}%
}{%
\bibstring[\emph]{andothers}%
}{}{}

\renewbibmacro{in:}{% Removes "In" from bibliography entries
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}

\usepackage{filecontents}
\begin{filecontents*}{example.bib}

@article{author2014,
author = {Author, A. B. and Author, A. B. and Author, A. B.},
journal = {Journal of the happy but frustrated biblatex user},
pages = {1070--1074},
title = {{Biblatex hurts so good}},
volume = {10},
date = {2014}
}
@article{author2013,
author = {Author, A. D. and Author, A. B. and Author, A. B.},
journal = {Journal of the happy but frustrated biblatex user},
pages = {1070--1074},
title = {{Biblatex hurts so good}},
volume = {10},
date = {2013}
}
\end{filecontents*}

\bibliography{example}

\begin{document}

Be excellent, Dudes \supercite{author2014,author2013}

\printbibliography

\end{document}

Best Answer

This answer incorporates the code from my comment and two elements from karlkoeller's answer:

  • the redefinition of the label in the bibliography;
  • sticking to bibstyle=authoryear (which I'd changed in my original answer).

In addition, I've changed the punctuation to match the target image. Specifically, I've put commas between the last name and initials of authors' names but removed them from between different names in the list. That is, the target format shows

last1, init1 last2, init2 and last3, init3

rather than

last1 init1, last2 init2, and last3 init3

The code

\documentclass [12pt]{article}

\usepackage[
    backend=bibtex8,
    natbib=true,
    citestyle=numeric,
    bibstyle=authoryear, % also thanks to karlkoeller's answer (was in MWE but - see comments)
    isbn=false,
    maxnames=3,
    minnames=3,
    firstinits=true, % Removes period after first name intial
    terseinits=true, % Removes period after first name intial
    sorting=none] % List citation in order they appear
    {biblatex}

\DeclareFieldFormat[article]{volume}{\textbf{#1}\addcomma\space} % Bolds volume of citation and adds comma after volume
\DeclareFieldFormat{pages}{#1} % No prefix for the "pages" field in the bibliography
\DeclareFieldFormat[article]{title}{#1}  % Remove quotes from journal title
\DeclareNameAlias{sortname}{last-first} % Lists all authors with last name first
\renewcommand{\labelnamepunct}{\addspace} % Removes period after year in bibliography
\renewcommand*{\revsdnamepunct}{\addcomma}% want a comma between last name and initials
\renewcommand*{\multinamedelim}{\space}% want a space but no comma between names
\renewcommand*{\finalnamedelim}{\addspace\bibstring{and}\space}% want a space but no comma between penultimate name and 'and' followed by final name

\usepackage{xpatch}

\xpatchbibmacro{name:andothers}{% maked the ``et al'' italicized in the bibliography
\bibstring{andothers}%
}{%
\bibstring[\emph]{andothers}%
}{}{}

\renewbibmacro{in:}{% Removes "In" from bibliography entries
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}

\DeclareFieldFormat{labelnumberwidth}{#1.}% from karlkoeller's answer

\defbibenvironment{bibliography}
  {\list
    {\printfield[labelnumberwidth]{labelnumber}}
    {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{0pt}%
      \setlength{\labelsep}{\biblabelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\itemindent}{\labelwidth}%
      \addtolength{\itemindent}{\labelsep}%
      \setlength{\parsep}{\bibparsep}}%
    \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

\usepackage{filecontents}
\begin{filecontents*}{example.bib}

@article{author2014,
author = {Author, A. B. and Author, A. B. and Author, A. B.},
journal = {Journal of the happy but frustrated biblatex user},
pages = {1070--1074},
title = {{Biblatex hurts so good}},
volume = {10},
date = {2014}
}
@article{author2013,
author = {Author, A. D. and Author, A. B. and Author, A. B.},
journal = {Journal of the happy but frustrated biblatex user},
pages = {1070--1074},
title = {{Biblatex hurts so good}},
volume = {10},
date = {2013}
}
\end{filecontents*}

\bibliography{example}

\begin{document}

Be excellent, Dudes \supercite{author2014,author2013}

\printbibliography

\end{document}

The result

Modified numeric style in bibliography

Related Question