TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am using TexShop and was wondering if there is an easy way to find the wordcount in a document ?
The way I do it now is copy and paste the PDF document into Word to calculate the word count. Is there a way I can do this directly from the PDF file in MACOS's Preview ? Or through LaTeX directly ?

share|improve this question

marked as duplicate by doncherry, Werner, Kurt, mafp, Herbert Apr 12 '13 at 21:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 7 down vote accepted

You could try detex document.tex | wc -w

(detex does a decent, but not perfect, job at eliminating LaTeX commands, if you use such to write part of the text, the count will be off. And I don't remember offhand how it handles accents, i.e. l'H\^opital might give too many words).

share|improve this answer
Where do I place this command ? – Razor Apr 12 '13 at 17:46
Run it from the command line. detex is part of TeXlive, at least. – vonbrand Apr 12 '13 at 17:51
I don't mean to be bothersome, but can you please provide more info ? Where is the command line ? How do I run it ? – Razor Apr 12 '13 at 18:22
I don't know Mac that well, but it is a Unixy system. There should be some way to get a terminal where you can enter commands, in that you can cd to where your document lives. Sorry I can't help more. – vonbrand Apr 12 '13 at 18:29
Thanks it works perfectly :) – Razor Apr 12 '13 at 18:31

TexCount will do a word count for you and also break it down per section etc.
Available both as a web-app as well as a download, and comes packaged with TeX Live. Can be invoked in the command line with texcount mytexfile.tex.

share|improve this answer
I've seen that thank you, but I was afraid my code will be stored somewhere and might be marked as plagiarism when I submit my report. – Razor Apr 12 '13 at 18:47
@NLed -- texcount comes with TeX Live, and can be invoked from the commandline (assuming Bash, or equivalent) as follows: texcount mytexfile.tex. It is much better than detex + wc. – jon Apr 12 '13 at 19:22
Yes, should have mentioned that there is also a downloadable version. – Ubiquitous Apr 13 '13 at 12:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.