Take the 2-minute tour ×
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.

I'm trying to count words in a cyrillic LaTeX document with Texcount.

I run the command perl texcount.pl index.tex and get following output:

D:\wd>perl texcount.pl index.tex

!!! Could not identify document class. !!!
File: index.tex
Encoding: utf8
Words in text: 0
Words in headers: 5
Words outside text (captions, etc.): 0
Number of headers: 1
Number of floats/tables/figures: 0
Number of math inlines: 0
Number of math displayed: 0

(errors:1)

index.tex starts with following line:

\documentclass[a5paper,pagesize,10pt,bibtotoc,pointlessnumbers,
normalheadings,DIV=9,twoside=false]{scrbook}

So documentclass tag is present.

How can I fix this error?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

The root of the problem is the line shift in the optional argument (enclosed in [...]) to \documentclass. Because TeXcount by default fails to parse optional arguments containing line shifts, it fails to identify the document class (scrbook), hence the error message.

TeXcount is a bit restrictive on what it accepts as optional arguments to avoid accidentally gobbling up large portions of text in case it should erroneously interpret an [ after a macro as a macro option.

There are three solutions:

The first solution is to run TeXcount with the option -relaxed which relaxes the constraint on macro options so that line shifts are allowed within them. This is arguably the best solution since it does not require modifying the TeX code, provided it does not cause problems by relaxing the parsing rules too much elsewhere.

The second is to remove the line shift from the first line so the whole \documentclass is on one line. This allows TeXcount to parse the option as a macro option.

The third is simply to ignore the error. The only effect, as far as I can tell, is that TeXcount doesn't figure out which document class is being used. The only use of the document class is that TeXcount may import document class specific macro handling rules, but there aren't a lot of these implemented in TeXcount anyway and none for scrbook as far as I can tell.

share|improve this answer

Changing first line to

\documentclass{scrbook}

fixed the problem.

share|improve this answer

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.