Correct word-count of a LaTeX document

前端 未结 9 1187
野的像风
野的像风 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:54

    For a very basic article class document I just look at the number of matches for a regex to find words. I use Sublime Text, so this method may not work for you in a different editor, but I just hit Ctrl+F (Command+F on Mac) and then, with regex enabled, search for

    (^|\s+|"|((h|f|te){)|\()\w+
    

    which should ignore text declaring a floating environment or captions on figures as well as most kinds of basic equations and \usepackage declarations, while including quotations and parentheticals. It also counts footnotes and \emphasized text and will count \hyperref links as one word. It's not perfect, but it's typically accurate to within a few dozen words or so. You could refine it to work for you, but a script is probably a better solution, since LaTeX source code isn't a regular language. Just thought I'd throw this up here.

提交回复
热议问题