Site Tools


kpsewhich

**This is an old revision of the document!**

Table of Contents

kpsewhich

kpsewhich is a LaTeX-related command. It's a diagnostic command that's used to look up the full path of a file you know the LaTeX compiler would use implicitly. In some way, it is similar to the which command, which shows the full path of a command if you would run it in the shell (e.g. which ls shows /usr/bin/ls).

For example, when you use \documentclass{article} in a TeX document, and you compile the document with pdflatex, the compiler is going to load the “document class: article” from article.cls file (Note: the .cls extension stands for “class”)

% Compile: pdflatex main.tex
% Result:  main.pdf 
\documentclass{article}
\begin{document}
...
\end{document}

Where article.cls located? You can find out with kpsewhich command.

 $ kpsewhich article.cls
/usr/share/texmf-dist/tex/latex/base/article.cls

Run

No arguments

You can't run it without arguments.

 $ kpsewhich
Missing argument. Try `kpsewhich --help' for more information.

Help

 $ kpsewhich --help
Usage: kpsewhich [OPTION]... [FILENAME]...

Standalone path lookup and expansion for the Kpathsea library.
The default is to look up each FILENAME in turn and report its
first match (if any) to standard output.

If multiple FILENAMEs are given and a given file is not found, a blank
line is written to standard output.

When looking up format (.fmt/.base/.mem) files, it is usually necessary
to also use -engine, or nothing will be returned; in particular,
-engine=/ will return matching format files for any engine.

The exit status is 0 if all files are found, nonzero otherwise.

-all                   output all matches, one per line (no effect with pk/gf).
[-no]-casefold-search  fall back to case-insensitive search if no exact match.
-cnf-line=STRING       handle STRING as a configuration file line.
-debug=NUM             set debugging flags.
-D, -dpi=NUM           use a base resolution of NUM; default 600.
-engine=STRING         set engine name to STRING.
-expand-braces=STRING  output variable and brace expansion of STRING.
-expand-path=STRING    output complete path expansion of STRING.
-expand-var=STRING     output variable expansion of STRING.
-format=NAME           use file type NAME (list shown by -help-formats).
-help                  display this message and exit.
-help-formats          display information about all supported file formats.
-interactive           ask for additional filenames to look up.
[-no]-mktex=FMT        disable/enable mktexFMT generation (FMT=pk/mf/tex/tfm).
-mode=STRING           set device name for $MAKETEX_MODE to STRING; no default.
-must-exist            search the disk as well as ls-R if necessary.
-path=STRING           search in the path STRING.
-progname=STRING       set program name to STRING.
-safe-in-name=STRING   check if STRING is ok to open for input.
-safe-out-name=STRING  check if STRING is ok to open for output.
-safe-extended-in-name=STRING   also check TEXMF[SYS]VAR.
-safe-extended-out-name=STRING  also check TEXMF[SYS]VAR.
-show-path=TYPE        output search path for file type TYPE
                         (list shown by -help-formats).
-subdir=STRING         only output matches whose directory ends with STRING.
-var-brace-value=STRING output brace-expanded value of variable STRING.
-var-value=STRING       output variable-expanded value of variable STRING.
-version               display version information number and exit.

Email bug reports to [email protected].
Kpathsea home page: https://tug.org/kpathsea/
kpsewhich.1779031930.txt.gz · Last modified: by Ivan Janevski