1

I'm trying to do this:

\documentclass{article}
\begin{document}
\begin{minipage}{2in}
\ttfamily
https://www.stackoverflow.com/questions/ask
\end{minipage}
\end{document}

The URL is not being hyphenated (because LaTeX doesn't hyphenate monospace fonts) and I'm getting "Overfull \hbox". The only solution I've found is to redefine the forward-slash to "forward-slash with a space" (maybe also do this with the dot). How can I do this?

PS. For some reason, this question was closed, while the answer is provided in this one.

yegor256
  • 12,021
  • @Marijn yes, it does but doesn't work in my case (I don't know why) – yegor256 Aug 28 '21 at 17:26
  • When I try \documentclass{article} \usepackage{xurl} \begin{document} \begin{minipage}{2in} \url{https://www.stackoverflow.com/questions/ask} \end{minipage} \end{document} it breaks the url (between stackoverflow. and com). – Marijn Aug 28 '21 at 17:30
  • @Marijn I'm not using \url command in my example above – yegor256 Aug 29 '21 at 04:06
  • I know you are not using the \url command but you can change your code to start using this command, because it is an easy way to allow for line breaks in urls. Do you have a reason for not wanting to use this command? If so then there may be a solution that addresses that reason while still using \url. – Marijn Aug 29 '21 at 07:24

0 Answers0