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

I want to perform a word count on my LyX document. The problem is that I include several files within my main document

  • main.lyx
    • include file1.lyx
    • include file2.lyx
      • include file21.lyx
    • include file3.lyx

I have not figured out how to do a proper PDF wordcount, since the results vary depending on how I export the PDF, but I know I could do a Tools -> Statistics... -> count words and add them up for each file, but I have something like 20 documents, hence this will be unnecessary time consuming work.

share|improve this question
up vote 3 down vote accepted

Export to text and use wc.

For example, if you are in the Italian manuals directory, you get the following output:

$ lyx -e text *.lyx && wc -w *.txt
starting local cmake binary
 18958 Customization.txt
  4115 Intro.txt
 11047 Tutorial.txt
 34402 UserGuide.txt
 68522 total

If you want just the total:

$ lyx -e text *.lyx && wc -w *.txt | awk '{ print $1 }' | tail -n 1
share|improve this answer
Thank you. Would you also know how to do this in Windows? I forgot to mention that is the OS I am working in. – chwi May 29 '13 at 9:22
Cygwin or Python should work. The same idea holds. Export to text and use any kind of word count program. – scottkosty May 29 '13 at 9:34
@Wilhelmsen Note that in general it is difficult to get an accurate word count. Using this method, a empty 5x5 table where all line are drawn will be count as 37 words!! More ideas on how to count (after exporting .lyx to .tex) can be found here. – e-birk May 30 '13 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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