如何将 DOI 添加到 Latex 参考文献中?

如何将 DOI 添加到 Latex 参考文献中?

考虑以下乳胶文档:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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}

其中引用的条目具有以下 bibtex 结构:

@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}
}

现在,如果我编译该文档,我将获得以下输出: 在此处输入图片描述

如您所见,两个 bibtex 条目都有 doi,但这未显示在 latex 文档中。如果可能的话,我想对参考书目使用 apalike 样式(不包括 DOI),但我读到 apacite 在参考文献中包含了 DOI,所以我尝试使用它:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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}

但是,我得到了以下错误:

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}

编辑:

根据答案,我更新了 tex 文件:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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}

编译此 tex 文件时,它返回三条错误消息:

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)

并且 pdf 结果不包含任何参考部分。你知道原因可能是什么吗?关于 biber 与 bibtex 的问题,我不知道 biber 和 bibtex 之间有什么区别,我使用 bibtex 是因为我使用 Jabref 处理我的参考书目,我认为它可以与 bibtex 一起使用,但也许我错了。

答案1

不要使用古老的bibtex。而是使用biber已在 tex 发行版中安装的版本:

\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}

使用pdflatex <file>, biber <file>,运行它pdflatex <file>

在此处输入图片描述

答案2

我是 Latex 的新手,我在这个版本的 apalike 上遇到了同样的问题。显然,这个版本是 apalike2.bst,正如有人在另一条评论中所说,这个版本太旧了。幸运的是,有一个新版本,apalike3.bst,它包含 doi 和 url 字段。我使用的是 Natbib(我不确定它是否适用于 Biblatex),我也在使用 Overleaf,所以我上传了 .bst 文件,你可以在此链接上下载https://drive.google.com/file/d/1ryzBhGzrK0MKEvziX9FzbLPRqgVvtLx8/view?usp=share_link

并且确实出现了 \bibliographystyle{apalike3.bst} 和 DOI。所以,请阅读我的消息的人纠正我的错误或说这是否是一个可靠的解决方案。我已经说过了,我是 latex 的新手,所以我不能说这是解决问题的方法。谢谢

相关内容