1

I'm trying to link to a file in a folder named Códigos. My minimal code looks like this.

    \documentclass{article}
    \usepackage{hyperref}
    \begin{document}
        \href{run:./Códigos/test.c}{\texttt{test.c}}
    \end{document}

The PDF generates alright, but when I try opening the link, I realize that LaTeX has interpreted the accent as plain TeX code, and is as such unable to open the file.

I've tried using percent-encoding (writing \%F3 instead of ó), but this doesn't seem to work for file paths. I've also tried to use the verbatim package, but every time I do so, it just throws me a TeX capacity exceeded error.

Finally, I've tried using \detokenize on the file path, but when I do so, regardless of whether I use characters like ó or not, Adobe Acrobat treats the link as if I was trying to connect to it, rather than opening it, and doesn't let me open the file.

ViHdzP
  • 123

1 Answers1

1

So, I figured out something... sort of. I can use \detokenize not on the whole file path, but only on the part after run:.

    \href{run:\detokenize{./Códigos/test.c}}{\texttt{test.c}}

If I do this, though, different PDF viewers get weirded out. The PDF viewer that comes with TeXWorks does interpret the file path correctly (as verified by doing a mouseover), but doesn't let me open it for whatever reason. Adobe Acrobat Reader does try to open the file, but interprets the ó as ó, because of encoding mismatches. I've tried other viewers, but none seem to be able to actually open the file.

I guess the only solution here is to avoid the problem altogether, and remove the accent from the file path.

ViHdzP
  • 123
  • 3
    With o without LaTeX, avoid accents and spaces in directories and file names is always a good idea. – Fran Sep 14 '20 at 00:14