我正在努力解决参考书目条目中过多的空白问题。这个问题问 前,但通常建议在url
包之前包含连字符选项hyperref
对我来说不起作用。
这是一个可重现的例子:
\documentclass{article}
\usepackage{natbib}
\usepackage[margin=1in]{geometry}
\usepackage[hyphens,spaces,obeyspaces]{url}
\usepackage[hidelinks,breaklinks]{hyperref}
\begin{document}
\bibliographystyle{apalike}
\bibliography{mini}
\nocite{*}
\end{document}
和我的文件 mini.bib
@misc{feilden2017,
title = {Most Scientists 'Can't Replicate Studies'},
abstract = {Science is facing a "reproducibility crisis" as scientists fail to reproduce others' work, it is claimed.},
language = {en-GB},
howpublished = {\url{https://web.archive.org/web/20190413132210/https://www.bbc.com/news/science-environment-39054778}},
author = {Feilden, Tom},
month = feb,
year = {2017}
}
答案1
正如@Bernard 在评论中建议的那样,你应该替换
\usepackage[hyphens,spaces,obeyspaces]{url}
和
\usepackage[obeyspaces]{xurl}
加载xurl
包而不是url
包允许 URL 字符串不只是连字符和空格(和斜杠)字符换行,而是任何字符。但我仍将指定选项obeyspaces
,否则 URL 字符串中的空格字符将被完全抑制。
作为使用的完全受欢迎的副产品xurl
,排版bib条目其他部分难看的空白间隙将自动消失。
哦,这个xurl
包裹是相当新的;这可能解释了为什么你在查询中引用的早期帖子中找不到它。
\RequirePackage{filecontents}
\begin{filecontents}{mini.bib}
@misc{feilden2017,
title = {Most Scientists `Can't Replicate Studies'},
abstract = {Science is facing a ``reproducibility
crisis'' as scientists fail to reproduce others'
work, it is claimed.},
language = {en-GB},
howpublished = {\url{https://web.archive.org/web/20190413132210/https://www.bbc.com/news/science-environment-39054778}},
author = {Feilden, Tom},
month = feb,
year = {2017}
}
\end{filecontents}
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{apalike}
\usepackage[margin=1in]{geometry}
\usepackage[obeyspaces]{xurl}
\usepackage[hidelinks]{hyperref}
\begin{document}
\nocite{*}
\bibliography{mini}
\end{document}