我的参考文献部分有时会在单词之间显示很多空格,我想删除这些空格。
例如,在下面的屏幕截图中,我想删除“描述链接”文本中的多余空格:
我知道我可以使用 mbox(例如\mbox{Describing a link}
),但我想应用一些选项来全局避免这种情况。
更新:主要答案适用于\url
,但现在使用时我遇到了同样的问题\href
:
\bibitem{Reference2} Some Name, \href{mailto:[email protected]}{[email protected]}
以下是完整的示例文档:
\documentclass[12pt, a4paper, twocolumn]{article}
\usepackage{xurl} % Added based on the initial answer
\usepackage{hyperref}
\hypersetup{colorlinks = true, urlcolor = blue, linkcolor = blue, citecolor = blue}
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{abstract}
\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}
\title{Test Article}
\author{Test Author}
\begin{document}
\twocolumn[
\begin{@twocolumnfalse}
\maketitle
\begin{abstract}
\noindent
Test abstract.
\newline\newline
\end{abstract}
\end{@twocolumnfalse}
]
\section{Section1}
Lorem ipsum dolor sit amet\cite{Reference1}, consectetur adipiscing elit. Fusce maximus nisi ligula. Morbi laoreet ex ligula, vitae lobortis purus mattis vel. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ac metus ut turpis mollis placerat et nec enim. Duis tristique nibh maximus faucibus facilisis. Praesent in consequat leo. Maecenas condimentum ex rhoncus, elementum diam vel, malesuada ante. Fusce pulvinar, mauris pretium placerat venenatis, lectus ex tempus lacus, id suscipit libero lorem eu augue. Interdum et malesuada fames ac ante ipsum primis in faucibus.
\section{Section2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce maximus nisi ligula. Morbi laoreet ex ligula, vitae lobortis purus mattis vel. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ac metus ut turpis mollis placerat et nec enim. Duis tristique nibh maximus faucibus facilisis. Praesent in consequat leo. Maecenas condimentum ex rhoncus, elementum diam vel, malesuada ante. Fusce pulvinar, mauris pretium placerat venenatis, lectus ex tempus lacus, id suscipit libero lorem eu augue. Interdum et malesuada fames ac ante ipsum primis in faucibus.
\begin{thebibliography}{99}
\bibitem{Reference1} Describing a link, \url{https://example.com/this_is_a_really_long_link_that_wraps_many_lines}
\bibitem{Reference2} Some Name, \href{mailto:[email protected]}{[email protected]}
\end{thebibliography}
\end{document}
答案1
在您的案例中,您可以简单地添加\usepackage{xurl}
前言。一定要xurl
在包之前调用hyperref
(如果您省略了它,hyperref
它本身会调用包url
并得到您得到的结果...)!
使用以下代码
\documentclass[12pt, a4paper, twocolumn]{article}
\usepackage{xurl} % <===================================================
\usepackage{hyperref}
\hypersetup{colorlinks = true, urlcolor = blue, linkcolor = blue, citecolor = blue}
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{abstract}
\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small\itshape}
\title{Test Article}
\author{Test Author}
\begin{document}
\twocolumn[
\begin{@twocolumnfalse}
\maketitle
\begin{abstract}
\noindent
Test abstract.
\newline\newline
\end{abstract}
\end{@twocolumnfalse}
]
\section{Section1}
Lorem ipsum dolor sit amet\cite{Reference1}, consectetur adipiscing elit. Fusce maximus nisi ligula. Morbi laoreet ex ligula, vitae lobortis purus mattis vel. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ac metus ut turpis mollis placerat et nec enim. Duis tristique nibh maximus faucibus facilisis. Praesent in consequat leo. Maecenas condimentum ex rhoncus, elementum diam vel, malesuada ante. Fusce pulvinar, mauris pretium placerat venenatis, lectus ex tempus lacus, id suscipit libero lorem eu augue. Interdum et malesuada fames ac ante ipsum primis in faucibus.
\section{Section2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce maximus nisi ligula. Morbi laoreet ex ligula, vitae lobortis purus mattis vel. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ac metus ut turpis mollis placerat et nec enim. Duis tristique nibh maximus faucibus facilisis. Praesent in consequat leo. Maecenas condimentum ex rhoncus, elementum diam vel, malesuada ante. Fusce pulvinar, mauris pretium placerat venenatis, lectus ex tempus lacus, id suscipit libero lorem eu augue. Interdum et malesuada fames ac ante ipsum primis in faucibus.
\begin{thebibliography}{99}
\bibitem{Reference1} Describing a link, \url{https://example.com/this_is_a_really_long_link_that_wraps_many_lines}
\end{thebibliography}
\end{document}
得到结果: