6

I would like to have

commons.wikimedia.org/wiki/File:Blue_Unknot.png

as text for the link

https://commons.wikimedia.org/wiki/File:Blue_Unknot.png

As I want line-breaking, I can't use

\href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{commons.wikimedia.org/wiki/File:Blue_Unknot.png}

but

\url{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}

shows https://.

Is it possible to tell get rid of the protocol in the displayed text, but still have a correct link?

Minimal not-working example

\documentclass[a6paper]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage{hyperref}   % links

\begin{document}
    \section{url}
    Trivialer Knoten: \url{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}

    \section{href}
    Trivialer Knoten: \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{commons.wikimedia.org/wiki/File:Blue\_Unknot.png}

    \section{href + path}
    Trivialer Knoten: \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{\path{commons.wi‌​kimedia.org/wiki/File:Blue_Unknot.png}}
\end{document}

which gives

enter image description here

  • 1
    you know there should be a MWE but I'd guess \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{\path{commons.wikimedia.org/wiki/File:Blue_Unknot.png}} using url pack's \path command (which I don't think hyperref touches) – David Carlisle Jan 30 '14 at 20:18
  • This did not work (see image above). I've also added a M(n)WE. – Martin Thoma Jan 30 '14 at 20:34
  • You have two spurious characters between wi and ki – egreg Jan 30 '14 at 20:37
  • @egreg: What are "spurious characters"? Which "wiki" do you mean? How did you see that? And how can I remove them (because I can't see them!) – Martin Thoma Jan 30 '14 at 20:48
  • @moose Can't you see the result in the third example? Just select the word wikipedia, hit delete and retype it. – egreg Jan 30 '14 at 21:19
2

As noted in comments you can use \path (you have unrelated spurious characters in your MWE, this just deletes them)

enter image description here

\documentclass[a6paper]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage{hyperref}   % links

\begin{document}
    \section{url}
    Trivialer Knoten: \url{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}

    \section{href}
    Trivialer Knoten: \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{commons.wikimedia.org/wiki/File:Blue\_Unknot.png}

    \section{href + path}
    Trivialer Knoten: \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}{\path{commons.wikimedia.org/wiki/File:Blue_Unknot.png}}
\end{document}
1
\section{href}
{\sloppy Trivialer Knoten: 
 \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}%
      {commons.wikimedia.org/wiki/File:Blue\_Unknot.png}\par}

may help. The text can only be hyphenated at regular hyphenation points. Or insert a space which is not misleading:

\section{href}
{\sloppy Trivialer Knoten: 
 \href{https://commons.wikimedia.org/wiki/File:Blue_Unknot.png}%
   {commons.wikimedia.org/ wiki/File:Blue\_Unknot.png}\par}

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.