0

I have a quite long url that I want to include in-text in a document of mine and would like to avoid having it in the middle of my writing. Is there a way to make this into a simple reference to the hyperlink somewhere else? Maybe a referencing command similar to \includegraphics, but that would work for hyperlinks?

I would like to do something like the following

Lorem ipsum dolor sit amet, \href{reference to url elsewhere in document}{consectetur adipiscing elit}...

rest of document

url reference here or somewhere else
3
  • 1
    Perhaps you want to use a bibliography entry or a footnote? Commented Aug 19, 2022 at 2:40
  • A bibliography entry might work. My main issue is that long urls clutter the source code and I don't want that if I can help it. Commented Aug 19, 2022 at 3:15
  • Welcome. // Have a look at the hyperref package at ctan. One of its nice features is to deal with long urls in print.
    – MS-SPO
    Commented Aug 19, 2022 at 3:48

1 Answer 1

0

You can store url's in commands. If they contain special chars, escape them:

\documentclass{article}
\usepackage{hyperref}
\newcommand\myurla{https://ctan.org/pkg/hyperref}
\newcommand\myurlb{https://en.wikipedia.org/wiki/Uniform_Resource_Identifier\#Syntax}
\begin{document}
\href{\myurla}{link to hyperref on ctan}

\href{\myurlb}{link with hash}
\end{document}
1
  • Oh this is actually perfect. I don't know why I didn't think of it! Thank you very much. Commented Aug 20, 2022 at 18:33

You must log in to answer this question.

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