0

I want to add character count including spaces in my report. So far I've found a command, which provides me this:

\documentclass{report}
\begin{document}

}{%
\newcommand{\charactercount}[1]{
\immediate\write18{
    expr `texcount -1 -sum -merge #1.tex` + `texcount -1 -sum -merge -char #1.tex` - 1 
    > chars.txt
}\input{chars.txt}}

Denne rapport indeholder \charactercount{main} anslag.
  
}%

\end{document}

enter image description here

Can anyone tell me exactly what is included in the character count when using this command? I suspect it shows a wrong number not true to the real character count in the report.

I want the character count with spaces to include everything from "initierende problem" to "Konklusion".

enter image description here

So appendix, front page, table of contents, references and abstract should not be included. How do I specify this in this command? Or should I use a completely different command?

I have no idea if this example is reproducible since I'm still not sure what to include for this, but let me know, if I missed something to clarify my question. If any help this link provide access to a complete example of the template and coding I'm using.

https://www.overleaf.com/7382543212gnzsfkpbdnrd

Thanks!

1 Answer 1

1

TeXcount can run in two modes: the default which will count words, and the character mode specified by -char which will count characters not including spaces and punctuation. The reason spaces are not included in the character mode is in part related to how TeXcount was originally implemented, but also difficult since spaces in the typeset document need not correspond well to spaces in the source file.

The solution for counting characters including spaces is the estimate the number of spaces from the number of words, which is not entirely accurate. However, it should normally be an ok estimate. It may be improved by including punctuation in the character count by using -all-nonspace-char instead of -char.

As I recall, the references should be default not be included in the count, although that may depend on how they are included in the document. However, if there are other segments of the document you do not wish included, you can do so by placing TeX comments in the document that TeXcount will interpret as instructions:

%TC:ignore

TeX code which you wish TeXcount to ignore

%TC:endignore

If you wish to check how TeXcount does the counting, you need to review more verbose TeXcount output: the options -1 -sum indicates that it should sum up the different counts (text, headers, captions) and output the sum as a single number. TeXcount can produce output per file, chapter, section, etc, and in verbose mode can also show a colour coded version of the source file which illustrates how each element has been counted. This might not be very compatible with Overleaf, however, although it might be useful for identifying problems.

You can check these features out on the TeXcount web service, which can also be a useful place to check out how TeXcount interprets specific elements.

You must log in to answer this question.

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