Is there a way to count characters in a document portion? I need to write a summary that is 3000 characters long at most, and every time I compile the document I copy/paste the resulting text to Word to do the count.
I found this post but it seems that solution doesn't work. What I would like to have is something like:
\begin{characterCount}
% write here all the text
\end{characterCount}
if characterCounter > threshold:
{\color{red} Character count exceeded! }
Best Answer
TeXcount is your friend. It is a perl script for counting words in LaTeX documents. Although the ouput is a separate plain text file, you can include easily verbatim in the own LaTeX document without modify the result, because you can count any arbitrary chunks of text and avoid some parts using the pseudoenvironment comments
%TC:ignore ... %TC:endignore
. Moreover, you can obtain subcounts at some section levels and separate counts of words for main text, headers, captions, inlined math and displayed math (and more, although this is out of the question. Runtexdoc texcount
for more information).To count characters instead of words, add simply the
-char
option aftertexcount
: