News for hackers. Stuff that matters.

Latex-wc: word count and word frequency for LaTeX projects

I was revising my proposal defense and kept feeling like I was repeating the same term. In a typical LaTeX project split across many .tex files, it’s awkward to get a quick, clean word-frequency view without gluing everything together or counting LaTeX commands/math as “words”.

So I built latex-wc, a small Python CLI that:

- extracts tokens from LaTeX while ignoring common LaTeX “noise” (commands, comments, math, refs/cites, etc.)

- can take a single .tex file or a directory and recursively scan all *.tex files

- prints a combined report once (total words, unique words, top-N frequencies)

Fastest way to try it is `uvx latex-wc [path]` (file or directory). Feedback welcome, especially on edge cases where you think the heuristic filters are too aggressive or not aggressive enough.

( 7 comments | on HN )
Re:Latex-wc: word count and word frequency for LaTeX projects by dang on Tuesday February 03, 2026 @12:31AM (#46866904)
We need a link!
Re:Latex-wc: word count and word frequency for LaTeX projects by jxmesth on Tuesday February 03, 2026 @02:02AM (#46867516)
Re:Latex-wc: word count and word frequency for LaTeX projects by dang on Tuesday February 03, 2026 @06:54PM (#46879229)
Added above. Thanks!
Re:Latex-wc: word count and word frequency for LaTeX projects by elashri on Wednesday February 04, 2026 @07:18AM (#46884953)
I think the link to source code repository would be better

https://github.com/sethbarrett50/LaTeX-wc

Re:Latex-wc: word count and word frequency for LaTeX projects by dang on Wednesday February 04, 2026 @12:53PM (#46889082)
Changed to that. Thanks!
Re:Latex-wc: word count and word frequency for LaTeX projects by mci on Wednesday February 04, 2026 @01:37PM (#46889753)

  detex "$@" | wc
  detex "$@" | tr -cs '[:alnum:]' '\n' | grep . | tr '[:upper:]' '[:lower:]' | sort | uniq -c | sort -rn
Re:Latex-wc: word count and word frequency for LaTeX projects by gucci-on-fleek on Wednesday February 04, 2026 @07:13PM (#46893849)
Are you aware of the "texcount" program [0] that's distributed with TeX Live by default?

[0]: https://ctan.org/pkg/texcount?lang=en