[Tex/LaTex] Define path for packages in the LaTeX file (analog of \input@path or \graphicspath for \usepackage)

inputpackage-writingpackagespaths

How to specify path for additional packages in the LaTeX file itself?

For graphics, you use \graphicspath{{a}{b}}, and then \includegraphics{file} finds b/file.pdf. EDIT: it should be \graphicspath{{a/}{b/}}, with slashes at the end.

For \input, you use \def\input@path{{a}{b}}, and then \input{file} finds b/file.tex. EDIT: \def\input@path{{a/}{b/}} is the answer, with slashes at the end.

Can I use a similar construction for \usepackage, so that \usepackage{mystuff} would find b/mystuff.sty?

I know I can mess up with system configuration or environment variables, but I prefer to specify this in the file itself, so that my files could be compiled on another computer.

I know that I can simply use \usepackage{b/mystuff}, but it generates a warning You have requested b/mystaff but the package provides mystuff, and it is less portable — for example, it requires knowing in which specific folder mystuff.sty is.

Best Answer

\usepackage is a wrapper around \input so \input@path applies to that just as well, but it is better not to set \input@path and just set TEXINPUTS appropriately