How many LaTeX classes and packages are there (say, on CTAN)?

TeX Live

TeX Live 2012 (2012-09-19)

$ egrep -c '\.sty$' ls-R
3381
$ egrep -c '\.cls$' ls-R
448
$ egrep -c '\.(sty|cls)$' texmf-dist/ls-R
3829

Windows has findstr, but it has some limitations. For example, it cannot detect Unix line ends or the end of the last line, if the file does not end with a end-of-line marker.

The equivalent for wc -l is find /c /v "", see What is the Windows equivalent of “wc -l”?.

> findstr /c:.sty ls-R | find /c /v ""
> findstr /c:.cls ls-R | find /c /v ""
> findstr /c:.sty /c:.cls ls-R | find /c /v ""

Different method:

$ find texmf-dist/tex/latex \( -name \*.sty -or -name \*.cls \) | wc -l
3148
$ find texmf-dist/tex/generic \( -name \*.sty -or -name \*.cls \) | wc -l
191
$ find texmf-dist/tex \( -name \*.sty -or -name \*.cls \) | wc -l
3500

Windows:

> (cd texmf-dist\tex\latex && dir /s /b *.sty *.cls | find /c /v "")
> (cd texmf-dist\tex\generic && dir /s /b *.sty *.cls | find /c /v "")
> (cd texmf-dist\tex\tex && dir /s /b *.sty *.cls | find /c /v "")

But:

  • False positives: .sty/.cls files that are not LaTeX packages or classes.
  • There are packages that divide their work on smaller units (modules in tikz, …) that are formally LaTeX packages.
  • TeX Live only contains a subset of free packages and classes.

TeX Catalogue

2012-09-19

$ find catalogue/entries/ -exec grep -l '/macros/latex' {} \; | wc -l
2154

Windows:

> dir /s /b catalogue\entries | findstr /m /f:/ /c:/macros/latex | find /c /v ""

But:

  • Not all package in CTAN are in the Catalogue.
  • There are packages outside CTAN:macros/latex/ (e.g. pgf) or packages that can be used in different formats.
  • One Catalogue entry might contain several packages and classes.
  • False positives: Driver files and other stuff (e.g. pdftex-def).

On a full MiKTeX installation:

$ find . | grep '\.sty' | wc -l
3498
$ find . | grep '\.cls' | wc -l
349

So about 3500 style files and about 350 class files.


At least the MiKTeX Package Manager has 2371 packages at the moment.