3

I know that one can use href or url to create links to open webpages, is there a way to insert a link to open a notebook file (mathematica?) i have it in the local folder but I cannot seem to get it to open. i have tried googling this and on mathematica stack exchange and wolfram alpha and on here. thanks

further info i have tried \href{run:./Invasion Analysis.nb}{Invasion Analysis.nb}, again, it writes the name but is not a clickable link and opens nothing

I have a file named "Invasion Analysis.nb" in the local folder with all the other tex files. if i type \href{Invasion Analysis.nb} or \url{Invasion Analysis.nb} it makes a link but is not clickable. i want the notebook file to open in mathematica when i click the link in the latex file.

I am working on Overleaf in case that makes any difference. enter image description here

\documentclass[12pt]{article}

\usepackage[letterpaper, margin=.45in]{geometry}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm,mathtools}
\theoremstyle{definition}
\usepackage{amsfonts}
\usepackage{cancel}
\usepackage{color}
\usepackage{enumitem}
\usepackage{mathrsfs}
\usepackage{esvect}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{ulem}
\usepackage{lscape}
\usepackage[fleqn]{nccmath}
\usepackage{empheq}

\begin{document}
\href{run:./Invasion Analysis.nb}{Invasion Analysis.nb}\\
\href{Invasion Analysis.nb}{Invasion Analysis}
\url{Invasion Analysis.nb}
\end{document}
  • I have a file named "Invasion Analysis.nb" in the local folder with all the other tex files. if i type \href{Invasion Analysis.nb} or \url{Invasion Analysis.nb} it makes a link but is not clickable. i want the notebook file to open in mathematica when i click the link in the latex file. i didnt put the code here because my file is 134 pages and counting. – elcharlosmaster May 31 at 0:07
  • i have tried \href{run:./Invasion Analysis.nb}{Invasion Analysis.nb}, again, it writes the name but is not a clickable link and opens nothing – elcharlosmaster May 31 at 0:14
  • \href{..} requires you to use a legal URI, i.e. something starting with https://, file:// or similar. However, linking with relative paths doesn't seem to work in this case, or I just cannot find the correct syntax. – siracusa May 31 at 0:18
  • I click the nb file on my desktop and I work on that, then I drag the file into the folder with the tex stuff on overleaf – elcharlosmaster May 31 at 0:27
  • My apologies, I am on a Mac – elcharlosmaster May 31 at 0:45
2

This seems to be viewer specific behavior.

(I own neither a Mac nor Mathematica. Instead, I tested this using Windows and an svg file, but that should not make a difference, I think.)

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\href{./test.svg}{foo}

\href{run:./test.svg}{bar}

\end{document}
  • In Overleaf, the links are not clickable. However, if I download the pdf from Overleaf and open it locally, they are (see below), so this may not be an issue for you (I suspect that opening a Mathematica file on Overleaf was not your intention).
  • In PDF-XChange Editor both links work. The tooltip displays file:///C:/<full path>/test.svg for the first and C:\<full path>\test.svg for the second, so they are different somehow. Clicking them results in Inkscape opening the file as desired.
  • In TeXstudio both links are clickable. The tooltip for the first shows ./test.svg, clicking it opens Windows Explorer in the location of the file. There is no tooltip for the second one and clicking it does nothing.

In summary, there is no "safe" way to do this in the sense that it will work in every pdf viewer. If you know beforehand how the document will be viewed, you can however just test the behavior and use \href accordingly.


PS: Feel free to add the behavior of other pdf viewers to the list above.

  • THANK YOU. this answers my question. If i download the pdf and have the nb file in the same folder it DOES become a clickable link. – elcharlosmaster May 31 at 11:26
  • Thank you KJO—I did not understand what you said before. I am not a programmer as you may have realized; and I didn’t know I had to download the pdf from overleaf to get it to become a live link. I know that others would have to have the same two files in the same folder on their desktop to be able to access them now. My most sincere apologies and thanks. – elcharlosmaster May 31 at 12:23
  • On my Mac I have a Mathematica notebook file ~/Desktop/plot.nb in my user account me. With the command \href{file:///Users/me/Desktop/plot.nb}{Plot saddle surface} in the LaTeX source, when I click the corresponding link in the generated .pdf, that notebook opens in Mathematica. (Of course it won't "run" the notebook, but you could set an option within the notebook that causes such initialization cells as you so mark to be evaluated automatically when the notebook opens.) You may use relative instead of absolute paths, too,as the accepted answer indicates. – murray May 31 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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