Forum moved here!

Home / LaTeX (hyperref) hyperlinks supposed to open files

dbitouze

Disclaimer: I’m not a Windows user and then not a regular SumatraPDF user.

Hi,

in this PDF file, the hyperlink is supposed to open the foo.tex target file with the default TeX editor of the OS (both the PDF file and foo.tex being in the same directory).

This works like a charm with e.g. Evince on Linux but not with SumatraPDFwhich displays the error “File C:\Users\denis\Documents\file:\foo.tex not found”.

It would be nice if SumatraPDF could be improved in this respect.

BTW, the PDF file has been generated from the following LaTeX file (compiled e.g. with pdflatex):

\begin{filecontents}[overwrite]{foo.tex}
\documentclass{article}
\begin{document}
I am the \texttt{foo.tex} file.
\end{document}
\end{filecontents}

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{run:foo.tex}{Open the \texttt{foo.tex} file in the default \TeX{} editor.}
\end{document}

Thanks.

GitHubRulesOK

Unfortunately, that means to open a linked file was a general open issue with version 3.2 and more recent pre-releases up to 3.3.13500 so ensure you are using a newer version.

Most should work with version 3.1.2 https://www.sumatrapdfreader.org/download-prev.html which may also work much better in general with LaTeX generated files.

The correct way to open a source TeX is to configure SumatraPDF so that it uses the synctex file to open the source TeX at the nearest line with a double click anywhere on the page and that should still be working in 3.2 see https://www.sumatrapdfreader.org/docs/Use-Sumatra-as-a-pre-viewer-for-LaTeX-editors.html

When you compile a TeX file the resulting synctex AND pdf should be built in the same directory. If you keep those 3 files together then the set can be opened with any other TeX editor even if not on the same platform, a TeX distro is not required. Thus in workflows with checkers only the author needs the compiler the other users only need any compatible editor to link back to the source TeX. Problems can arise when users insist on ignoring the expert experienced user advice not to use relative sub folders or try to separate chapters into folders. That may well work in simple cases but will almost certainly cause problems with makeindex and biblio apps.

So in latest SumatraPDF I open a compiled PDF double click anywhere on the page and NotePad (No TeX system installed) will open the TeX file for me.

If I change the default notepad %f to call a portable TeX editor I can add the commands to go to the correct line without installing a TeX distro.
Obviously i would need to include say MiKTeX portable / Tiny TeX or similar to re-generate the synctex and modified PDF.