![长 href 在文本和引用中都超出了页面范围,我该如何防止这种情况?](https://linux22.com/image/435016/%E9%95%BF%20href%20%E5%9C%A8%E6%96%87%E6%9C%AC%E5%92%8C%E5%BC%95%E7%94%A8%E4%B8%AD%E9%83%BD%E8%B6%85%E5%87%BA%E4%BA%86%E9%A1%B5%E9%9D%A2%E8%8C%83%E5%9B%B4%EF%BC%8C%E6%88%91%E8%AF%A5%E5%A6%82%E4%BD%95%E9%98%B2%E6%AD%A2%E8%BF%99%E7%A7%8D%E6%83%85%E5%86%B5%EF%BC%9F.png)
我有很长的 URL,但似乎在文本和引用中都被截断了。
\documentclass{article}
\usepackage[english]{babel}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
url with no hyphens that is long and already starts halfway across the page \href{http://sadlkjfdlkabfskalbjflskdbgfksldabvladbcviuldasbcalsuncilsalxbvucx.com/}{http://sadlkjfdlkabfskalbjflskdbgfksldabvladbcviuldasbcalsuncilsalxbvucx.com/}
random citation \cite{zotero-180}
\bibliographystyle{naturemag}
\bibliographystyle{alpha}
\bibliography{sample}
\end{document}
我的围兜文件:
@misc{zotero-180,
title = {{{this long citation also appears in bib gets cut}}},
file = {C\:\\Users\\myfile.html},
howpublished = {http://sadlkjfdlkabfskalbjflskdbgfksldabvladbcviuldasbcalsuncilsalxbvucx.com/}
}
答案1
好吧,您可以简单地xurl
像这样加载包:
\begin{filecontents*}{\jobname.bib}
@misc{zotero-180,
title = {{{this long citation also appears in bib gets cut}}},
file = {C\:\\Users\\myfile.html},
howpublished = {\url{http://sadlkjfdlkabfskalbjflskdbgfksldabvladbcviuldasbcalsuncilsalxbvucx.com/}},
}
\end{filecontents*}
\documentclass{article}
\usepackage[english]{babel}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{xurl} % <===================================================
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
url with no hyphens that is long and already starts halfway across the page
\url{http://sadlkjfdlkabfskalbjflskdbgfksldabvladbcviuldasbcalsuncilsalxbvucx.com/} % <===============
random citation \cite{zotero-180}
%\bibliographystyle{naturemag} % <======================================
\bibliographystyle{alpha}
\bibliography{\jobname}
\end{document}
请看一下,我使用的是\url
您以前使用的\href{}{}
方法xurl
。
得到的pdf是: