Use \numexpr
and other commands to calculate the multiplication.
However, just inputing count.txt
does not make the number available for computation. I stored the number to a counter instead.
The command \totalwordcount
computes the number of words from the \wordcount
command and adds the table/figure word amount then, finally the counter value is printed. Afterwards the command is redefined to provide only the counter value, no computations are done in the end.
\documentclass{article}
\newread\somefile
\usepackage{xparse}
\newcounter{totalwordcounter}
\newcounter{wordcounter}
\makeatletter
\NewDocumentCommand{\wordcount}{s}{%
\immediate\write18{texcount -sum -1 \jobname.tex > count.txt}%
\immediate\openin\somefile=count.txt%
\read\somefile to \@@localdummy%
\immediate\closein\somefile%
\setcounter{wordcounter}{\@@localdummy}%
\IfBooleanF{#1}{%
\@@localdummy% print only if not starred version
}%
}
\makeatother
\usepackage{totcount}
\regtotcounter{table} %count tables
\regtotcounter{figure} %count figures
\newcommand{\numberofwordsthejournalthinksforafigure}{250}
\newcommand{\numberofwordsthejournalthinksforatable}{250}
\newcommand{\totalwordcount}{%
\wordcount*% Just get the number, don't print it
\setcounter{totalwordcounter}{\value{wordcounter}}%
\addtocounter{totalwordcounter}{\numexpr\numberofwordsthejournalthinksforafigure*\totvalue{figure}}%
\addtocounter{totalwordcounter}{\numexpr\numberofwordsthejournalthinksforatable*\totvalue{table}} %
\number\value{totalwordcounter}% Output the number: Do not use \thetotalwordcounter here!
\renewcommand{\totalwordcount}{\number\value{totalwordcounter}}% Prevent the call again, otherwise the figure/table counter would be added again.
}
\setcounter{figure}{100}
\setcounter{table}{10}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem % 12 words
Word Count: \wordcount words + \total{figure} figure(s) + \total{table} table(s) = \totalwordcount~words
\end{document}
