GeneralURL with % included, doesn't compile with Overleaf

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ebigunso
Posts: 9
Joined: Sat Jul 29, 2017 5:04 pm

URL with % included, doesn't compile with Overleaf

Post by ebigunso »

Hello. I'm using Overleaf to create a report, and I have run into an issue where Overleaf wouldn't compile URLs with % included in it.

I am using the URL package, and here is what I am having trouble with:
--figure here--
\caption{stuff \protect \footnotemark}
--figure end here--
\footnotetext{ITER Organization \url{https://www.iter.org/album/Media/7%20-%20Technical} (2018/5/29)}

Since I am using the URL package, if I try to escape the % as in \%, the resulting PDF will show the \ as well which is not ideal. When I have it in the form I posted above, the % is considered a start of a comment line even though it's inside a \url{}.
I haven't had this issue on my local TeX Live install, so I'm confused. What is going on, and how can I fix it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

URL with % included, doesn't compile with Overleaf

Post by Stefan Kottwitz »

Hi,

in general it would be good if you would post a small piece of (compilable) code that shows the issue. So we can test it and fix it. Otherwise every reader has to build a test example on his own and possibly simply skips the topic if there's not much time.

Here is a solution: using \urldef to define the URL in advance:

Code: Select all

\documentclass{article}
\usepackage{url}
\urldef{\technical}\url{https://www.iter.org/album/Media/7%20-%20Technical}
\begin{document}
\begin{figure}[!htbp]
--figure here--
\caption{stuff \protect \footnotemark}
\end{figure}
\footnotetext{ITER Organization \technical (2018/5/29)}
\end{document}
You can see how handy such a small example is: you could open it by just one click in Overleaf (top right of the code block) and see the result. ;-)

Stefan
LaTeX.org admin
ebigunso
Posts: 9
Joined: Sat Jul 29, 2017 5:04 pm

URL with % included, doesn't compile with Overleaf

Post by ebigunso »

Thank you! This works perfectly.

I'll try to post a full working piece of code next time. Thanks for the advice as well :)
Post Reply