3

Consider the following latex document:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,11pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{caption}
\usepackage[dvips]{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{cite}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{fancyvrb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bibliographystyle{apalike}
\renewcommand{\baselinestretch}{1.2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Title and author
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\textbf{My title}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \maketitle
    First citation: \cite{Tibshirani1996b}, second citation \cite{Laria2019a}.
    \bibliography{D:/Documentos_2/GoogleDrive/Doctorado/Tesis/Articulos/library}
\end{document}

Where the cited entries have the following bibtex structure:

@article{Laria2019a,
author = {Laria, Juan C. and Aguilera-Morillo, M. Carmen and Lillo, Rosa E.},
doi = {10.1080/10618600.2019.1573687},
file = {:D$\backslash$:/Documentos{\_}2/GoogleDrive/Doctorado/Tesis/Bibliograf{\'{i}}a/Mendeley/An iterative sparse-group lasso{\_}Laria, Aguilera-Morillo, Lillo{\_}2019.pdf:pdf},
journal = {Journal of Computational and Graphical Statistics},
month = {feb},
pages = {1--21},
title = {{An iterative sparse-group lasso}},
url = {https://www.tandfonline.com/doi/full/10.1080/10618600.2019.1573687},
year = {2019}
}

@article{Tibshirani1996b,
author = {Tibshirani, Robert},
doi = {10.2307/2346178},
file = {:D$\backslash$:/Documentos{\_}2/GoogleDrive/Doctorado/Tesis/Bibliograf{\'{i}}a/Mendeley/Regression Shrinkage and Selection via the Lasso{\_}Tibshirani{\_}1996.pdf:pdf},
journal = {Journal of the Royal Statistical Society. Series B (Methodological)},
number = {1},
pages = {267--288},
publisher = {WileyRoyal Statistical Society},
title = {{Regression Shrinkage and Selection via the Lasso}},
url = {https://www.jstor.org/stable/2346178},
volume = {58},
year = {1996}
}

Now if I compile the document, I obtain this output: enter image description here

As you can see, both bibtex entries have doi, but this is not shown in the latex document. I would like to use if possible apalike style for the bibliography (ibcluding the DOI), but I read that apacite includes the DOI in the references, so I tried using it:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,11pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{caption}
\usepackage[dvips]{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{cite}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{fancyvrb}
\usepackage{apacite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\bibliographystyle{apacite}
\renewcommand{\baselinestretch}{1.2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Title and author
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\textbf{My title}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \maketitle
    First citation: \cite{Tibshirani1996b}, second citation \cite{Laria2019a}.
    \bibliography{D:/Documentos_2/GoogleDrive/Doctorado/Tesis/Articulos/library}
\end{document}

However, I obtained the following error:

Use of \@year@ doesn't match its definition. First citation: \cite{Tibshirani1996b}
Use of \@year@ doesn't match its definition. ...i1996b}, second citation \cite{Laria2019a}

EDIT:

Based on the answers, I have updated the tex file:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,11pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{fancyvrb}
\usepackage{csquotes}
\usepackage[style=apa]{biblatex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addbibresource{library.bib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Title and author
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{My title}

\author{Some author}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \maketitle
    First citation: \cite{Tibshirani1996b}, second citation \cite{Laria2019a}.
    \printbibliography
\end{document}

While compiling this tex file, it returns three error messages:

This is BibTeX, Version 0.99d (MiKTeX 2.9.7000 64-bit)
The top-level auxiliary file: document.aux
I found no \citation commands---while reading file document.aux
I found no \bibdata command---while reading file document.aux
I found no \bibstyle command---while reading file document.aux
(There were 3 error messages)

And the pdf result does not include any reference section. Do you have any idea on what the reason may be? Regarding the biber vs bibtex question, I do not know what the differences between biber and bibtex are, I am using bibtex because I handle my bibliography using Jabref, and I think it works with bibtex, but maybe I am mistaken.

3
  • 1
    apalike.sty is very old. You should probably look at the apa style for biblatex. Commented Apr 30, 2019 at 9:30
  • apalike style is one of the earlier BibTeX styles and dates back to the late eighties, when DOIs and even URLs weren't really a thing yet. The style does not support dedicated url or doi fields. Note that certainly today apalike is only like APA and would not satisfy the requirements of the APA style. apacite on the other hand, aims at implementing the APA requirements as far as possible with BibTeX. If you use \bibliographystyle{apacite} you should also load \usepackage{apacite}. ...
    – moewe
    Commented Apr 30, 2019 at 11:38
  • ... If you are up for using biblatex, you can also get APA style with biblatex-apa. Many people who use apalike would probably be happy with a less complex style like biblatex's standard authoryear style already, so you need not use apa if you don't need full APA support.
    – moewe
    Commented Apr 30, 2019 at 11:39

2 Answers 2

4

Do not use the ancient bibtex. Use instead biber which is already installed with your tex distribution:

\RequirePackage{filecontents}% Only for demo here
\begin{filecontents*}{library.bib}
@article{Laria2019a,
    author = {Laria, Juan C. and Aguilera-Morillo, M. Carmen and Lillo, Rosa E.},
    doi = {10.1080/10618600.2019.1573687},
    file = {:D$\backslash$:/Documentos{\_}2/GoogleDrive/Doctorado/Tesis/Bibliograf{\'{i}}a/Mendeley/An 
    iterative sparse-group lasso{\_}Laria, Aguilera-Morillo, Lillo{\_}2019.pdf:pdf},
    journal = {Journal of Computational and Graphical Statistics},
    month = {feb},
    pages = {1--21},
    title = {{An iterative sparse-group lasso}},
    url = {https://www.tandfonline.com/doi/full/10.1080/10618600.2019.1573687},
    year = {2019}
}

@article{Tibshirani1996b,
    author = {Tibshirani, Robert},
    doi = {10.2307/2346178},
    file = 
    {:D$\backslash$:/Documentos{\_}2/GoogleDrive/Doctorado/Tesis/Bibliograf{\'{i}}a/Mendeley/Regression 
    Shrinkage
     and Selection via the Lasso{\_}Tibshirani{\_}1996.pdf:pdf},
    journal = {Journal of the Royal Statistical Society. Series B (Methodological)},
    number = {1},
    pages = {267--288},
    publisher = {WileyRoyal Statistical Society},
    title = {{Regression Shrinkage and Selection via the Lasso}},
    url = {https://www.jstor.org/stable/2346178},
    volume = {58},
    year = {1996}
}
\end{filecontents*}

\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[style=apa]{biblatex}
\addbibresource{library.bib}

\title{\textbf{My title}}

\begin{document}
    \maketitle
    First citation: \cite{Tibshirani1996b}, second citation \cite{Laria2019a}.
    \printbibliography
\end{document}

run it with pdflatex <file>, biber <file>, pdflatex <file>

enter image description here

2
  • Hello, thanks for your answer. I have tried to use your solution however the references section is not being generated. Please find more information on the edit of the question Commented May 6, 2019 at 10:58
  • You have to run biber and not bibtex
    – user187802
    Commented May 6, 2019 at 11:08
1

I'm new on Latex and I have the same problem with this version of apalike. Apparently, this version is apalike2.bst and, as someone said in another comment, this version is too old. Fortunately, there's a new version, apalike3.bst, which includes doi and url fields. I'm using Natbib (I'm not sure if it works with Biblatex) and I'm using Overleaf, so I upload the file .bst what you can download on this link https://drive.google.com/file/d/1ryzBhGzrK0MKEvziX9FzbLPRqgVvtLx8/view?usp=share_link

and did \bibliographystyle{apalike3.bst} and DOI appeared. So, please, whoever reads my message, corrects my errors or says if it is a reliable solution. I already said it, I'm new to latex, so I can't say it's something that solves the problem. Cheers

2
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Miyase
    Commented Nov 23, 2022 at 10:24
  • 1
    Please don't use external links that will break in the future, making the answer useless. EIther find a stable link (to CTAN for example) or explain what changes are in this specific version of the file.
    – Miyase
    Commented Nov 23, 2022 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .