Skip navigation.

Counting the Words in a LaTeX Document

 

The standard command wc counts the letters, words and lines in a file. However this will give a gross over estimate on many latex documents due to the large number of words which are actually latex commands and maths. To get a more accurate estimate use untex first to remove the tex codes and then count the words, e.g.

untex file.tex > output_filename

where the output_filename is the name of the file you want it to produce without any tex commmands. You can then use

wc -w output_filename

to count the words in the resulting file.

The accuracy of the estimate will depend to a degree on how many latex macros of your own you have which it fails to handle well.

An alternative approach is to try to count the words in the dvi file by converting it to plain text first, e.g.

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