I'm becoming increasingly happy with overleaf, now prefering it to vscode or vim. A lot of the stuff I have to write for university needs a character count including spaces. Up until now I've been exporting as pdf and counting from there, but this process seems quite tedious. I recently found an overleaf example with character count as a command, but the problem is that this does not include spaces. The command is as follows:
\newcommand{\quickcharcount}[1]{%
\immediate\write18{texcount -1 -sum -merge -char #1.tex > #1-chars.sum }%
\input{#1-chars.sum}%
}
Additionally the include command for word count is:
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -1 -sum -merge #1.tex > #1-words.sum }%
\input{#1-words.sum}%
}
I therefore figured that the fastest way to get an (approximate) char count including count spaces is by adding the word count to the character count. I've been attempting to it has described here:
\numexpr \quickwordcount{main} + \quickcharcount{main}
But this just handles words and chars as strings and outputs the sum as so.
Sorry for the long confusing post, but here's the tl:dr: does anyone have an idea of have I can get the char count including as spaces in Overleaf?
Thanks
texcount
, of course, is that it is relatively robust - ignoring most things in the preamble and document code (versus document content). I can provide an answer (that works on Overleaf) with a Perl script that counts all characters, if you like. The caveat is that this counts all spaces, including those in the preamble, etc. that should (probably) not be included.texcount
is complicated enough that you would be better off contacting the developer to see about including this option.