1

I am writing a thesis document in Latex, for the moment I am using Overleaf program.

I am figuring out how could I have my reference list in the following way with the Authors sorted in alphabetical order. I tried all the possible options I found in this forum and others, but couldn't reach to my target.

Reference list style wanted

I am using author-year citation style as shown below (Due to the big amount of packages I didn't put all the preamble, if any other kind of packages are needed to understand or fix my problem tell me):

\documentclass[a4paper,twoside,11pt]{book}
\usepackage[citestyle=authoryear,style=authoryear,sorting=nyt]{biblatex}
\bibliography{ref_Generacion.bib}
\printbibliography[heading=bibintoc,title={BIBLIOGRAPHY}] 

I tried to edit style=author year using the code proposed in question: Creating a bibliography with fixed indention and authoryear labels using biblatex and biber

I copy/paste the code I used:

\makeatletter
\setlength{\bibitemsep}{0.5\baselineskip plus 0.5\baselineskip}

\newsavebox\ay@labelbox
\newlength{\labwidthsameline}
\setlength{\labwidthsameline}{6em}

\newbibmacro{labelwidthbib}{%
  \begingroup
  \delimcontext{cite}%
  \DeclareFieldFormat{bibhyperref}{##1}%
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@citekey}%
  \citetrackerfalse\pagetrackerfalse\backtrackerfalse
  \defcounter{maxnames}{\blx@maxcitenames}%
  \usebibmacro{cite}%
  \endgroup
} 
%-----------------------
\newbibmacro{kicklabel}{% 
  \sbox\ay@labelbox{\usebibmacro{labelwidthbib}}%
  \global\togglefalse{blx@insert}%
  \ifdim\wd\ay@labelbox>\labwidthsameline
    \leavevmode\newline
  \fi
}

\defbibenvironment{bibliography}%
  {\list
    {\usebibmacro{labelwidthbib}}%
    {\setlength{\labelwidth}{\labwidthsameline}%
     \setlength{\leftmargin}{\labelwidth}%
     \setlength{\labelsep}{\biblabelsep}%
     \addtolength{\leftmargin}{\labelsep}%
     \setlength{\itemsep}{\bibitemsep}%
     \setlength{\parsep}{\bibparsep}%
     \renewcommand*{\makelabel}[1]{##1\hss}}}%
  {\endlist}%
  {\item\usebibmacro{kicklabel}}
\makeatother

With this, what I obtain in the bibliography is closer to want I want, but still I need to do some changes: What I get in bibliography

However I am quite new in the fact of changing predifined styles I am not able to understand all this code and make a change in it.

  • How can I add brackets to author year tags, as it is shown in the first figure?
  • How can I edit the space author year tag take in the page? Can I make this distance variable according to the tag?
  • How can I make that same authors articles are not grouped together and dashed? I would like to have each author year tag separately.

Thank you in advance for taking the time to read and answer this long issue.

  • Have a look at https://tex.stackexchange.com/q/420595/35864 – moewe Jun 28 '19 at 07:22
  • 2
    ... and as I send that comment I realise you use Overeleaf :-(. Unfortunately, the LaTeX version on Overleaf is a bit outdated by now and does not come with biblatex-ext. Is there any chance you could use a more up-to-date local installation? (https://tex.stackexchange.com/q/348126/35864 pre-dates biblatex-ext and shows how things could work out on older systems, but it might not be exactly what you hoped for). – moewe Jun 28 '19 at 07:23
  • Thank you @moewe! It is a pity Overleaf hasn't got the lastest version. For the moment I am not able to change to another up-to-date installation, but it is something I am going to bear in mind. The 2nd link you provided changes author-year style to introduce it more or less as I want, however I am new in the redefinition of styles and I am not able to introduce brackets [author year], should I ask a new question about that? – Aurea 1994 Jun 28 '19 at 07:56
  • You could just edit this question here with the code you from the other answer and we can discuss what needs to be changed. – moewe Jun 28 '19 at 10:25

1 Answers1

1

This answer is specifically written for the situation in the question, where the OP uses the outdated LaTeX installation currently run on Overleaf.

Please refer to printbibliography output for "[author year] entrydata" (using biblatex-ext and its introcite option) if you are using a more recent TeX installation.

As mentioned in the comments and in printbibliography output for "[author year] entrydata", with an up-to-date LaTeX installation you could just use biblatex-ext's introcite=label.

With the outdated system that Overleaf currently runs, we have to code the stuff ourselves. Here I just copied the important bits from biblatex-ext. The customisation section that sets the square brackets and allows you to change to lengths (the width of the label and the minimum distance between label and entry; all of this uses the same names as in biblatex-ext, so you can have a look at the section documenting introcite in the biblatex-ext documentation, pp. 15-19, note that only introcite=label is implemented here).

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber, dashed=false]{biblatex}
\addbibresource{biblatex-examples.bib}

% implementation copied from biblatex-ext
\makeatletter
\newbibmacro*{bbx:introcite}{\usebibmacro{cite}}

\DeclareFieldFormat{bbx@introcite}{#1}
\newcommand*{\introcitepunct}{\addcolon\space}
\newcommand*{\introcitebreak}{\leavevmode\newline}

\newlength{\extbl@this@introcitewidth}
\newlength{\introcitewidth}
\setlength{\introcitewidth}{8\biblabelsep}
\newlength{\introcitesep}
\setlength{\introcitesep}{\biblabelsep}

\newbibmacro{introcite:typeset}{%
  \begingroup
    \iftoggle{blx@citation}
      {}
      {\togglefalse{blx@bibliography}%
       \toggletrue{blx@citation}}%
    \delimcontext{bbx@introcite}%
    \csuse{blx@hook@cite}%
    \csuse{blx@hook@citekey}%
    \DeclareFieldFormat{bibhyperref}{##1}%
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \citetrackerfalse\pagetrackerfalse\backtrackerfalse
    \defcounter{maxnames}{\blx@maxcitenames}%
    \defcounter{minnames}{\blx@mincitenames}%
    \printtext[bbx@introcite]{\usebibmacro{bbx:introcite}}%
  \endgroup
}

% This macro is used in \defbibenvironment
\newbibmacro*{introcite:break}{%
  \settowidth{\extbl@this@introcitewidth}
    {\usebibmacro{introcite:typeset}}%
  \ifdimgreater{\extbl@this@introcitewidth}{\introcitewidth}
    {\introcitebreak}
    {}}


\defbibenvironment{bibliography}
  {\list
     {\usebibmacro{introcite:typeset}}
     {\setlength{\labelwidth}{\introcitewidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\introcitesep}%
      \addtolength{\leftmargin}{\labelsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item
   \usebibmacro{introcite:break}}
\makeatother


% customisation starts here
\DeclareFieldFormat{bbx@introcite}{\mkbibbrackets{#1}}
\setlength{\introcitewidth}{8\biblabelsep}
\setlength{\introcitesep}{\biblabelsep}

\begin{document}
\cite{sigfridsson,worman,geer,knuth:ct:a,knuth:ct:b}
\printbibliography
\end{document}

Bibliography with author-year labels in square brackets

The general solution works for other authoryear and authortitle styles as well, but some details would have to be changed for the more complex -icomp styles.

Note the option dashed=false, since the default dashed=true would look weird (at least that's what I think) and would leave excessive space after the namedash (that could probably be fixed).

Note also that citestyle=authoryear,style=authoryear,sorting=nyt, is equivalent to just

style=authoryear,

since style sets both bibstyle and citestyle and the authoryear style sets sorting=nyt already.

moewe
  • 175,683
  • Thank you so much @moewe!! I fixed my bibliography after so many hours! You really helped me with the documentation and your comments! – Aurea 1994 Jun 30 '19 at 15:40