0

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} 
22
  • 1
    I would expect ~/texmf is already in your default path so the simplest thing is to use that name rather than ~tex. Check kpsexpand '$TEXINPUTS' Commented Dec 15, 2023 at 23:36
  • don't use the environment variable TEXINPUTS as that masks the setting in texmf.cnf and your editor, if launched from the dektop may not share the same environment Commented Dec 15, 2023 at 23:38
  • @DavidCarlisle The point of my question was to find a way to input a random custom folder that is not already in the default path. I've edited the question to make that clearer, calling the folder in my homefolder now "custompath" as opposed to "tex" to not create any confusion. In regards to your second comment, if not $TEXINPUTS, then how can I achieve what I want (making a custom folder plus subfolders visible to tex)? Is there an alternative method? Commented Dec 16, 2023 at 2:47
  • 1
    you can symlink your tex folders under texmf Commented Dec 16, 2023 at 8:16
  • 1
    sorry I have no mac. I'm out. Stick to symlinks? Commented Dec 19, 2023 at 16:34

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.