There are numerous questions on this site (and elsewhere on the web) how to define $TEXINPUTS and other strategies for including non-standard locations to be searched by TeX. See, for instance the discussions here, here (for texmaker), here (for Texstudio), here, here (for MikTeX), here (for TeXShop), here (macOS), or here. From all those discussions (a lot of helpful explanations buried in comments) I gather that there are many different ways of defining the variable and that it depends on the operating system, TeX distribution, and program what will work and what won't.
I'm on macOS and use TeXShop. I have a location at ~/custompath/input/ with a bunch of subfolders for graphics, figures etc., which I would like TeX to access without having to specify explicit paths (which I know I can do via \def\input@path{...}).
Temporarily, I've learned I can define the variable via command line with
export TEXINPUTS=.:~/custompath/input//: A more permanent solution should be to add TEXINPUTS = .:~/custompath/input//: either to
~/.bashrc or
/usr/local/texlive/YYYY/texmf.cnf The first method (via export TEXINPUTS=.:~/custompath/input//:) does work as expected when I run pdflatex from the same command line window. I understand that since it's temporary I can't expect this to work in TeXShop.
But I fail at getting any of the other methods to work. Placing the magic line in ~/.bashrc has no effect whatsoever.
When I add it to texmf.cnf, then I can run from the command line
kpsexpand '$TEXINPUTS' and that does return .:~/custompath/input//:
However, compiling (again from the command line pdflatex ~/custompath/testing.tex) gives me:
`! LaTeX Error: File `testinput.tex' not found.` And, needless to say, nothing works from TeXShop.
Is there a bulletproof way to define an additional location to be searched by TeX that will always work, no matter if I'm invoking LaTeX from the command line, using TeXShop, or another front end? My hunch is the answer is no, but perhaps someone can explain how to get it to work for different systems/installations/front ends. (I'm particularly interested in TeXShop, of course, but it seems people on other platforms frequently run into similar issues, so maybe it's worth to have an authoritative answer for all scenarios ...).
MWE for what it's worth, with testinput.tex at ~/custompath/input/figures/project1/ :)
\documentclass{article} \begin{document} test document \par \input{testinput.tex} %\input{~/custompath/input/figures/project1/testinput.tex} % \end{document}
~/texmfis already in your default path so the simplest thing is to use that name rather than~tex. Checkkpsexpand '$TEXINPUTS'$TEXINPUTS, then how can I achieve what I want (making a custom folder plus subfolders visible to tex)? Is there an alternative method?