I am trying to make an automatic char count with spaces on my report, so that i get a char count on my main mainmatter displayed and one on my appendix. I have looked at Paul Gessler answer (Command for character count including spaces (in overleaf)) but i can't get it to work if i have more files then the main.tex.
So far i have tried just to count the main.tex file but it comes up with an error "Missing number, treated as zero."
% ~~~~~~~~~~~
% Mainmatter - Chapters
% ~~~~~~~~~~~
\mainmatter
\quickwordcount{main}
\quickcharcount{main}
There are \thechar characters and approximately \theword spaces.
That makes approximately \the\numexpr\theword+\thechar\relax\ characters total.
\include{Chapters/1. INDLEDNING}
\include{Chapters/2. PROBLEMFORMULERING}
\include{Chapters/3. TEORI OG METODE}
\include{Chapters/4. PROJEKTRESULTATER}
\include{Chapters/5. DISKUSSION}
\include{Chapters/6. KONKLUSION}
% ~~~~~~~~~~~
% appendix, billag og referancer
% ~~~~~~~~~~~
\pagestyle{empty}
\appendix
\include{App, Bil, Bib/appendix} % Appendix A
In my preamble which is put in with \input{preamble} in the beginning i have
\newread\tmp
\newcommand{\quickcharcount}[1]{%
\immediate\write18{texcount -1 -sum -merge -char #1.tex > #1-chars.sum}%
\openin\tmp=#1-chars.sum%
\read\tmp to \thechar%
\closein\tmp%
}
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -1 -sum -merge #1.tex > #1-words.sum}%
\openin\tmp=#1-words.sum%
\read\tmp to \theword%
\closein\tmp%
}
any suggestions?
.sumfiles to see what they contain: each should contain just a single number. However, iftexcountproduced an error message, the values returned would not be a number which could explain the error message. – Einar Rødland Mar 06 '22 at 15:54But it seems like it wont treat
– Mathias Houmøller Mar 07 '22 at 22:27\charcountand\wordcountlike a number that i can add togeather even through they show as numbers above..sumfiles. – Mathias Houmøller Mar 07 '22 at 22:37