3

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.

1 Answer 1

3

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
68522
3
  • 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, 2013 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, 2013 at 9:34
  • 2
    @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, 2013 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .