Oct 122008

I‘d like to thank Prof Michael Friendly for telling me this: just create a hyperlink to the file with the run protocol and then you can open a file directly from the hyperlink. For example, in LaTeX with hyperref package, you may use \href{run:path/to/some.file}{some link} to open this some.file in your PDF. This is a useful hack that I have been looking for over a long time.

Related Posts

7 Responses to “How to Open a File from a Hyperlink”

Comments (7)
  1. Ft says:

    Thank you!!

  2. gilberto says:

    it didn’t work for me!! :cry:

    • Yihui Xie says:

      At least it works for Windows and MikTeX (compile by pdflatex), e.g.

      \documentclass{article}
      \usepackage{hyperref}
      \begin{document}
      \href{run:c:/downloads/run.txt}{hi}
      \end{document}
      
  3. gilberto says:

    At the end I got it working on my Mac:

    \documentclass{article}
    \usepackage{hyperref}
    \begin{document}
    \href{run:./sameDirectoryAsMaster/run.txt}{hi}
    \end{document}

    But the link only worked with AdobeAcrobat, not with Apple’s Preview.

  4. Peter says:

    Can you get it to open at a specific page in the target document?

Leave a Reply

(required)

(required)

WWW.YIHUI.NAME XIE@YIHUI.NAME © 2007 - 2010 by Yihui Xie