我有一个参考书目,其中包含了指向出版网站的超链接。现在我想在超链接内添加换行符,因为参考文献太长了。
到目前为止,我发现的所有选项都不起作用,如果能得到任何帮助,我将不胜感激。抱歉,如果这有一个明显的解决方案,我是 Latex 初学者。我在 Overleaf 上使用 LaTex 编译器。
这是我的代码:
\documentclass{scrbook}
\usepackage[backend=biber, style=chem-angew]{biblatex}
\usepackage{hyperref}
\DeclareFieldFormat{doilink}{%
\iffieldundef{url}{%
#1%
}{%
\href{http://dx.doi.org/\thefield{url}}{#1}%
}%
}
\DeclareBibliographyDriver{article}{%
\printtext[doilink]{%
\usebibmacro{author}%
\newunit
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{note+pages}%
}%
}
\addbibresource{Library.bib}
\begin{document}
\noindent
Reference 1\autocite{RN398}
\newline
Reference 2\autocite{RN404}
\printbibliography[heading=none]
\end{document}
以及我的参考资料
@article{RN398,
author = {Stabile, Paolo and Lamonica, Alessandro and Ribecai, Arianna and Castoldi, Damiano and Guercio, Giuseppe and Curcuruto, Ornella},
journal = {Tetrahedron Lett.},
volume = {51},
number = {37},
pages = {4801-4805},
url = {10.1016/j.tetlet.2010.06.139},
year = {2010}
}
@article{RN404,
author = {Cordes, D. B. and Hua, G. and Slawin, A. M. and Woollins, J. D.},
journal = {Acta Crystallogr C},
volume = {67},
number = {Pt 12},
pages = {509-514},
url = {10.1107/S0108270111049900},
year = {2011}
}
答案1
以下代码使用 pdfLaTeX、LuaLaTeX 和 XeLaTeX 正确地换行。
它只是对您的代码进行了轻微的修改,以使用字段doi
而不是url
,因为10.1016/j.tetlet.2010.06.139
它不是一个 URL,并且代码始终链接到 DOI 解析器。
\documentclass{scrbook}
\usepackage[backend=biber, style=chem-angew]{biblatex}
\usepackage{showframe}
\usepackage{hyperref}
\DeclareFieldFormat{doilink}{%
\iffieldundef{doi}
{#1}
{\href{https://doi.org/\thefield{doi}}{#1}}}
\DeclareBibliographyDriver{article}{%
\printtext[doilink]{%
\usebibmacro{author}%
\newunit
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{note+pages}%
}%
}
\begin{filecontents}{\jobname.bib}
@article{RN398,
author = {Stabile, Paolo and Lamonica, Alessandro
and Ribecai, Arianna and Castoldi, Damiano
and Guercio, Giuseppe and Curcuruto, Ornella},
journal = {Tetrahedron Lett.},
volume = {51},
number = {37},
pages = {4801-4805},
doi = {10.1016/j.tetlet.2010.06.139},
year = {2010},
}
@article{RN404,
author = {Cordes, D. B. and Hua, G. and Slawin, A. M. and Woollins, J. D.},
journal = {Acta Crystallogr C},
volume = {67},
number = {Pt 12},
pages = {509-514},
doi = {10.1107/S0108270111049900},
year = {2011},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Reference 1\autocite{RN398}
Reference 2\autocite{RN404}
\printbibliography[heading=none]
\end{document}
请注意,屏幕截图并未重现链接框,但链接确实存在。
为了验证 Overleaf 上的一切是否也能按预期运行,请按照https://www.overleaf.com/read/zvsvhcvgsbgy请参阅背页上的 MWE。