TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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}
share|improve this answer
    
Thanks. That is embarrassingly easy.... – cfr Jan 5 at 2:10

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.

share|improve this answer
    
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 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 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 at 1:29
    
@cfr I'll edit it to say that (actually you could have done that as well:-) – David Carlisle Jan 5 at 1:29
    
@cfr updated with plan b for more complicated cases – David Carlisle Jan 5 at 1:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.