4

I need to include the following URL in my text:

http://people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf

It's a two-column document to it must break into two lines and also the tilde should be displayed. So far I have been unable to include this URL due to these two complications. How do I do this? Thank you!

6
  • See the url package, made for this sort of thing
    – daleif
    Commented Oct 25, 2015 at 18:57
  • Hi, would \usepackage{url} and then \url{http://people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf} do the trick?
    – yo'
    Commented Oct 25, 2015 at 18:57
  • The lines break, but it seems the tilde ~ is cutting the URL to only the first half? I.e. to http://people.mech.kuleuven.be/. How do I fix this? Commented Oct 25, 2015 at 19:03
  • You don't provide a lot of context, so I don't know whether this would be a valid solution to your problem, but have you considered putting the long URL into a footnote? Text there is often typeset smaller, and not subject to the column layout.
    – RQM
    Commented Oct 25, 2015 at 21:38
  • You could also refer to it in a footnote, where the font is smaller, so you want have that problem. Commented Oct 26, 2015 at 12:34

3 Answers 3

4

Because you gave no MWE I had to guess. I used paper=A6 to simulate your column.

\documentclass[paper=A6]{scrartcl}

\usepackage[hyphens]{url}
\makeatletter
\g@addto@macro{\UrlBreaks}{\UrlOrds\do\r\do\u\do\b\do\i}
\makeatother
\usepackage{showframe} % to show typing area and margins


\begin{document}

text 
\url{http://people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf‌​}

\end{document}

With the line \g@addto@macro{\UrlBreaks}{\UrlOrds\do\r\do\u\do\b\do\i} I defined that an url can be broken at the letters r, u, b or i. You can add more if you need. The syntax is \do\ followed with the letter were the url can be broken.

Result:

enter image description here

For example test with adding \do\t to allow breaking at t.

I just found that question Forcing linebreaks in \url is a possible duplicate (see answer of Herbert Voss).

0

You can include or omit the http and play with UrlBreaks - decide depending on the width of your column.

enter image description here

\documentclass[10pt]{article}

\usepackage[showframe,text={3in,4in}]{geometry}

\usepackage[hyphens]{url}
\usepackage[pdftex,breaklinks]{hyperref}

\begin{document}


\url{http://people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf}

\url{people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf}

{\def\UrlBreaks{\do\n}
\url{people.mech.kuleuven.be/~bruyninc/tmp/HermanBruyninckx-robotics.pdf}
}

\end{document}
0

I would "translate" it to a shorturl and including http://alturl.com/7fs2x

   \documentclass[paper=A6]{scrartcl}
    \usepackage{url}
    \begin{document}
    \url{http://alturl.com/7fs2x}
    \end{document}

also easier to type your work is in a paper-version

2
  • 2
    I would advise against this, as it includes another point of failure: Instead of having to have faith in the permanence of the original link, now the author and reader also have to blindly hope that the URL shortener service used stays operational indefinitely, and that it does not change the link target for some reason. Depending on how informal the document authored by OP is, this might be a risk the author is willing to take, but e.g. for anything scientific, I would say the original link has to be included in the publication. OP could add a shorter URL for convenience, though.
    – RQM
    Commented Oct 25, 2015 at 21:30
  • @RQM I understand, but looking at the link, the document was in a tmp-folder, so I think it is only temporary ... But I agree it is not time-proof, if they change the short-links to something else. Although I don't have any issues with this for over 10 years. Commented Oct 26, 2015 at 12:32

You must log in to answer this question.

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