我需要在“_”和“-”处断开 URL:
http://www.domain.org/word/word-word_(word-word)/。
谢谢此主题,通过使用\RequirePackage[hyphens]{url}
和\usepackage[hyphens]{url}
,我在 '-' 处换行,但它似乎在 '_' 处不起作用。欢迎您的建议。
更新
\RequirePackage[hyphens]{url}
\documentclass[a4paper,12pt]{article}
\usepackage[hyphens]{url}
\makeatletter
\def\do@url@hyp{\do\-\do\_}
\makeatother
\begin{document}
\url{http://www.dom.it/aaaa/word-word\_word-word\_word-word\_word-word\_word-word\_word-word\_word-word------------------------------------------------------------------------------------------------------------------(xyz)}
\url{http://www.dom.it/aaaa/word-word\_word-word\_word-word/word-word\_word-word\_word-word\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_(xyz)}
\end{document}
因此,它似乎可以与“_”一起使用,但不能与许多“-”一起使用。欢迎您发表评论。
答案1
该hyphens
选项执行
\def\do@url@hyp{\do\-}
而您只想\do\_
对此进行添加。
\documentclass{article}
\usepackage{url}
\makeatletter
\def\do@url@hyp{\do\-\do\_}
\makeatother
\begin{document}
\begin{minipage}{0pt}
\hspace{0pt}\url|http://www.domain.org/word/word-word_(word-word)/|
\end{minipage}
\end{document}
这minipage
只是为了尽可能地强制分裂。