I am trying to count words in a document that contains various C types such as \texttt{uintptr\_t}
, \texttt{size\_t}
, etc. However, when I use texcount it breaks at the underscore and these as two words.
Is there a way to tell texcount to treat words with underscores as being only one word?
If I run texcount on this file it reports 5 words:
\documentclass{article}
\begin{document}
Word with underscore: \texttt{uintptr\_t}.
\end{document}
How can I work around this and count uintptr\_t
as one word?
edit: I've tried the following which mostly works:
\documentclass{article}
%TC:newcounter icode Number of words in code
%TC:newcounter icodeuses Number of code uses
%TC:macrocount \code [icodeuses]
%TC:macro \code [icode]
\newcommand*{\code}[1]{\texttt{#1}}
\begin{document}
Word with underscore: \code{uintptr\_t}.
\end{document}
This now reports the following for texcount -sum
:
Sum count: 6
Words in text: 3
Words in headers: 0
Words outside text (captions, etc.): 0
Number of headers: 0
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 0
Number of words in code: 2
Number of code uses: 1
Can I exclude certain counters from the total sum?
texcount
but you could modify the script itself to do this.-template=
flag and bash:echo "Total words: $(($(texcount '-template={w} + {icodeuses}' foo.tex)))"
printsTotal words: 4
\_
from your file withsed
and then count:sed "s/\\\_//g" yourfile.tex|texcount -
.