# Note that not counting words is not an option.

All journals in my discipline require a word count on submission, as do most anthology editors, conference organisers and other institutional powers.

How can I run texcount on a .tex file which defines a new column type for use in tabulars with mathematical content.

For example the following MWE compiles fine:

\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}
\begin{document}
\begin{tabular}{C}
x\\
\end{tabular}
\end{document}


but texcount does not like it:

!!! Encountered } without corresponding {. !!!

!!! Encountered } without corresponding {. !!!

!!! Encountered } without corresponding {. !!!

!!! Reached end of file while waiting for $. !!! !!! Reached end of file while waiting for }. !!! !!! Reached end of file while waiting for$. !!!

!!! Reached end of file while waiting for }. !!!

!!! Reached end of file while waiting for }. !!!
File: prawf.tex
Encoding: ascii
Words in text: 0
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: 0

(errors:8)


This question concerning a shell script in a .tex file seems related except that my dollar signs and curly brackets etc. are paired and I'm not using anything in a way TeX does not allow.

Nonetheless, it does work if I write

\newcommand*\makecolC{\newcolumntype{C}{>{$}c<{$}}}
\makecolC


in the sense that I no longer get errors. (texcount appears not to count the tabular at all and gives a count of zero. But that's a different question.)

But I'm tempted to think that there ought to be some better approach to cope with something which is, after all, not in the 'foreign' language of the shell, but pretty basic LaTeX.

Moreover, I have a number of these definitions and it seems ridiculous to define macros to define all of them, just to satisfy texcount's warped sense of propriety.

Is there another way to convince it that my definition is perfectly valid syntax?

Tell texcount to ignore the preamble:

%TC:ignore
\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}
%TC:endignore
\begin{document}
\begin{tabular}{C}
x\\
\end{tabular}
\end{document}

• That doesn't work for me... – user131526 Jul 3 '17 at 14:05
• @PintoDoido Sorry, but it does for me. Of course in the example you get zero words, because tabulars are ignored in the count. – egreg Jul 3 '17 at 14:12

My preferred solution would be to do away with word counts, which are more or less meaningless, but failing that, since it doesn't like the {} you can remove them.

This gives no warnings (but doesn't count inside the table)

\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>$c<$}
\begin{document}
\begin{tabular}{c}
hello world\\
\end{tabular}
count this
\end{document}


gives

Encoding: ascii
Words in text: 2
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: 0


Or for more complicated example given in comments

\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>$c<$}
\let\DOLLAR$\let\DOLLAR$
\newcolumntype{E}{>{\DOLLAR}
r<{= {}\DOLLAR}@{}}
\begin{document}
\begin{tabular}{E}
x+y\\
\end{tabular}
count this
\end{document}


where defining \DOLLAR twice keeps texcount happy.

• I changed career so I now don't have to deal with such silliness:-) I can understand a page count restriction but a word length restriction especially for anything with mathematics is nonsense. The fact that it sometimes is a good idea to do what is asked doesn't mean the numbers used are any more meaningful. – David Carlisle Jan 5 '16 at 1:23
• @cfr note (following the edit to the question) I never said you shouldn't count words, I just said I'd rather not, the tex change I suggested here is probably the simplest, or the alternative I suppose would be to try to modify the patterns in the source of texcount so that you didn't need to change the tex, that's no doubt possible but harder – David Carlisle Jan 5 '16 at 1:27
• In my actual document I have things like \newcolumntype{E}{>{$}r<{= {}$}@{}} which means that I don't think I can simply remove the curly brackets, right? Because the < will not read until the next @? – cfr Jan 5 '16 at 1:29
• @cfr I'll edit it to say that (actually you could have done that as well:-) – David Carlisle Jan 5 '16 at 1:29
• @cfr updated with plan b for more complicated cases – David Carlisle Jan 5 '16 at 1:38