This question is an extension of my previous question, although the answer to that question worked well in TeX-Studio, it does not work in Overleaf v2, which was primarily the Shareletax interface). It seems that \wordcount
failed to return a number.
My first question is: why the original answer does not work in Overleaf?
On the other hand, I tried the minimum example below and it was able to return the correct word count in Overleaf v2. My second question is, can I somehow combine these 2 sets of codes and successfully automate total word count in Overleaf v2?
\documentclass{article}
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -1 -sum -merge #1.tex > #1-words}%
\input{#1-words}words%
}
\begin{document}
There are \quickwordcount{main} in this article.
\end{document}
\quickwordcount
to set some texcount parameters: the previous solution with\jobname
no longer works well, because ShareLaTeX/Overleaf v2 sets the\jobname
tooutput
.\input{#1-words}
as a variable in LaTeX and use it to calculate the final word count?