1

Is there a way to use a windows environmental variable in \href that uses this environment variable in the output PDF document?

When I use

\href{run:\%foo\%\\bar.cpp}{bar.cpp}

The PDF Reader I use (Adobe Acrobat Pro) appends SomeDriveLetter:\ to the front of the link to make

SomeDriveLetter:\%foo%\bar.cpp

of course this drive does not have the path that foo points to.

Rather, it should go to

%foo%\bar.cpp
Heiko Oberdiek
  • 271,626
  • do you want to look up the environment variable value from within TeX or do you simply want to write a literal % and \ into the href? – David Carlisle Nov 02 '16 at 21:28
  • No I want the pdf reader to look up the environmental variable value. – Lightyear Buzz Nov 02 '16 at 21:45
  • you can use \@percentchar and \@backslashchar to get a % and \ but which pdf readers will do anything with a url of the form run:%foo% ? – David Carlisle Nov 02 '16 at 22:08
  • To clarify, here %var% is the Windows/Command Prompt's syntax for environment variable, just like $var in bash. ■ So you just need to invoke cmd with appropriate arguments (I think the syntax is cmd /c ⟨command⟩); however you can't just pass arguments to cmd so you need to write a wrapper batch script (Windows shell script) and execute that. – user202729 Jul 04 '22 at 17:16

1 Answers1

3

The answer is no. The PDF format does not support environment variables in launch actions.

Heiko Oberdiek
  • 271,626