I have three MacOSs, and set different names for User and Home Folder. I take Emacs as my default editor in those devices.

Using Emacs to edit tex-document, I found the code \input{~/Documents} and \input{$HOME/Documents} can't work when compiling, Error message said not found such file. To make it work, I must write the absolute path, such as \input{/Users/Abel/Documents} .

The trouble is due to the different account names and home folders in the three devices, I don't want to alter them into a same name. Q: Is there any method that keeping the situation and Emacs can recognize \input{~/Documents} or \input{$HOME/Documents} ?

Here are some extra information:

  1. Use other editors, such as TeXShop, this trouble doesn't happen both \input{~/Documents} and \input{$HOME/Documents} make effect.
  2. ~/ can be known as Home directory by Emacs, typing C+ x + f, and ~/ , All Emacs(s) in devices point to the right Home Directory.
  • AFAIK, this is not an Emacs issue but a LaTeX issue. Note that $HOME works for me in a WSL-Ubuntu environment. – Tobias Jan 21 at 15:52
  • Wow, in my case, $HOME also works when I use a non-Emacs editor. – Zoe Rowa Jan 22 at 0:40
  • 1
    What is the value of M-x getenv <RET> HOME <RET>? If HOME is not in the environment of Emacs it cannot be passed to LaTeX. But, that case would be rather strange. – Tobias Jan 22 at 4:45
  • 1
    The slash at the end of HOME is bad. Run M-x setenv <RET> HOME <RET> /Users/abel <RET> and try again. – Tobias Jan 22 at 4:49
  • 1
    Under Linux I would now advise you to fix the HOME path in your /etc/passwd file. But, I do not know whether this advice is valid for MacOS. A hacky solution would be (setenv "HOME" (directory-file-name (getenv "HOME")) in your init file. I assume that is approximately what TeXShop does before running LaTeX. – Tobias Jan 22 at 5:07

Your Answer

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

Browse other questions tagged or ask your own question.