如何hyperref
在环境中破坏 URL tabular
。请考虑以下示例:
\documentclass{article}
\usepackage[colorlinks=true,linkcolor=black,anchorcolor=black,citecolor=black,menucolor=black,runcolor=black,urlcolor=black,bookmarks=true]{hyperref}
\usepackage{breakurl}
\begin{document}
\url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\begin{tabular}{l l}
A long url &
\url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\end{tabular}
\end{document}
第一个中断了,第二个没有。输出如下:
我在用pdflatex
。
答案1
使用p{10.0cm}
需要长度的列规范。这使得列可以有换行符:
\documentclass{article}
\usepackage[colorlinks=true,linkcolor=black,anchorcolor=black,citecolor=black,menucolor=black,runcolor=black,urlcolor=black,bookmarks=true]{hyperref}
\usepackage{breakurl}
\begin{document}
\noindent
\url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\noindent
\begin{tabular}{l p{10.0cm}}
A long url &
\url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\end{tabular}
\end{document}
答案2
列l
规范无法控制列宽,因此无法正确拆分 URL。可以使用p{<len>}
列规范(其中<len>
是已知的 TeX 长度)修复列,或者使用tabularx
包裹将表格宽度固定为某个最大值:
\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage[colorlinks=true,linkcolor=black,anchorcolor=black,citecolor=black,menucolor=black,runcolor=black,urlcolor=black,bookmarks=true]{hyperref}% http://ctan.org/pkg/hyperref
%\usepackage{breakurl}% http://ctan.org/pkg/breakurl
\begin{document}
\noindent\url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\noindent\begin{tabularx}{\textwidth}{l X}
A long url & \url{http://www.avery/long/url?zz/very/very/long/this/should/break/very/long/long.html}
\end{tabularx}
\end{document}