The journal I am submitting to requires a total word count on the title page. My question is more like an extension to Greg's previous question. The journal states that a table/figure is counted as 250 words, and the total word count -- which is essentially word count + figure count * 250 + table count * 250 -- cannot exceed a certain number.

From Greg's solution, I was able to print the three counts using texcount and totcount:

    \immediate\write18{texcount -sum -1 \jobname.tex > count.txt} \input{count.txt}}
    \regtotcounter{table}   %count tables
    \regtotcounter{figure}  %count figures

Word Count: \wordcount words + \total{figure} figure(s) + \total{table} table(s) = ?? words

My question is, in LaTeX, how do I calculate the total word count (??) using the three counts and print it on my title page?

PS. I am new to LaTeX (and TeX.SX) so any help is highly appreciated!

1 Answer 1


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.




  \immediate\write18{texcount -sum -1 \jobname.tex > count.txt}%
  \read\somefile to \@@localdummy%
  \@@localdummy%   print only if not starred version

\regtotcounter{table}   %count tables
\regtotcounter{figure}  %count figures


\wordcount*% Just get the number, don't print it
\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. 


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


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.