# Break url in tabular

How can I break hyperref URLs in a tabular environment. Consider the following example:

\documentclass{article}

\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}


The first one breaks, the second one doesn't. The output looks like:

I am using pdflatex.

Use the p{10.0cm} column specification, which require a length. This makes the column able to have line breaks:

\documentclass{article}

\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}


The l column specification has no control over the column width and therefore doesn't break the URL properly. Either fix the column using a p{<len>} column specification (where <len> is a known TeX length), or use the tabularx package to fix the table width to some maximum:

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
%\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}​


hyperref loads the url package by default, which does a good job of breaking URLs.