# Multi-line URLs are not properly colored in floating captions

With document class amsart, urls are not properly colored when spanning more than one line in figure captions and table captions. I want them colored. The xurl package is not relevant to the bug, but a solution should not contradict xurl.

\documentclass{amsart}

\usepackage{xurl}

\begin{document}

\begin{table}
\caption{
The last line is not properly colored
\url{https://tex.stackexchange.com/questions/999999/The-last-line-is-not-properly-colored.}
}
\end{table}

\begin{figure}
\caption{
The last line is not properly colored
\url{https://tex.stackexchange.com/questions/999999/The-last-line-is-not-properly-colored.}
}
\end{figure}

\end{document}


Try package caption, because it solves quite a few package incompatibilities.
\documentclass{amsart}

• Just to clarify: Is this how you would order these packages? caption after hyperref? Dec 28 '20 at 15:43
• The caption package needs to know, which other relevant packages are used. Therefore, I have loaded it after package hyperref. It it is loaded before hyperref, the caption package defers its code to \begin{document} . Dec 28 '20 at 16:08