2

I am using TeXcount to count the words in my pdfLatex/XeTex documents. This is working decent overall, but I need TeXcount to ignore my in-text references. By default, TeXcount counts all the in-line BibTex references as 1 word, no matter if it's "X, Y and Z (year)" or "(X year)". But I need this to be counted as 0 words.

I have been looking in the manuals, but nothing is said about this matter. Hope someone can help me here :) Maybe there is a way to make any \cite command not to be counted, without manually adding %TC:ignore in front of it. Maybe this will also allow me to include a manual wordcount per image.

  • @koleygr, well I don't think that that is a possibility, because the TeXcount software counts the words in the .tex file. So \cite{CITATION} is seen as one word, no matter if the bibtex file is compiled or not. A possibility will be to type something like %REPLACE123\cite{CITATION} and replace all the %REPLACE123's by nothing. But this will make it much harder not to exceed the world limits, because it requires an extra step before each count. – Nino Apr 11 '18 at 21:46
  • By default, TeXcount should ignore \cite{ref} unless you have some other setting that overrules this. But maybe you are using some other citation command that TeXcount does not have a rule for? – Einar Rødland Apr 11 '18 at 21:48
  • @EinarRødland that's very strange. Do you maybe know which setting may be wrong? Where it accidentally may have been configured that a \cite command is counted as a word. – Nino Apr 11 '18 at 21:54
  • 1
    If you are using \cite with the optional argument, then the optional argument counts as text. – Heiko Oberdiek Apr 11 '18 at 21:57
1

Instead of filling the comment section, I'll write this down as an answer.

The rule for \cite is \cite[text]{ignore} (encoded somewhat differently in the Perl code of TeXcount). So, as Heiko points out, if you include an optional argument, the words of this will be counted, but not the reference itself.

You can modify the handling of \cite by adding/changing the handling rule. To do this, insert the line

%TC:macro \cite [option:ignore,ignore]

in the document some place before the macro is used. This will change the rule to \cite[ignore]{ignore} and nothing will be counted.

Unless another rule for \cite has been set, which is not something that would happen by accident, or there is some other code prior to \cite which makes TeXcount fail to identify the \cite macro, I cannot think of any way in which \cite{ref} should be counted.

As has been noted by Nino himself, TeXcount has no clue as to how the citation is presented in the text, and so cannot count the words inserted by the \cite macro.

| improve this answer | |
  • Thank you very much. It did the job :-) Guess that was the reason why all the references were counted as one word, due to the page number. – Nino Apr 11 '18 at 22:47

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.