我正在使用 overleaf 中的 IEEEtrans 模板撰写一篇文章,但我刚刚注意到带有 URL 的技术报告参考无法正确编译:
%Smith2040
@electronic{Smith2040,
author = "Smith, Matthew Nitch",
title = "The number of cars worldwide is set to double by 2040",
url = "\url{https://www.weforum.org/agenda/2016/04/the-number-of-cars-worldwide-is-set-to-double-by-2040}"
}
使用时我遇到了上述问题\usepackage{url}
。但是,使用时\usepackage{hyperref}
我遇到了致命错误。
答案1
使用IEEEtran
参考书目格式和超链接url
包,将字段的内容放在包装器中是错误的\url{...}
。你应该只写
url = "https://www.weforum.org/agenda/2016/04/the-number-of-cars-worldwide-is-set-to-double-by-2040",
顺便说一句,我认为填写此条目的year
和字段是一个非常好的主意。organization
以下示例加载xurl
包,而不是url
包。唯一的区别是前者允许在格式化的 URL 字符串中换行任意字母。
\RequirePackage{filecontents}
\begin{filecontents}{testbib.bib}
@electronic{Smith2040,
author= "Smith, Matthew Nitch",
title = "The number of cars worldwide is set to double by 2040",
year = 2016,
organization = "World Economic Forum",
url = "https://www.weforum.org/agenda/2016/04/the-number-of-cars-worldwide-is-set-to-double-by-2040"
}
\end{filecontents}
\documentclass{IEEEtran}
\bibliographystyle{IEEEtran}
\usepackage[spaces,hyphens]{xurl} % allow arbitrary line breaks in a formatted URL string
\usepackage[colorlinks,allcolors=blue]{hyperref}
\begin{document}
\cite{Smith2040}
\bibliography{testbib}
\end{document}