Text Formattinglink to a pdf document

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

link to a pdf document

Post by fatra2 »

Hi there,

I am stumped. I thought it would be terribly simple, but I can seem to find the answer to this question.

I would like to make a reference/link to a local pdf document. A bit like with a html hyperlink, I would want the output to be a "clickable" link that opens the document with adobe reader or something. Is there anyway to do so???

Cheers

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

link to a pdf document

Post by frabjous »

You could do that with the hyperref package. E.g., if the two PDFs were in the same folder, you could just use something like this:

Code: Select all

\documentclass{article}
\usepackage{hyperref}
\begin{document}
  \href{mypdf.pdf}{Click here to open mypdf.pdf!}
\end{document}
For more info, see the hyperref documentation.

I have to confess I don't see the point of such a thing, however. The link would only work for someone with both pdfs in the same folder. Consider using pdfpages instead just to include the one PDF inside the other. You could still use hyperref, only with internal links, from one part of the document to another.
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Re: link to a pdf document

Post by fatra2 »

Hi there,

Fact is that is works fine, as long as mypdf.pdf is in the same folder as the source code. But what if I want to refer to a file in another folder???

Cheers
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

link to a pdf document

Post by Bozack »

fatra2 wrote:But what if I want to refer to a file in another folder???
I'd guess that you could just use some other relative path - i.e. .../otherdirectory/mypdf.pdf instead of just mypdf.pdf (note that the .../ means that you go one directory "up").

I've not tested it - but I think it should work.
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Re: link to a pdf document

Post by fatra2 »

Hi there,

That's where I'm stumped. It does not seem to work with a relative path (../folder-something/mypdf.pdf), nor with a definitive path (D:/My documents/folder/mypdf.pdf)

Cheers
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: link to a pdf document

Post by Bozack »

In that case I'm not sure how to do it - I hope someone else can figure it out for you ;)
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: link to a pdf document

Post by frabjous »

Relative paths work for me.

However, try also:

\href{file:///C|/My Documents/folder/mypdf.pdf}{Click here.}
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

Re: link to a pdf document

Post by fatra2 »

Hi there,

From my understanding, this is not a relative path. On top, I don't understand, I tried varying many different parameters from what you say, and it does not seem to work for me. Don't know. I guess I'll stick with the reference to a file in the same folder, much less complicated, and mor portable. I just need to send the folder as a zip file to have a working .pdf document.

Cheers
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

Re: link to a pdf document

Post by karlisrepsons »

frabjous, fatra2: what LaTeX distributions / OSes you have? Just maybe that is important there? How else can relative paths work for one, but fail for another?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

link to a pdf document

Post by frabjous »

I'm using TeXLive 2008 on Ubuntu 9.04 (Linux). Relative paths work.

But I dual boot with Windows XP with MikTeX installed. I'll check that when I get a chance.

UPDATE:
Checked on Windows with MikTeX 2.7, compiling with pdflatex. Relatve paths work there too.

Could the issue be with the pdf viewing software? I'm using evince on Ubuntu, and Acrobat reader on Windows.

Code used (verbatim):

Code: Select all

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\href{../target.pdf}{LINKY!}

\end{document}
Post Reply