I often have trouble remembering the name of the kpsewhich command. Maybe it would be easier for me to remember it, if I understand where the name come from, so the question is:

What does the kpse stand for?

2 Answers 2


Karl's Path SEarch Library WHICH

  • 1
    Thank you! This will make it much easier to remember!
    – muxoveji
    Commented May 22, 2019 at 12:29
  • 1
    @david-carlisle what a bold answer ;-)
    – topskip
    Commented May 23, 2019 at 13:28
  • 2
    @muxoveji honestly, it doesn't help me to remember it any better! Why not a simpler name? Who is Karl by the way? Commented Dec 30, 2019 at 11:16
  • 3
    @SaeedAhadian Karl Berry who wrote the code and who has maintained texlive for the last few decades. Commented Dec 30, 2019 at 11:33

As info kpathsea says (online manual here), Kpathsea is a library for path searching (e.g., for very quickly locating a given .sty file in a set of potentially large TEXMF trees, without doing a recursive directory tree traversal every time a given file is needed; this is important when compiling LaTeX documents using several packages, themselves requiring other packages, possibly various font files, etc.).

This path search gives the pathse part, abbreviated as pse. The “which“ reminds of the Unix which utility, which tells you the path of the executable run for a given command, according to your PATH environment variable. For instance:

$ which find

I believe the “k” stands for “Karl Berry”. :-)


The comparison between which and kpsewhich goes further than that. As Unix shells often maintain a cache of executables present in directories of the PATH in order to offer efficient lookup for command completion, the Kpathsea library maintains a filename database (comprised of the ls-R files in each TEXMF tree) in order to offer similar fast lookup to TeX-related programs.

In Unix shells, the cache can often be updated with a hash command (hash -r in Bash, rehash in Zsh) when you've added or removed executables from your PATH and wish to refresh the cache without restarting your shell; for the Kpathsea library, the corresponding operation is done with mktexlsr, also known as texhash.

Finally, which looks up a given executable in the directories listed in PATH1, in some way similarly as kpsewhich for finding a TeX-related file using either on-disk lookup or only the filename database (it depends on whether the TEXMF tree is preceded with !! where it is used in texmf.cnf2). kpsewhich is more sophisticated than a typical which builtin, though, as it can return different results depending on what was given as -progname, has a notion of variables that can be set in texmf.cnf, can look up in-cache-only or on-disk depending on the per-directory-settings in texmf.cnf, etc.


  1. In Bash and Zsh at least, it seems to really search the PATH: if you add a new executable to a directory of your PATH, the which builtin of these shells finds it right away without any need to run hash -r or rehash (this may not be the case for command completion).

  2. See for instance /usr/share/texlive/texmf-dist/web2c/texmf.cnf on Debian.

You must log in to answer this question.

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