I would like to include all macros (or \newcommand's) that start with \figure and count them as floats in texcount. For context, have a look in here.
It works if I tell texcount to increment the float counter individually for each \newcommand:
%TC:macroword \figureMyNthPicture [float]
It would be convenient that each newcommand that would start with a string, like \figure, would be counted and the macrocount/macroword would only need to be defined once.
I have tried the following regex without success:
%TC:macroword ^\\figure [float]
Below is a MWE that works, but the macrocount/macroword is currently defined individually for every macro, which is undesired.
\documentclass[a4paper,12pt]{scrartcl}
\usepackage{graphicx}
%---------------------------------------
\begin{document}
% define figureA
\newcommand{\figureA}{
\begin{figure}
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
}
%Count figure A in texcount
%TC:macroword \figureA [float]
%place figureA
\figureA
%define figureB
\newcommand{\figureB}{
\begin{figure}[!htb]
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{example-image-B}
\end{figure}
}
%Count figure B in texcount
%TC:macroword \figureB [float]
%place figure B
\figureB
\end{document}
texcountcannot easily be tweaked to work with it. To select the rule to apply, the internal data structures use the macro name as a key to a lookup table. One would have to rewrite considerable parts oftexcountto allow for the processing of regexps. – gernot Sep 30 '21 at 07:45