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'– David Carlisle Dec 15 '23 at 23:36$TEXINPUTS, then how can I achieve what I want (making a custom folder plus subfolders visible to tex)? Is there an alternative method? – jan Dec 16 '23 at 02:47~/texmf? It's possible to add an addition tree either permanently (as I do for/usr/share/...) or temporarily as people sometimes do for testing. But there are particular reasons for those structures and it isn't clear whether you plan to structure this as another tree anyway. – cfr Dec 16 '23 at 02:59input) with subfolders with files that are shared between projects (figures, examples, graphs, tables, pictures, etc.). – jan Dec 16 '23 at 03:25$TEXMFHOME. (2) In other cases, I keep them outside, especially if they are relevant to only a certain category of documents (e.g. they're chunks or examples I use in teaching materials, but not writing or research). Especially for teaching, I add some of these directories in custom classes or packages and only quite specific ones in each project or document config. All custom classes and packages are under$TEXHOME. These also define commands which utilise other, task-specific places. – cfr Dec 16 '23 at 05:21.bashrcor similar: this is a design decision by Apple - as such you cannot use exactly the same methods for all OSs. – Joseph Wright Dec 16 '23 at 07:51TEXINPUTS=.:~/custompath/input//:totexmf.cnf, whilekpsexpand '$TEXINPUTS'returns the custom location, when compiling I still get the file not found error (whether in a GUI program or from the command line). – jan Dec 16 '23 at 16:48TEXINPUTS=.:~/custompath/input//: to texmf.cnfsounds wrong, that will mask the original setting, probably something likeTEXINPUTS.tex = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//you want to set TEXMFHOME as described in the comments in texmf.cnf% Per-user texmf tree(s) -- organized per the TDS, as usual. To define % more than one per-user tree, set this to a list of directories in % braces, as described above. (This used to be HOMETEXMF.) ~ expands % to %USERPROFILE% on Windows, $HOME otherwise. TEXMFHOME = ~/texmf– David Carlisle Dec 16 '23 at 16:59TEXMFHOME = ~/custompath/input//to/usr/local/texlive/2023/texmf.cnfdoes work but only if I move the file in question to a subfolder of~/custompath/input/tex/latex/– "organized per the TDS, as usual" (I get it now). But what I was trying to accomplish is to directly input the folder without yet again having to bury the files two levels down (as then my current method with a symlink is still easier). From what I had been reading, it seemed that TEXINPUTS was the way to go but I couldn't get it to work. – jan Dec 19 '23 at 15:33TEXINPUTS.pdflatex = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//so you wantTEXINPUTS.pdflatex = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//,/some.path.to/somewhereif you just set it to your path pdflatex won't look in the standard places so\documentclass{article}wouldn't findarticle.cls– David Carlisle Dec 19 '23 at 15:44TEXINPUTS.pdflatex = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//,/~/custompath/inputto/usr/local/texlive/2023/texmf.cnf– but still getting file not found :( – jan Dec 19 '23 at 15:56~/custompath/input/figures/project1/testinput.tex) – jan Dec 19 '23 at 15:57