I'm writing an article for the American Geophysical Union, and they have an absurd method of quantifying length:
For most journals, Research Articles are allowed to be up to 25 publication units (PU), where 1 PU is 500 words or 1 display element (figure or table). The title, authors, affiliations, key points, keywords, text in tables (but not captions) and references are excluded from word counts. Longer papers are assessed an excess length fee. Research Letters for Geophysical Research Letters have a maximum length of 12 publication units. Longer papers are not considered in GRL and will be returned for shortening. For most journals, Commentaries are limited to 6 publication units (recommended length is about 2000 words and 1-2 figures).
I'm working on writing a few lines of LaTeX that will keep track of this for me, but struggling a bit to get the wordcount incorporated as a variable to a math equation. Here's what I've got so far:
\documentclass{article}
\usepackage[utf8]{inputenc}
% Figuring out AGU's absurd "Publication Unit" scheme:
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -1 -sum -merge #1.tex> #1-words}%
\input{#1-words}
}
\newcommand{\MyWordcount}{\quickwordcount{agujournaltemplate}}
\newcommand{\MyTestVar}{37} %for testing purposes
\usepackage{siunitx,xfp}
\usepackage{xassoccnt}
\NewTotalDocumentCounter{totalfigures}
\NewTotalDocumentCounter{totaltables}
% \NewTotalDocumentCounter{appendixchapters}
\DeclareAssociatedCounters{figure}{totalfigures}
\DeclareAssociatedCounters{table}{totaltables}
\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp
\title{AGU Wordcount Test}
\begin{document}
% \maketitle
There are approximately \MyWordcount words in this article. There are \TotalValue{totalfigures} figures, and \TotalValue{totaltables} tables. That means we have a total of \num[scientific-notation=false]{\fpeval{(1/500)*\MyWordcount+ \TotalValue{totalfigures} + \TotalValue{totaltables}}} publication units, out of a maximum of 25.
\end{document}
This does not compile. If I replace \MyWordcount with \MyTestVar in the equation, it does fine. Any tips for making the wordcount into a variable for this purpose?