# Using Texcount but how do I ignore macro contents?

I am using TexCount to do word counts on my document. I am using a \cmt command to write inline comments so anything in \cmt{} does not get printed.

I am using the texcount command %TC: macro \cmd [1] to try and ignore these comments

%TC: macro \cmd [1]

\documentclass[]{article}
\immediate\write18{texcount.pl -total \jobname.tex -out=\jobname.sum}

\newcommand{\cmt}[1]{}

\usepackage{verbatim}
\newcommand\wordcount{\verbatiminput{\jobname.sum}}

\begin{document}

One
\wordcount
\cmt{Two Three Four Five}

\end{document}


I should be getting Words in Text: 1 but it's coming out as 5.

The syntax is %TC:macro \cmt [state1] if there is only one argument.

The state1 can have a specific value, if the argument should be ignored, use %TC:macro \cmt [ignore]

\documentclass[]{article}

%TC:macro \cmt [ignore]

\immediate\write18{texcount -total \jobname.tex -out=\jobname.sum}

\usepackage{verbatim}
\newcommand\wordcount{\verbatiminput{\jobname.sum}}

\newcommand{\cmt}[1]{}

\begin{document}

One
\wordcount
\cmt{Two Three Four Five}

\end{document}


• Perfect. That's solved it. Tnks Nov 4, 2015 at 17:36