Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to add hyperlinks to external pdfs (which are saved in the local file system) and to specific pages of these pdfs to a LaTeX document on MacOS X and opening them with Skim.app (default).

My problem is: it works, if the pdf is in the same path as the latex document and I use a \href{./filename.pdf} (However, the [page=2] option does not work then.)

But if I try to use an asolute path like \href{/Users/myaccount/folder/test.pdf} or {/Volumes/Data/folder/folder/test.pdf}, a click on the link in the pdf created by LaTeX does not open the linked file.

I also tried to use "file:///Volumes/.." and "run:///volumes..", but it does not work. However, I can successfully open a link like "file:///Volumes/Data/Folder/file.pdf" in Safari!

How can I fix that?

I'm using TeXLive 2010 on OS X 10.6.5 and pdflatex for compiling.

minimal example:

\documentclass[11pt]{scrreprt}

\usepackage{hyperref}
\hypersetup{bookmarksopenlevel={2}, bookmarksopen = true, 
colorlinks= false, linkbordercolor = 0 1 0.5, urlbordercolor = 0 0 1
}

\begin{document}


that works, but it opens on page 1 and not on page 3
\href[page=3]{run://test.pdf}{relative path}

that does not work:
\href[]{/Volumes/Daten/test.pdf}{absolute path}


\end{document}
share|improve this question
    
Related question: pdfpages and linktodoc –  Martin Scharrer Mar 6 '11 at 17:36
    
@Martin: unfortunately the solution is not the same. –  Matthew Leingang Mar 7 '11 at 22:02
    
@Matthew: sorry, I do not understand what you mean. "the same" like what? –  Martin Mar 9 '11 at 19:24
    
sorry, my comment was to Martin Scharrer. What I meant was that the answers to the question Martin S linked to did not solve this problem. They all involve relative, not absolute paths. –  Matthew Leingang Mar 9 '11 at 20:58
    
How i can open some pdf file on specific page? I use \href[page=3]{run://test.pdf}{relative path}, it works fine, file is opened, but on page 1. Can you help? –  user11986 Feb 22 '12 at 12:26
show 1 more comment

4 Answers

I found a very short but very hacky solution. Just abuse the nice and working relative links:

\href{../../../../../../../../../../../../home/juve/phd/papers/my-linked-paper.pdf}{file}

I generate such links into my bib files and can now quickly jump from my references to the paper itself.

share|improve this answer
    
ouch! Anyway, thanks for sharing your workaround! –  Martin Mar 15 '13 at 9:52
1  
I use this mainly for draft work where I need some quick shot links to all files in a dir and do not want to maintain bibtex entries for dozens of files that will be not considered later on. –  Juve Mar 15 '13 at 10:01
add comment

After some hours with Skim, I have these conclusions

  1. I presume that Skim is defined to be the default PDF viewer, and Preview is the default PNG and JPG viewer.

  2. \href{file://absolute path to/calledfile.png}{link} works fine with Skim, instead of PNG you can use JPG. Examples: \href{file:///Users/altermundus/Desktop/bosch2.jpg}{jpg abs link} or \href{file:///Users/altermundus/Desktop/Einstein.png}{png abs link}

  3. But \href{file://absolute path to/calledfile.pdf}{link} does not work with Skim. Example: \href{file:///Users/altermundus/Desktop/Newton.pdf}{Newton.pdf absolute path}

  4. It's possible to use \href{run:calledfile.pdfor \href{run:calledfile.png but the file called must be in the same folder that your initial PDF. Remark: with Skim we can see that the link is: file://localhost/.../calledfile.pdf localhost/... is the absolute path for your main.pdf file.

  5. Possible: \href{run:/tmp/file.pdf you need to put the calledfile inside tmp/ The path of called file is relative to main.pdf file: <path to the main file>/tmp/calledfile.pdf.

  6. A new try for the PDF file. \href{run:myscript.sh}{myscript}. You can create a script file name myscript.sh with

    \#!/bin/bash 
    
    open -a skim /Users/altermundus/Desktop/Newto.pdf
    

    This script must be executable : $ chmod +x /Users/altermundus/Desktop/myscript.sh Then, in main.pdf you write

    \href{run:myscript.sh}{myscript}
    

    This script must be in the same folder than main.pdf or a subfolder .

    My test file is :

    % the file is compiled inside a folder named : myfolder 
    %   /Users/altermundus/myfolder 
    \documentclass{scrartcl}
    \usepackage{graphicx}
    \usepackage{hyperref}
    \begin{document}
    
    % absolute path problem with pdf file     
    \href{file:///Users/altermundus/Desktop/bosch.jpg}{bosch.jpg absolute path}\par
    % relative path  
    \href{run:Einstein.png}{Einstein in the same folder}\par %  myfolder/Einstein.png  
    \href{run:tmp/Einstein.png}{Einstein in a subfolder}\par 
      % myfolder/tmp/Einstein.png
    \href{run:texteinv.pdf}{Newton.pdf}\par % myfolder/Newton.pdf 
    \href{run:bosch.jpg}{run:bosch.jpg}\par % myfolder/bosch.jpg
    \href{run:/tmp/myscript.sh}{Newton.pdf}\par % myfolder/tmp/myscript.sh
    % but myscript calls /Users/altermundus/Desktop/Newton.pdf
    \href{file:///Users/altermundus/Desktop/myscript.sh}{Newton.pdf absolute path}\par
    
    \end{document}
    

    Final remarks: With Preview, only \href[]{run:texteinv.pdf}{Newton.pdf} works and only Adobe Reader and Adobe Acrobat Pro are able to open \href{file:///Users/altermundus/Desktop/Newton.pdf}{Newton.pdf absolute path}.

I await an answer from Christiaan Hofman (the author of Skim).

share|improve this answer
    
thanks for your efforts. I read a post on the skim users mailinglist - I suppose it's yours. –  Martin Mar 9 '11 at 19:25
    
@Altermundus: When trying something similar SKIM opens the script in a text editor. How can I tell it to run the script? –  Dror Dec 9 '11 at 16:17
    
@Dror Your script must be executable : $ chmod +x –  Alain Matthes Dec 9 '11 at 23:21
    
@Altermundus: It is. In any case, what worked for me is tex.stackexchange.com/a/37737/412. Thanks! –  Dror Dec 10 '11 at 5:26
add comment

I poked around and found the same information as you:

  • \href{run:file.pdf}{file} will open the pdf in the default application for pdfs
  • \href{run:///global/path/to/file.pdf} will attempt to open a file at the path point given by the current directory with ///global/path/to/file.pdf appended. Obviously this file doesn't exist, so you get an error.
  • \href{file:///global/path/to/file.pdf} creates a file link in the PDF with location "Macintosh HD:Volumes:global:path:to:file.pdf" Note the colons. I'm not sure if this is the correct path, though, since in POSIX style paths the Volumes comes first, then Macintosh HD. In any case, the link doesn't open anything.

    Edit: I opened the PDF in Acrobat (Pro) to verify the link's location. When I manually edited the link in Acrobat to have it open the file I wanted, the location was changed to "Macintosh HD:global:path:to:file.pdf" (no Volumes). So some agent is miswriting or misreading that location.

No solution from me, but one workaround is to make a symbolic link of the target file into your document's directory. Then you can use the \href{run:test.pdf}{local} syntax you describe above.

share|improve this answer
    
@Matthew: with \href{file:///global/path/to/file.pdf} do you have try with "adobe reader" ? –  Alain Matthes Mar 6 '11 at 17:47
    
@Altermundus: Tried with with Adobe Acrobat Pro, which was how I was able to examine the created link. –  Matthew Leingang Mar 7 '11 at 2:45
    
@Matthew: thank you. So it seems to be a special problem of OS X and the pdf readers?! :-( Your hint on the paths is a big step into the right direction, thank you for that. Is there a way to see the "real" file path of the link without having Acrobat Pro? but adding symbolic links for my >800 pdfs is also not an option for me. –  Martin Mar 7 '11 at 6:05
    
@Altermundus: using Adobe Reader is not an option for me. :-( I need the features of Skim. –  Martin Mar 7 '11 at 7:04
    
@Martin: me too :( I need to post on the OS TEX list to get a specific answer and at the author of Skim. But I think Skim and Preview use the same engine. –  Alain Matthes Mar 7 '11 at 7:43
show 4 more comments

I proceed like this

\href[]{file:///Users/ego/Desktop/bosch2.jpg}{absolute path}

This works fine with Skim and not with Previewbut if the link is with a pdf file, I need to open the first pdf with adobe reader. The problem seems specific to Mac os x and the pdf viewers.

share|improve this answer
    
thanks for your help! –  Martin Mar 7 '11 at 6:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.