Adding links to PDFs , both internal and external, certainly only makes sense for digital copies of the file. Nevertheless, they still come in handy, for example for actual WWW-addresses or as direct reference inside a document.
Local references
As usual, you first need the package which handles the links:
\usepackage{hyperref}
This does the job for the moment. The package “hyperref” will automatically insert links wherever you place a citation or reference (\cite{}, \ref{}).
Global references
Referencing to URLs or local files can be done as follows:
\href{url}{text}
Try this:
\href{http://texblog.wordpress.com}{\bf{Blog on Latex Matters}}
Colour references
So far, the references were marked by a colour rectangle around them, which is not very appealing (unless you are using Apple Preview). Here is how you remove the border and if you wish define your own colours for references.
Either add this optional argument to the previous package:
\usepackage[colorlinks]{hyperref}
or use a new line and set the colour:
\usepackage{hyperref}
\hypersetup{colorlinks}
If you want to define your own colours, you will have to use the latter, as the colours are part of the argument of “hypersetup”. But in order to do so, you first need to define colours, which is why you will need the colour-package:
\usepackage{color}
Then you can define different colours you may want to use for your references, e.g.:
\definecolor{darkred}{rgb}{0.5,0,0}
\definecolor{darkgreen}{rgb}{0,0.5,0}
\definecolor{darkblue}{rgb}{0,0,0.5}
Latex uses the standard RGB (red/green/blue) colour model. The three values define the intensity for each channel within the interval (just because Latex looks nicer:-).
Now you are ready to use the defined colours, by extending the previously used command:
\hypersetup{ colorlinks,
linkcolor=darkblue,
filecolor=darkgreen,
urlcolor=darkred,
citecolor=darkblue }
Note: If your tex-distribution does not contain the hyperref-package, you can download it here (hyperref.zip), including the complete documentation.
Timothée
Cool
And by the way, thanks for your blog. very useful.
How do you manage to add LaTeX in your WordPress posts?
tom
Thanks!
You can only use math-environment Latex:
dollar latex your-code dollar (just replace dollar by $)
Similar to what you do in Latex actually, but you need to tell WordPress that you want to use Latex.
Cheers
El Niño
$ latex \mathbb{M}\alpha t \hbar \quad \widetilde{\imath} \oint \quad \mathcal{B} e \vec{a} \cup \tau \check{\imath} \Phi \upsilon \pounds $
Does it work ?
tom
You just need to omit the space after the dollar sign and it should work.
No guarantee for the formula:-).
Cheers,
Tom
virsaar
hey great blog…
really helpful…
Rob Dyke
Great blog. Thanks. Here are some more hack that you can do with the pdflatex generation.
Here is how I poked my pdflatex config file to make the following modifications to my PDF output.
hamen
Absolutely usefull!
Thanks
RnD HW
thanks… I’ve been looking for this…
the default colors are too contrast (red and light green)….
Tony
Thanks a lot for this post 😉 Finally got rid of those nasty red frames with use of the colorlink option
Hemanth
Thanks for the information. It was really helpful and worked for me.
Allan
I am trying to write a scientific paper and i intend to use the hyperref package for coloured links however when i use it,my Url exceeds one colum what can i do to solve this.
This is my code:
My problem is that the url exceed one column of the Latex Paper and enters into other text,how can i solve this?
tom
Hi Allan,
Thanks for your e-mail. I moved your comment to this blog post, since the answer may also help others with the same problem. Hope that’s ok with you.
Try loading the url package with the
hyphens
option. Here is an example:Hope that helps,
Tom.
Allan
thats my code for the bibliography its a long thing,its over the one column and yet am using two columns.
tom
Hi Allan,
Try this:
Allan
Thats ok,now i need to add a video to my beamer presentation but i am having trouble with media9 and media15
tom
Hi Allan,
Did you try the flashmovie package? See the example included in the package for some sample code. In case you are using Mac OSX, it doesn’t seem to work in Preview, you’d need to switch to Adobe Reader.
Best, Tom.
Allan
That doesnt seem to work for me lol,i need to understant either media9.sty or media15.sty
Kelly
Hi,
I’m able to insert links using \cite{} and \ref{} and generate a pdf with these links working. However I need to insert signatures into my pdf using Adobe Reader (it’s a PhD thesis).
As soon as I “save as” the pdflatex-generated pdf with the signatures inserted, the next time I open the pdf all of the links do not work.
Any help would be appreciated.
tom
Hi Kelly,
I assume you mean digital signatures, which frankly speaking I have never used. However, you may find these links informative: here and here.
Good luck with your thesis!
Tom.
Preetham A. M.
Dear Tom,
First of all thank for your time and effort. I am have trouble in figuring out start page in pdf reader (Adobe or others). I would like to have my pdf start page from the chapter, after pagenumbering{arabic} i.e. pdf page shall start at page number 1.
Right after:
I did tried \usepackage[pdfstartpage = some number x]{hyperref}. Since the TOC, list of figures and other contents page number can grow, every time I need to change number ‘x’.
So, I am really looking forward for some auto-mechanism such that provided that line/piece of code and complied, after opened the pdf page (in Adobe reader/Acrobat), it should right away starts from that page.
Example:
Placed in particular location, it shall start on that particular page.
Further, I have attached my typical example file:
Thank you,
tom
Hi!
Interesting question, thanks! Try the first answer to the same question on tex.SX.
Let me know if you need help with that.
Cheers, Tom
Marco Smolla
Thanks that was very helpful!!
tom
Thanks, appreciate the feedback. Tom