2

I'm writing up an academic document for which I have a max wordcount, using Overleaf's texcount with default settings to count words. By default this excludes equations (which is desirable) but this does not detect the IEEEeqnarray - is there a systematic way to exclude a type of environment from texcount?

I realise %TC:ignore with %TC:endignore allow me to exclude specific instances, but it is not feasible for me to go to every environment and add this - I would be willing to compromise on a way of creating a new custom environment such as

\newenvironment{EqnExcluded}{
%TC:ignore
    \begin{IEEEeqnarray*}
    }{%
    \end{IEEEeqnarray*}
%TC:endignore
}

but firstly I'm not sure how LaTeX newcommand would parse the commented text, but more importantly when I tried testing by putting this into my preamble then I get 0 words regardless of whether I actually use it in the document. The various MWEs with word counts are included below: the only thing that changes is the environment and whether the above code is included

IEEEeqnarray* write up giving 6 words:

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}

\begin{document}
Testing
\begin{IEEEeqnarray*}{rCl}
    A &=B\\
    B &=C\\
\end{IEEEeqnarray*}

\end{document}

Same as previous but with the new environment definition in the preamble only, not used in the text: 0 words

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}

\newenvironment{EqnExcluded}{
%TC:ignore
    \begin{IEEEeqnarray*}
    }{%
    \end{IEEEeqnarray*}
%TC:endignore
}

\begin{document}
Testing
\begin{IEEEeqnarray*}{rCl}
    A &=B\\
    B &=C\\
\end{IEEEeqnarray*}

\end{document}

align* giving 1 word, 1 math display:

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}

\begin{document}
Testing
\begin{align*}
    A &=B\\
    B &=C\\
\end{align*}

\end{document}
2
  • not directly related but if you use rCl columns shouldn't that be A&=B\\ ? It is partially related as if you do use &=& which is eqnarray syntax you could use eqnarray* in the document (which texcount knows and then just define that to be the IEEE version for typersetting. Apr 21 at 7:34
  • @DavidCarlisle Ah yes, I changed that for the align environment and thought it better to have the same content between MWE, thanks.
    – George
    Apr 21 at 12:20

1 Answer 1

6

You can tell texcount that the environment is displaymath with one argument it should ignore

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}
%TC:envir IEEEeqnarray* [ignore] displaymath
\begin{document}
Testing
\begin{IEEEeqnarray*}{rCl}
    A &=&B\\
    B &=&C\\
\end{IEEEeqnarray*}

\end{document}

Produces

$ texcount file.tex 
File: file.tex
Encoding: ascii
Words in text: 1
Words in headers: 0
Words outside text (captions, etc.): 0
Number of headers: 0
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 1
5
  • Minor correction, which in this case makes no difference but might be useful to know. In order to tell TeXcount that the environment takes one argument which should be ignored, the line should read %TC:envir IEEEeqnarray* [ignore] displaymath. The original line, %TC:envir IEEEeqnarray* [] displaymath means it takes no arguments, and so the argument will be processed as part of the contents, ie as part of the displaymath. I'll correct the answer. Apr 21 at 10:38
  • @EinarRødland thanks, it was actually the first time I have used texcount and I only skimmed the manual:-) Apr 21 at 11:03
  • Just a note for future users - when I put this in a separate preamble file included with \input it didn't work at first, but putting it into the main file then excluded the environment as expected. (not sure if there's a reason for this - I have very little texcount experience)
    – George
    Apr 21 at 12:41
  • 1
    texcount is just a perl script with almost no real tex knowledge built in so it's not surprising that it needs its configuration in the main file (or a separate config fiele specified on the commandline options) but I haven't used it before so I am no expert heer. @George Apr 21 at 12:48
  • 1
    @George: As David correctly pointed out, TeXcount doesn't actually run TeX. By default, it only processes files you explicitly give it. Options -inc or -merge will process included files: not sure which Overleaf uses. Using -inc will process included files, but as separate files, so definitions will be processed after the main file and thus not give the result you desire. The -merge option will cause TeXcount to merge included files into the main file, and should work. Unfortunately, Overleaf seems to handle file paths/working directory differently, and so it still may not work. Apr 21 at 22:50

You must log in to answer this question.

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