[OS X TeX] linking to and opening a .tex file using hyperref?

Ross Moore ross.moore at mq.edu.au
Wed Jun 13 16:53:45 EDT 2018


Hi Gary,

On Jun 14, 2018, at 6:30 AM, Gary L. Gray <euler at psu.edu<mailto:euler at psu.edu>> wrote:

This is sort of Mac related in that I do not understand why it works on my Mac. :-) And I apologize in advance for a rather long message.

From within a presentation, I would like to be able to link to and open a .tex file. Some searching in the hyperref manual alludes to the fact that this can be done, but I sure can’t find the scheme for doing so. So I tried the following

\href{file:///Users/gray/Documents/Teaching/LaTeX\ Course/Lectures/2018\ -\ Fall/Lecture\ 03/simple_document/simple_doc.tex}{Simple \LaTeX\ Document}

which shows the title as a link, but clicking on it does nothing and when one hovers, it shows nothing.

Use relative paths, as you discovered.
Typically — probably for security reasons — applications aren’t allowed to use arbitrary full paths.
Otherwise malicious code within a PDF (or other) document could do potentially damaging things.


The next thing I did was to head over to TeX StackExchange (that place intimidates me a more than a little) where I found this

https://tex.stackexchange.com/questions/41539/does-hyperref-work-between-two-files/41605#41605<https://protect-au.mimecast.com/s/TM8JCYW86EsnBJOuj6nwD?domain=tex.stackexchange.com>

The answer from Sony suggests using “run:” before the path to the file. So I tried this

\href{run:/Users/gray/Documents/Teaching/LaTeX\ Course/Lectures/2018\ -\ Fall/Lecture\ 03/simple_document/simple_doc.tex}{Simple \LaTeX\ Document}

which also did not work. In this case it linked to:

file:///Users/gray/Documents/Teaching/LaTeX%20Course/Lectures/2018%20-%20Fall/Lecture%2003//Users/gray/Documents/Teaching/LaTeX%5C%20Course/Lectures/2018%5C%20-%5C%20Fall/Lecture%5C%2003/simple_document/simple_doc.tex

so you can see that some extraneous stuff was inserted.

Finally, rather than use an absolute path, I used a relative one as

\href{run:simple_document/simple_doc.tex}{Simple \LaTeX\ Document 2}

and amazingly, this worked.

Keep the file names simple and relative.
You cannot guarantee that URL encoding ( all that %20  and %5C  stuff) will work on all systems.

In this case, the link is to

file:///Users/gray/Documents/Teaching/LaTeX%20Course/Lectures/2018%20-%20Fall/Lecture%2003/simple_document/simple_doc.tex

and so the .tex file opens in the default app for such files. By the way, this also works:

\href{run:./simple_document/simple_doc.tex}{Simple \LaTeX\ Document}

So, can anyone explain what this run thing is doing?

 run  is also what you do when you play a video, or audio file from within a PDF document.
Just as with hyperlinks, an “annotation" is used to interface between an area on the page,
and some action that you want to perform.

There are many things that can be done with annotations.
The Hyperref  package has extensive coding that helps setup an annotation to do exactly what you want.


Searching the web, it appears to be a Windows thing, but works perfectly on my machine. More importantly, what should I be doing to open a .tex file as I am doing here?

Any insights would be greatly appreciated.

Gary


Hope this helps.

Ross


Dr Ross Moore

Mathematics Dept | 12 Wally’s Walk, 734
Macquarie University, NSW 2109, Australia

T: +61 2 9850 8955  |  F: +61 2 9850 8114<tel:%2B61%202%209850%209695>
M:+61 407 288 255<tel:%2B61%20409%20125%20670>  |  E: ross.moore at mq.edu.au<mailto:rick.minter at mq.edu.au>

http://www.maths.mq.edu.au<http://mq.edu.au/>


[cid:image001.png at 01D030BE.D37A46F0]<http://mq.edu.au/>


CRICOS Provider Number 00002J. Think before you print.
Please consider the environment before printing this email.<http://mq.edu.au/>

This message is intended for the addressee named and may
contain confidential information. If you are not the intended
recipient, please delete it and notify the sender. Views expressed
in this message are those of the individual sender, and are not
necessarily the views of Macquarie University.<http://mq.edu.au/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://email.esm.psu.edu/pipermail/macosx-tex/attachments/20180613/56ee2ad3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4605 bytes
Desc: image001.png
URL: <https://email.esm.psu.edu/pipermail/macosx-tex/attachments/20180613/56ee2ad3/attachment.png>


More information about the MacOSX-TeX mailing list