Counting words in TeX/LaTeX

I was trying to find an easy way to count the words in LaTeX documents. I guess there must be clients that do this for you, but I don’t use such a client and many times I’m using vi to edit LaTeX documents.

An way to go with it is to use a filter to strip as much as possible the TeX/LaTeX commands from the .tex file. This can be easily done with the detex command and the wc command:

detex report.tex | wc -w

Another way to filter the .tex document is to use untex in the same way as detex. This link describes lists also an alternative way of counting the words by converting the .dvi file to a plain text file:

dvips -o - report.dvi | ps2ascii | wc -w

However, this way doesn’t seem to filter the .dvi file that good so you may count more commands as words.

Basic and generic LaTeX notes

Some basic stuff I came across while writing on LaTeX:

  • Subscript, Greek letters, special character in mathematical form
\( H_{0} \): ${\mu}$\( _0 \) = ${\mu}$\( _1 \)
\( H_{1} \): ${\mu}$\( _1 \) ${\neq}$ ${\mu}$\( _1 \)
  • Chapters definitions etc
  • Two graphics side by side
\includegraphics[scale=0.3] {graphics/figure1}
\caption{{\bf label}}
\hspace{0.5cm} % Space between the figures
\includegraphics[scale=0.3] {graphics/figure2}
\caption{{\bf label2}}
  • Single image
\includegraphics[scale=0.5] {graphics/figure3}
\caption{{\bf label3}}
  • Bulletpoint list
item 3
item 4
  • Text formation: italics


  • Special characters (such as % and & for instance)

\% \&

  • Plain text format