I am seeking to include in a latex run a range of files off different paths; I am working in MiKTeX 2.9 under Windows 10. I am unable to get \string~ to point to %USERPROFILE%.
A MWE to illustrate is:
\documentclass{article}
\usepackage{graphicx}
% I put mypic.png in my Home Folder; I'm running Windows 10, MiKTeX 2.9,
% executing pdflatex both in command line and in TeXWorks
%
\newcommand\HomeFolder{\string~} %1
%\newcommand\HomeFolder{$HOME} %2
%\newcommand\HomeFolder{C:/Users/MyLoginName} %3
\begin{document}
\includegraphics{\HomeFolder/mypic}
\end{document}
uncommenting in turn the \newcommand labelled 1, 2, and 3. The results are, respectively:
! LaTeX Error: File `~/mypic not found.
! LaTeX Error: File `$HOME/mypic not found.
and success on 3. (That one puts in my %USERPROFILE% explicitly.) Does tilde point somewhere other than %USERPROFILE% in MiKTeX? If so, is there a way to reset ~ to %USERPROFILE? Or is the issue more general?
Put differently, is the "\includegraphics{\string~/foo} should work" in David Carlisle's answer in Reference file relative to the home directory known to apply (or not) to MiKTeX 2.9? This ought to be pretty basic but I have not been able to see direct statement on it one way or the other.
(This MWE above illustrates the point I'm trying to make about accessing paths off my home folder. I realise that if my home directory is in my TEXINPUTS path, then I don't need to qualify the inclusion of mypic.png. However, the use cases I am working with are about paths more generally, of which the problem above is just a special case.)
The report https://sourceforge.net/p/miktex/bugs/2535/ discusses how it is pdftex.exe, not MiKTeX, that is the problem for handling tilde. Here, however, the problem applies to pdflatex as well, whereas in 2535's illustration pdflatex works the tilde fine, even if there pdftex does not.
pdflatex %USERPROFILE%/tests/test.utf8works for me provided the file exists. – Christian Schenk Dec 06 '20 at 11:20