0

I'm wondering if it is possible to exclude ExPex code from being counted by texcount? At the moment I'm writing a thesis with lots of linguistic examples, but I need to exclude these from the total word count. So far I've been surrounding each example with %TC:ignore...%TC:endignore. For instance (MWE):

\documentclass{article}
\usepackage{expex}

\begin{document}

TexCount correctly counts five words.

%TC:ignore
\ex
  \begingl
    \gla foo bar//
    \glb gloss1 gloss2//
    \glft `Translation of the sentence.'//
  \endgl
\xe
%TC:endignore

\end{document}

I've tried using %TC:envir ex [] text and other variations (including %TC:group), but they do not work (for me). I would be grateful if anyone could tell me how to get this working. It's not totally essential, as the manual method works fine (I've got a snippet set up that generates an expex template surrounded by %TC:ignore...%TC:endignore), but my files would be a little cleaner if I didn't have to have these at every example (of which there are lots).

From my understanding, ExPex begins a group with \ex or \pex. However, I just can't get texcount to recognise this group. Any help would be greatly appreciated!

1 Answer 1

1

The %TC:envir rules would only apply to \begin...\end groups, not to macro pairs \ex...\xe.

However, there is a trick that can be used: to substitute \ex and \xe with \begin{ex}...\end{ex} and then apply the environment rule. Fortunately, TeXcount has a substitute operation that simply replaces a macro with some other text. Just add the following:

%TC:subst \ex \begin{ex}
%TC:subst \xe \end{ex}
%TC:envir ex [] xx

The xx rule is a strong exclude rule. Not sure if the best option is ignore, xx (strong exclude), xxx (stronger exclude), or xall (ignore all). The difference is to what extent the contents is processed, eg with respect to balancing \begin...\end, processing macro parameters, and balancing {...}, so it depends on the \ex...\xe contents.

While TeXcount does process some special macros like \verb+...+, these tend to be hard-coded and not easily exteded without modifying the TeXcount code (which is in Perl). The rules that can be extended, eg using %TC commands, are those that follow general patterns: ie macro with parameters, or \begin...\end environments.

1
  • That works perfectly, thank you! I had no idea about %TC:subst Commented May 31 at 5:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .