Discussion:
Link in LaTeX
(too old to reply)
db
2024-03-25 15:49:39 UTC
Permalink
I want to present a link to a pdf file in a pdf.
In the LaTeX body I have
http://www.dieterbritz.dk/bla.pdf
but I want this to be a link. I tried href, adding
the package hyperref, and that hides the link text,
and puts a red frame around each line in the
Contents section for some reason.

I also tried framing the link text with \ url{...}
but that didn't work.

So, how do I display the link text and make it a
link that can be clicked on to get to the pdf?
Eberhard W Lisse
2024-03-25 15:56:06 UTC
Permalink
RTFM (hyperref)

mfg, el

On 2024-03-25 17:49, db wrote:
[...]
adding> the package hyperref, and that hides the link text, and puts
a red frame around each line in the Contents section for some
reason.
[...]
Nicola Talbot
2024-03-25 17:39:47 UTC
Permalink
Post by db
I want to present a link to a pdf file in a pdf.
In the LaTeX body I have
http://www.dieterbritz.dk/bla.pdf
but I want this to be a link. I tried href, adding
the package hyperref, and that hides the link text,
and puts a red frame around each line in the
Contents section for some reason.
A red frame is the default behaviour and each line in the table of
contents is a hyperlink when hyperref is loaded.
Post by db
I also tried framing the link text with \ url{...}
but that didn't work.
So, how do I display the link text and make it a
link that can be clicked on to get to the pdf?
Try

\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks}% colour the link text
% or
\hypersetup{hidelinks}% links the same colour as surrounding text

\begin{document}
\tableofcontents
\section{Sample}
\href{http://www.dieterbritz.dk/bla.pdf}{Link to PDF}
\end{document}

Regards
Nicola Talbot
--
Dickimaw Books
Home: https://www.dickimaw-books.com/
Creating a LaTeX Minimal Example:
https://www.dickimaw-books.com/latex/minexample/
LaTeX Resources: https://www.dickimaw-books.com/latexresources.html
db
2024-03-26 08:43:12 UTC
Permalink
Post by Nicola Talbot
I want to present a link to a pdf file in a pdf. In the LaTeX body I
have http://www.dieterbritz.dk/bla.pdf but I want this to be a link. I
tried href, adding the package hyperref, and that hides the link text,
and puts a red frame around each line in the Contents section for some
reason.
A red frame is the default behaviour and each line in the table of
contents is a hyperlink when hyperref is loaded.
I also tried framing the link text with \ url{...} but that didn't
work.
So, how do I display the link text and make it a link that can be
clicked on to get to the pdf?
Try
\documentclass{article}
\usepackage{hyperref}
\hypersetup{colorlinks}% colour the link text % or
\hypersetup{hidelinks}% links the same colour as surrounding text
\begin{document}
\tableofcontents \section{Sample}
\href{http://www.dieterbritz.dk/bla.pdf}{Link to PDF} \end{document}
Regards Nicola Talbot
Great, thanks. Now, how to make the text "Link to PDF"
look like a link, e.g. colour it blue?
Nicola Talbot
2024-03-26 09:10:31 UTC
Permalink
On 26/03/2024 08:43, db wrote:> Great, thanks. Now, how to make the text
"Link to PDF"
Post by db
look like a link, e.g. colour it blue?
The colorlinks setting has different colours for different types of
links. The colour for external links is governed by urlcolor:

\hypersetup{colorlinks,urlcolor=blue}

The complete set of link colour options are listed in the section
"Extension options" in the hyperref manual (`texdoc hyperref` or
http://mirrors.ctan.org/macros/latex/contrib/hyperref/doc/hyperref-doc.pdf).

Regards
Nicola Talbot
--
Dickimaw Books
Home: https://www.dickimaw-books.com/
Creating a LaTeX Minimal Example:
https://www.dickimaw-books.com/latex/minexample/
LaTeX Resources: https://www.dickimaw-books.com/latexresources.html
Ulrich D i e z
2024-03-26 10:36:15 UTC
Permalink
Post by db
Great, thanks. Now, how to make the text "Link to PDF"
look like a link, e.g. colour it blue?
Now, how about looking into the fine manual of the hyperref package?

Ulrich
db
2024-03-29 15:01:24 UTC
Permalink
Post by Ulrich D i e z
Post by db
Great, thanks. Now, how to make the text "Link to PDF"
look like a link, e.g. colour it blue?
Now, how about looking into the fine manual of the hyperref package?
Ulrich
OK, OK, I will do that.
db
2024-03-30 14:44:07 UTC
Permalink
Post by Ulrich D i e z
Post by db
Great, thanks. Now, how to make the text "Link to PDF"
look like a link, e.g. colour it blue?
Now, how about looking into the fine manual of the hyperref package?
Ulrich
I did that. The last two package calls in the
preamblre are

\usepackage{hyperref}
\hypersetup{colorlinks,urlcolor=blue}

and in the text, I have

\href{http://www.dieterbritz.dk/bla.pdf}{bla.pdf}.

This works, the link is blue.
But the document also has a table of contents, and
it is rendered all red. I can't find anything in that
manual, nor in hycolor.pdf, on the contents' colour.
How do I suppress that, so that it comes out black?
Ulrich D i e z
2024-03-31 13:33:52 UTC
Permalink
db wrote:

[...]
This works, the link is blue.> But the document also has a table of contents, and> it is rendered all red. I can't find anything in that> manual, nor in hycolor.pdf, on the contents' colour.> How do I suppress that, so that it comes out black?
The manual of the most recent release of the package hyperref can be
found at:

http://mirrors.ctan.org/macros/latex/contrib/hyperref/doc/hyperref-doc.pdf

Depending on the TeX distribution in use by you you can probably use the
texdoc-utility for finding the manual belonging to the hyprref-release
installed on your computer.

On my system I can type the command

texdoc hyperref

on the shell and my pdf-viewer is launched and shows the manual of the
hyperref manual.

Section "5.6 Extension options" says:

| colorlinks boolean false Colors the text of links and anchors.
| The colors chosen depend on the type of
| link. At present the only types of link
| distinguished are citations, page
| references, URLs, local file references,
| and other links. Unlike colored boxes,
| the colored text remains when printing.
| linkcolor color red Color for normal internal links.
| anchorcolor color black Color for anchor text. Ignored by most
| drivers.
| citecolor color green Color for bibliographical citations in
| text.
| filecolor color cyan Color for URLs which open local files.
| menucolor color red Color for Acrobat menu items.
| runcolor color filecolor Color for run links (launch
| annotations).
| urlcolor color magenta Color for linked URLs.
| allcolors color Set all color options (without border
| and field option.)
| frenchlinks boolean false Use small caps instead of color for
| links.
| hidelinks Hide links (removing color and border).

Links in the table of contents are internal links, so you can change
the color of links of the table of contents to black via

\hypersetup{colorlinks,linkcolor=black}

For having all links, not just internal links, without color/border
you can use the option hidelinks:

\hypersetup{hidelinks}

You can switch color of all internal links only with links belonging to
the table of contents to black by adding \hypersetup-commands to the
.toc-file (which holds the data of the table of contents) via

\AtBeginDocument{\addtocontents{toc}{\begingroup\protect\hypersetup{linkcolor=black}}}
\AtEndDocument{\addtocontents{toc}{\endgroup}}

You can turn off both coloring of links and adding borders to links
only with all links belonging to the table of contents by adding
\hypersetup-commands to the .toc-file (which holds the data of the
table of contents) via

\AtBeginDocument{\addtocontents{toc}{\begingroup\protect\hypersetup{hidelinks}}}
\AtEndDocument{\addtocontents{toc}{\endgroup}}

Sincerely

Ulrich
db
2024-04-01 08:34:50 UTC
Permalink
Post by Ulrich D i e z
\hypersetup{colorlinks,linkcolor=black}
Thank you!

Dr Eberhard W Lisse
2024-03-26 13:46:50 UTC
Permalink
Seriously?

there are 60 references to this on google in English and 40 in German.

It is all in the hyperref manual...

ep
[...]
Post by db
Great, thanks. Now, how to make the text "Link to PDF"
look like a link, e.g. colour it blue?
Loading...