texWordCount: word counting in LaTeX documents

[ Back to the WING home page ]

This page is the home page for my texWordCount perl script, a script used to count words in LaTeX documents. It is open source code which you are free to use or redistribute in any manner.

Download

The below links may show up in your browser as plain text. If so, just save the resulting page in a suitable plain text file, such as texWordCount.pl.

Previous versions are incorporated into the 090326 but not explicitly available from version control (I was -- and still am -- lazy).

Web form-based demonstration

Try out the demo to see whether it fits your needs.

Cut and paste your LaTeX document. This demo only works for single .tex files. The script also works to process multiple files as per the \include{filename} LaTeX directive.

Check to count words in captions as well.

Or enter a LaTeX file to upload to get word count

Installation

The script is a simple perl script. You need to have perl installed on your computer. For most UNIX servers, Linux based computers and Macs running OSX or later, this should be trivial, since perl comes installed with most modern operating systems.

For Windows XP/Vista, you need to install perl yourself. A perl version for windows that is free is ActiveState's ActivePerl.

Usage

usage: texWordCount.pl -h                               [invokes help]
       texWordCount.pl -v                               [invokes version]
       texWordCount.pl [-cduiq] filename(s)...
Options:
        -c      Count words in captions
        -d      Debug Mode
        -i      Inclusive.  Don't search for {document} tags.  Good for \includes
        -q      Quiet Mode (don't echo license)
        -u      Update word counts in file

Will accept input on STDIN as a single file.

A thing that I originally liked to do is have the word count embedded within the LaTeX file itself. You can then have the script run during TeX compilation (e.g., ant or make). Do this by including:

% texWordCount - begin
% texWordCount - end

in your .tex file. The leading '%' makes it a TeX comment, invisible to LaTeX for all intents and purposes.

Acknowledgments

Links

TeXcount: Possibly a better LaTeX word counting script? From Norway. At least it seems to have frequent updates, unlike this one. :-P


Min-Yen Kan <kanmy@comp.nus.edu.sg>
Created on: Thu Mar 26 20:35:11 2009 | Version: 1.0 | Last modified: Thu Mar 26 21:42:03 2009