+4 votes
109 views
in Office by (242k points)
reopened
LaTeX: insert URL

1 Answer

+5 votes
by (1.6m points)
 
Best answer

How to insert a URL in LaTeX

To insert a URL in LaTeX, all you need is the right package and command. Just follow our instructions..

image image

You can use a URL to refer to an external homepage in your document. As known from Word or other text editors, the URL is automatically converted into a clickable link. In order to achieve the same in LaTeX, a suitable package must be imported and the correct command entered. More on this in this tipps + tricks article.

How to insert a URL in LaTeX

There are two packages with which URLs can be represented in LaTeX. Import either the url package with \usepackage{url} or the hyperref package with \usepackage{hyperref} . We recommend the latter - since the hyperref package can not only be used to link URLs, but also references to other chapters or figures. Problems with other packages can occur, which is why \usepackage{hyperref} the last package in the document should be imported.

So enter the command in the preamble of your LaTeX documents \usepackage{hyperref} . Then URLs can be \url{...} generated in the text with the command . Here is sample code for using URLs:

\documentclass{article}
\usepackage{hyperref}
\begin{document}

Unsere Internetseite ist auf \url{https://www.heise.de/tipps-tricks/} erreichbar.
\end{document}

If you convert the whole thing into a PDF, you get a clickable URL. By default, the display of URLs with hyperref is not really appealing. In order to make links more recognizable, it is advisable to display them in blue. A few settings must be made for this. We show below what you have to set in the options of hyperref :

\usepackage[
colorlinks=true,
urlcolor=blue,
linkcolor=green
]{hyperref}

The links in the compiled document look like this:

image

...