Latex wordcounting

I wanted a quick way to get the word count for my latex document – so I now have 2 lovely hacky scripts.
My latex file is called document.tex, so ‘document’ should be changed to the name of your file.

In your Latex file you need to include ‘\input{hack}’ at the top of your document and ‘\input{wordcount}’ wherever you want to include your wordcount.

The following script removes the bibliography and citations and then counts the words outputting to a file:
makeme:

echo > wordcount
echo "\renewcommand{\cite}[1] {}
\renewcommand{\maketitle}[1] {}
\renewcommand{\bibliography}[1] {}" > hack
pdflatex document
ps2ascii document.pdf | wc -w > wordcount

makemepropper:

echo > wordcount
./makeme
echo "" > hack
bibtex document
pdflatex document
bibtex document
pdflatex document
bibtex document
pdflatex document

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: