My question is somewhat similar to this one: Type '{' '}' in url However, how can I write an uneven number of curly braces, e.g.:


The documentation of the URL package says, one should use another char than {}. However as soon as I load hyperref, the URL functional seems to be overwritten. The only working code I could produce was something like


which is still syntactically correct but produces the %7B in the output (where I want to have the human-readable '{').

Minimal example which does not compile correctly:

   foo \url+http://example.org/foo/\{bar+ bar

If I remove hyperref, the example works…

  • 4
    Instead of curly braces, use a non-special character that doesn't occur inside the URL string as the delimiter at both the beginning and the end of the string. E.g., with the + symbol as the delimiter character, write \url+http://example.org/foo/\{bar+. Of course, the url package must be loaded for this to work. (Aside: A "special" character, in a TeX context, is one of % & # \ _ ^ { }.
    – Mico
    Dec 11 '18 at 7:59
  • 1
    this does only work for the url package. If i load hyperref, I get a compile error
    – Ben
    Dec 11 '18 at 13:57
  • As I wrote very explicitly in my earlier comment, the url package must be loaded for my suggestion to work. If you don't load the url package, I can see no reason for why my suggestion would work. If you want to (or need to) load the hyperref package as well, you are of course free to do so. Just be sure to load hyperref after url.
    – Mico
    Dec 11 '18 at 14:07
  • 2
    That's what I tried. Minimal example: \documentclass{article}\usepackage{url} \usepackage{hyperref} \begin{document} foo \url+http://example.org/foo/\{bar+ bar \end{document} results in foo +http://example.org/foo/{bar+ bar (note the additional +-sign, I think hyperref destroys the functionality of url)
    – Ben
    Dec 11 '18 at 14:36
  • You are right that hyperref modifies \url in a way breaking its usage with a delimiter. It provides \nolinkurl with comment save the meaning of the original \cmd{\url} in \cmd{\nolinkurl} but this does not work for usage with delimiter.
    – user4686
    Jan 8 '19 at 15:09

As a workaround (perhaps a better way exists, not yet investigated) you can use this:

   foo \href{http://example.org/foo/\%7Bbar}{\texttt{http://example.org/foo/\{bar}} bar

enter image description here

The image is from usage of Acrobat Reader. In another PDF viewer, the tooltip displayed a brace, not %7B in the displayed URL with yellow background.

  • Nice solution, however it breaks the linebreak algorithm which should break urls on / characters and does not add a hyphen…
    – Ben
    Jan 20 '19 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.