4

When using TeXcount on the following MWE \multicolumn macro is counted as a word and I get:

Words in text: 6

What can I do to avoid this behavior and get the correct word count?

\documentclass{article}

%TC:group table 0 1
%TC:group tabular 1 1

%TC:macro \specialcell [0,text]


\newcommand{\specialcell}[3][c]{%
    \begin{tabular}[#1]{@{}#2@{}}#3\end{tabular}}

\begin{document}


\begin{table}
    \begin{tabular}{lr}
        \multicolumn{2}{c}{word1 word2} \\
        word3 & \specialcell[t]{l}{word4\\word5} \\
    \end{tabular}
\end{table}


\end{document}
2

Ouch! This was a nasty bug!

Problem is that \mu gets interpreted as the greek letter, and so \multicount gets parsed as a the word {\mu}lticount.

The error is in the line

my $specialchars='\\\\('.join('|',@LetterMacros).')(\{\}|\s*|\b)';

which should have read

my $specialchars='\\\\('.join('|',@LetterMacros).')(\{\}|\s+|\b)';

with \s* replaced by \s+ to ensure there's something to separate the \mu from the rest of the word (in the case where it is actually the greek letter).

If you correct this code line in the script, it should work without any need for the work-around.

2
  • Thank you very much! That solves the prolem. Hope the online script would be updated as well. Apr 8 '14 at 21:23
  • @NikosPapandreou: The script is now updated online at app.uio.no/ifi/texcount for both the web-service and the downloadable Perl script. Apr 11 '14 at 13:52
2

I am not familiar with texcount. At least I found a workaround:

%TC:macro \tcmulticolumn [ignore,ignore,text]
%TC:subst \multicolumn \tcmulticolumn

Or a little shorter (the number means the number of ignored arguments):

%TC:macro \tcmulticolumn 2
%TC:subst \multicolumn \tcmulticolumn

I do not know, why the direct approach %TC:macro \multicolumn [ignore,ignore,text] is not working.

Full example file:

\documentclass{article}

%TC:group table 0 1
%TC:group tabular 1 1

%TC:macro \specialcell [0,text]

\newcommand{\specialcell}[3][c]{%
    \begin{tabular}[#1]{@{}#2@{}}#3\end{tabular}}

%TC:macro \tcmulticolumn 2
%TC:subst \multicolumn \tcmulticolumn

\begin{document}

\begin{table}
    \begin{tabular}{lr}
        \multicolumn{2}{c}{word1 word2} \\
         word3 & \specialcell[t]{l}{word4\\word5} \\
    \end{tabular}
\end{table}

\end{document}

Result:

File: test.tex
Encoding: ascii
Words in text: 5
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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