# Can I configure texcount to not ignore certain optional arguments?

Is it possible to configure texcount not to ignore text in optional arguments for certain macros?

Consider the following example:

\documentclass{article}
\begin{document}
\autocite[e.g.][4]{key-1,key-2}
\autocites[e.g.][5]{key-1,key-2}[and][89]{key-3}
\end{document}


This will not compile, of course, but it works as a minimal example for texcount which does not care whether it compiles or not.

My texcount.cfg includes the following rules:

%TC:macro \autocite [1]
%TC:macro \autocites [1,1]


Running the minimal document above through texcount yields output which includes the following:

\documentclass{article} [0]
\begin{document} [0]
\autocite[e.g.][4]{key-1,key-2} [2]
\autocites[e.g.][5]{key-1,key-2}[and][89]{key-3} [5]
\end{document} [5]

Total
Sum count: 5
Words in text: 5
Words outside text (captions, etc.): 0
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 0
Files: 2


For my purposes, this is a significant improvement over the default which would not count my citations at all. Nonetheless, it still underestimates the count. An accurate count would be (approximately) 16 words rather than 5, including 6 in pre- and post-notes:

• the optional arguments are produced as part of the citations and total 6 words

Can I tell texcount to count the words in the optional arguments?

Assuming you're running version 3 of TeXcount, you can specify parsing rules for optional arguments.

You can also use more intuitive names for the rules rather than the numerical codes.

In you case, you can use the following parsing rules:

%TC:macro \autocite [option:text,option:ignore,text]
%TC:macro \autocites [option:text,option:ignore,text,option:text,option:ignore,text]


The optional rules, specified on the format option:rule apply if an optional argument is provided to the macro, otherwise it is skipped.

The available parsing rules are (copied from section 5.1 of the documentation):

• Text: (key: text, word, wd, w formerly 1) Count as text (i.e. count words).
• Other text: (key: otherword, other, oword, owd, ow formerly 3) Count as float/caption text.
• Displaymath: (key: displaymath, dsmath, dmath, ds formerly 7) Count as displayed math formulae.
• Inline math: (key: inlinemath, inline, imath, eq formerly 6) Count as inlined math formulae.
• Thank you! May I suggest that you indicate in the output from texcount --help that documentation is available via texdoc? Because this is something I use at the command line rather than loading it as a package, I looked for a man page or info entry and it did not occur to me to try texdoc. Maybe this is just me being idiotic, but I would have been glad of a helpful hint for idiots! – cfr Jan 5 '16 at 22:13
• I'd still add texdoc. People aren't always connected, whereas they are likely to have access to the PDF as part of their TeX installations. The help does cite the web site. However, it doesn't say anything about documentation being there. – cfr Jan 5 '16 at 22:25
• @cfr: Will add reference to texdoc texcount as well. I was actually not aware of the texdoc command, but that's quite useful. – Einar Rødland Jan 5 '16 at 22:33