On 2018-01-16 09:26, Dr. Thomas Möbius wrote:
\definestartstop
[abstract]
[style=bold,
after={\blank[big]}]
\starttext
\title{My title: example of a word and character count}
{\strut\tfx Formal guidelines: word count of abstract: $x$, character
count of main text: $x$, character count of figure captions: $x$.}
\blank
\startabstract
This is the abstract. Read this and that.
\stopabstract
% start of the main text
Some random text with formulas
\startformula
y = α + βx + ε, \quad ε \sim N(0,σ^2)
\stopformula
And there are also figures with captions.
\startplacefigure[
location=bottom,
title={Residual plot with time $t$ on the x-axis and
residuals $e_{jt}$ on the y-axis},
reference={fig:subject-residual}]
\externalfigure[residuals][height=.242\textheight]
\stopplacefigure
And some more text with $x$ and $y$ and $z$, and \placeformula
\startformula \startalign
\NC a =\NC b \NR
\NC c =\NC d \NR
\stopalign \stopformula
And stop.
\stoptext
Try something based on this:
\startluacode
userdata = userdata or { }
function userdata.wordcount(listname)
filename = file.addsuffix(tex.jobname,"words")
if lfs.isfile(filename) then
local w = dofile(filename)
if w then
if type(w.categories[listname]) == "table" then
context(w.categories[listname].total)
else
context(w.total)
end
context.par()
end
end
end
\stopluacode
\def\wordcount{%
\dosingleempty\dowordcount}
\def\dowordcount[#1]{%
\ctxlua{userdata.wordcount("#1")}}
\setupspellchecking[state=start,method=2]
\ctxlua{languages.words.threshold=1}
\definestartstop
[abstract]
[style=bold,
after={\blank[big]}]
\starttext
\setupspellchecking[list=abstract]
\startabstract
This is the abstract. Read this and that.
\stopabstract
\setupspellchecking[list=main]
Some random text with formulas
\startformula
y = α + βx + ε, \quad ε \sim N(0,σ^2)
\stopformula
And there are also figures with captions.
\setupspellchecking[list=figures]
\startplacefigure[
location=bottom,
title={Residual plot with time $t$ on the x-axis and
residuals $e_{jt}$ on the y-axis},
reference={fig:subject-residual}]
\externalfigure[residuals][height=.242\textheight]
\stopplacefigure
\setupspellchecking[list=main]
And some more text with $x$ and $y$ and $z$, and \placeformula
\startformula \startalign
\NC a =\NC b \NR
\NC c =\NC d \NR
\stopalign \stopformula
And stop.
\setupspellchecking[state=stop]
\title{My title: example of a word and character count}
Abstract: \wordcount[abstract]
Main: \wordcount[main]
Figures: \wordcount[figures]
Wordcount: \wordcount
\stoptext
--
Rik
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________