46

I am using TeX Live 2012/Debian on Linux Mint 14.

I am wondering what the right definition of the TEXINPUTS variable is.

5
  • 2
    Don't define TEXINPUTS in the environment if you don't have compelling reasons to do it, such as the need to set some shared input directory.
    – egreg
    Commented Jan 14, 2013 at 11:11
  • 3
    I have a local folder where I put extra stuff in. Therefore I need to define the variable and somehow adding :$TEXINPUTS in the definition does not work.
    – Jana
    Commented Jan 14, 2013 at 12:03
  • 2
    you should not set TEXINPUTS. You'll get problems when using ConTeXt or LuaTeX beside pdflatex
    – user2478
    Commented Jan 14, 2013 at 12:30
  • 4
    @Herbert, what problems? How should we refer to collections of other latex content instead? We have used TEXINPUTS to manage large collections of files created by different people for many years. What should we do to use lualatex?
    – Leo
    Commented Mar 6, 2014 at 19:43
  • Side note, looks like the "default value" that corresponds to an empty entry or "trailing colon" is kpsewhich -var-value TEXINPUTS. Of course trailing colon(/semicolon) is cleaner though
    – user202729
    Commented May 28, 2023 at 16:44

2 Answers 2

60

You can always put your personal files in a proper subdirectory of ~/texmf; for instance, your personal .sty files could go in

~/texmf/tex/latex/jana/

This "personal tree" is always consulted for input files before the other trees and doesn't need hashing (with texhash aka mktexlsr). This is by far the preferred method for personal input files.

If instead you have a folder somewhere, you can set the variable TEXINPUTS in the environment by saying something like

export TEXINPUTS=/path/to/the/local/folder//:

The // means that TeX programs will search recursively in that folder; the trailing colon means "append the standard value of TEXINPUTS" (which you don't need to provide).

Note that TEXINPUTS is usually not set; it takes a value as soon as a TeX program is started (by reading a set of texmf.cnf files). However, if the program finds it in the environment, it follows the rule sketched above.

If you need the current directory to be searched for inputs before the local one, then

export TEXINPUTS=.:/path/to/the/local/folder//:

should be the best choice.

11
  • 3
    Problem is that I do not know the right way.
    – Jana
    Commented Jan 14, 2013 at 13:17
  • 4
    @Jana Did you try my answer? As I've added, for clarity, you don't need to add the value of TEXINPUTS, the trailing colon suffices.
    – egreg
    Commented Jan 14, 2013 at 13:32
  • 1
    @Leo In my experiment it works with lualatex
    – egreg
    Commented Mar 6, 2014 at 20:50
  • 1
    I am aware that this problem solved now (this post is 8 years old) but I ran into a similar issue (exporting local path to TEXINPUTS and accidentally deleting the system path) so I leave this here for posterity: Editing environment variables in the console only affects that console. The easiest way to refresh is to log out and log back in again. (I had fixed the environment variable in a separate console and I was puzzled why latex still did not find the right path.)
    – Joao
    Commented Nov 13, 2021 at 10:58
  • 1
    @user202729 Yes, any empty part after a colon means “the default”.
    – egreg
    Commented May 28, 2023 at 21:21
2

The question asks for a definition of the environmental variable TEXINPUTS: it controls where LaTeX searches for input files, the default is:

  1. First your current directory.
  2. Second the local ifp styles held in /ifp/latex/ and its subdirectories.
  3. Third the standard system LaTeX directories, where are held in /usr/share/texmf/tex/latex/ and its subdirectories.

TEXINPUTS can contain a list of paths. I am using "xelatex" on windows, and in that environment you must separate the separate path entries by semicolon. Colon will not work. If you want LaTeX to find files in the current folder be sure to include a "." in as one of the entries. Some sources sensibly recommend adding your personal path into the existing setting without looking the rest of the path by using a construct like this:

TEXINPUTS=.;/Home/loginname/mystyles/;$TEXINPUTS

The other answer seems to be on the subject of how to use it (and there are plenty of comments saying simply don't use it.) However, in my case, I have a collection of content stored in a source management system organized according to the team that maintains the content, but we need to compose a book out of various selections of the content pieces. Putting that content into a particular folder on the current machine is out of the question. We have to have a way for each book specify where to find all the content. We have not found any other way to specify in the build script where LaTeX is supposed to find all the pieces of the book.

2
  • That is so strange! Why did the xelatex developers use non-standard semicolons instead of colons?
    – vy32
    Commented Oct 7, 2018 at 17:12
  • 1
    @vy32 the semicolons are there for all Windows environments not just XeLaTeX on unix or mac they are colons its a Windows thing just for this windows specific alternative answer
    – user170109
    Commented Apr 1, 2019 at 23:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .