3

I am searching for a way to allow URLs to line-break at any character within a marginal comment created by the package luatodonotes. I installed the xurl package, which is one of the options for allowing URLs to break at any character within text.

The xurl package works for me within text but not within \todo{} notes. The \todo{} command is a moving argument, so using \url{} within it causes an error. Prefacing \url{} with \protect makes the URL render, but it still does not break as desired.

Can anyone suggest a solution? Minimal example and screenshot below.

% !TEX TS-program = lualatex
\documentclass[letterpaper,11pt]{memoir}
\usepackage[english]{babel}

\usepackage{xurl}

\usepackage[dvipsnames]{xcolor}
\usepackage{luatodonotes}%

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. %
\todo{this todo note has just plain text}%
%
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. %
\todo{this todo note contains a long URL using the texttt command. It renders fine but does not break: \texttt{http://www.blahblah.com/blah/blah/and-more/and-more/and-more.html}}%
%
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Here is a really long URL in the text block using the \textbackslash url command. It renders and breaks properly (well, almost): \url{http://www.blahblah.com/blah/blah/and-more/and-more/blah/blah/and-more/and-moreblah/blah/and-more/and-more-and-more.html} %
%
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.%
\todo{this todo note contains a long URL using \textbackslash protect\textbackslash url. It renders but does not break: \protect\url{http://www.blahblah.com/blah/blah/and-more/and-more/and-more.html}}%

\end{document}

The results

1 Answer 1

3

I don't think that it can work with luatodonotes. If you look closely you will see that it not only prevents url to break but also hyphenation. It simply stores everything in a hbox and then breaks it into lines. With todonotes it works:

\documentclass[letterpaper,11pt]{memoir}
\usepackage[english]{babel}

\usepackage{xurl}

\usepackage[dvipsnames]{xcolor}
\usepackage{todonotes}%
\urldef\myurl\url{http://www.blahblah.com/blah/blah/and-more/and-more/and-more.html}
\begin{document}
\listoftodos

\bigskip
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.%
\todo{this todo note contains a long URL using \textbackslash urldef. \myurl}%

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.%
\todo{this todo note contains a long URL using \textbackslash protect. \protect\url{http://www.blahblah.com/blah/blah/and-more/and-more/and-more.html}}%

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .