Talk:LaTeX/Hyperlinks

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Hyperref also works with plain 'latex', not only 'pdflatex'. One must specify the right driver instead of 'pdftex', though. I only tested it with 'dvipdfm' (dvi->pdf directly), so I don't know if the ps output has hyperlinks, but the pdf output does.

See for example the documentation at http://www.tug.org/applications/hyperref/manual.html

Contents

[edit] Addition

How about custom colours? Maybe you could add examples, like dark blue or teal (as in biblatex documentation for instance).

One can define custom colors for hyperref package by writing a small style file that adds to the predefined colors in the color.sty. Specifically create the following mycolor.sty file containing the following lines:

\RequirePackage{color}

\definecolor{bwgreen}{rgb}{0.183,1,0.5}

\definecolor{bwmagenta}{rgb}{1,0.169,0.909}

\definecolor{bwblue}{rgb}{0.317,0.161,1}


These particular colors provide a clear high contract result when printed in color or black and white. Therefore they are useful when making figures that need to be readable in color or monochrome.

To use the newly defined colors with hyperref in your LaTeX document:


\documentclass{article}

\usepackage{mycolor}

\usepackage{hyperref}

\hypersetup{linkcolor=bwmagenta}

[...]


[edit] Algorithms package

The following is stated in the end of the section named "Problems with links"

"The problem can also occur with the algorithms package: because each algorithm uses the same line-numbering scheme, the line identifiers for the second and follow-on algorithms will be duplicates of the first."

As I get around 300 errors due to this, any method for fixing it is much appreciated.

[edit] Problem with column separators

What if the url contains a symbol & (ampersand)? How to use \href?

  • In the URL section of an href, it doesn't seem that the TeX processor much cares about ampersands. If the TeX processor gives you an error, escape the ampersand like "\&". If the link doesn't work as you expect it to in the final product, escape the ampersand for the browser by writing "&". You may have to end up escaping the ampersand twice, writing "\&"
  • If it's the description that contains the ampersand, just use \& instead of & to escape the ampersand for the TeX processor.
68.118.159.98 (talk) 06:53, 9 November 2008 (UTC)

[edit] Underlining?

Is there any way to automatically underline links in the final output using the hyperref package, as is common in the world wide web? Perhaps an "underline=true" configuration option? - 68.118.159.98 (talk) 06:55, 9 November 2008 (UTC)

  • The configuration option that works for me is "pdfborderstyle={/S/U/W 1}", but I've googled that some older pdf viewer may have problems rendering it.

[edit] Will table of contents be displayed as bookmarks (structured tree) in .pdf?

Hyperlinks will be in the pdf, but what about the bookmarks of the pdf? Kazkaskazkasako (talk) 10:32, 28 January 2009 (UTC)

  • everything that's included in the ToC will be included as bookmark. Because the Table of content isn't mentioned in the ToC itself it will not be included as a bookmark. Thijs(User talk:Thijs.de.meester) 9:58 14 july 2009 (UTC)

[edit] \hyperref example

It seems that including a \ref inside a \hyperref destroys its purpose: for the example given -- "\hyperref[mainlemma]{lemma \ref{mainlemma}}" -- only the lemma number is hyper-refed, and the "lemma " (sans quotes) part is not, whereas "\hyperref[mainlemma]{lemma blah}" would hyperref "lemma blah" (sans quotes). I will let someone more knowledgable than me correct it or correct me before changing it myself. Unco (talk) 23:08, 13 April 2009 (UTC)

[edit] \hyperlink and \hypertarget

I found it much more useful to use \hyperlink{labelname}{descriptive text about link} and \hypertarget{labelname}{} for referencing things in my document than \hyperref[labelname}{some text}. In fact, I couldn't get the \hyperref command to work in conjunction with a \label{labelname}, so I gave up and luckily found this little tidbit. Hope it helps.

[edit] ampersand problem

I need to have an ampersand in my url. I have to escape it by \& to be able to compile latex code. But in the url the whole \& is the shown and destroys the link. Anybody knows a workaround? Hm ok the problem only exists within a table where & is the column separator. --62.178.198.156 (talk) 20:48, 19 October 2009 (UTC)