Determine full list of installed LaTeX packages in Ubuntu

You can find all locations that TeX will search for files using

kpsepath tex

The format is a bit weird: items are separated by colons, directories that should be searched using a ls-R index file start with !!, directories to be searched recursively end with //. To clean it up, we can process the output a bit:

kpsepath tex | tr ':' '\n' | perl -ne 'm-^(!!)?(/.*?)(//)?$- && print "$2\n"'

For each of those paths, you can find out which installed packages have put files under those paths using dlocate:

dlocate --package-only /path

(if you don't have dlocate, install it and make sure to run sudo update-dlocatedb). Putting it all together and eliminating duplicate package names from the output:

kpsepath tex | tr ':' '\n' | perl -ne 'm-^(!!)?(/.*?)(//)?$- && print "$2\n"' | while read path; do dlocate --package-only $path ; done | sort -u

For example, on my system, that prints:

asymptote
cm-super-minimal
context
dblatex
feynmf
gnuplot-x11
latex-beamer
latex-cjk-common
latex-make
latex-xcolor
latex2html
lgrind
lilypond-data
lmodern
pgf
preview-latex-style
tex-common
tex-gyre
tex4ht-common
texinfo
texlive-base
texlive-bibtex-extra
texlive-extra-utils
texlive-font-utils
texlive-fonts-extra
texlive-fonts-recommended
texlive-generic-recommended
texlive-lang-other
texlive-latex-base
texlive-latex-extra
texlive-latex-recommended
texlive-luatex
texlive-math-extra
texlive-metapost
texlive-pictures
texlive-pstricks
texlive-science
texlive-xetex
texpower
tipa

There's some stuff there that I wouldn't have expected, like gnuplot-x11, but dpkg -L shows that it includes a gnuplot-lua-tikz.sty. Who knew?!


I am very reluctant to install anything that is not in official packages from a Linux distribution, but LaTeX and R are the exceptions that confirm my rule.

As Ubuntu packages for LaTeX could be outdated, the list of Ubuntu packages is not the list of LaTeX packages, and not all TeX Live stuff are available from .deb packages (notably tlmgr), I think that the best way to control what is already installed is:

  1. Uninstall all the .deb packages related with LaTeX.
  2. Install the recent TeX Live 2013 followings instructions from www.tug.org.
  3. Then, you can obtain easily the list with: tlmgr list | more and detailed information for specific packages (for example: tlmgr info xcolor)

I do not think that obtain that list justifies the download of some gigabytes and change the installation, but it is a good excuse to have tlmgr so you can update and install all the latest TeX Live packages that you will need.


Using unix tools:

To seach per user packages:

find ~ -name '*.sty' | grep -oE '/([^/]+)/[^/]+\.sty$' | cut -f2 -d'/' | sort | uniq

To search system-wide packages:

find /usr -name '*.sty' | grep -oE '/([^/]+)/[^/]+\.sty$' | cut -f2 -d'/' | sort | uniq

To search all file system:

sh -c "find / -name '*.sty' | grep -oE '/([^/]+)/[^/]+\.sty$' | cut -f2 -d'/' | sort | uniq" 2>/dev/null

2>/dev/null is to suppress "Permisson denied errors"