Correct word-count of a LaTeX document

前端 未结 9 1342
野的像风
野的像风 2021-01-30 01:37

I\'m currently searching for an application or a script that does a correct word count for a LaTeX document.

Up till now, I have only encountered script

9条回答
  •  抹茶落季
    2021-01-30 01:55

    I use the following VIM script:

    function! WC()
        let filename = expand("%")
        let cmd = "detex " . filename . " | wc -w | perl -pe 'chomp; s/ +//;'"
        let result = system(cmd)
        echo result . " words"
    endfunction
    

    … but it doesn’t follow links. This would basically entail parsing the TeX file to get all linked files, wouldn’t it?

    The advantage over the other answers is that it doesn’t have to produce an output file (PDF or PS) to compute the word count so it’s potentially (depending on usage) much more efficient.

    Although icio’s comment is theoretically correct, I found that the above method gives quite accurate estimates for the number of words. For most texts, it’s well within the 5% margin that is used in many assignments.

提交回复
热议问题