Hi is there something like texcount
to count all the words of a latex file including the ones linked by input
and include
?
Solution for linux as well as for windows are fine for me.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityTeXcount can include subfiles included by \input
, \include
or the subfiles
package. For this, you need to use the option -inc
which will automatically parse the subfiles, or -merge
which will merge the included subfiles into the main document.
texcount inhalt.tex -inc -total
was exactly what I was looking for.
texcount main.tex
with no result: no words counted. Is there a simpler and complete way to execute this command?
Save this script as buildFile.pl
and run it with Perl or execute it: buildFile.pl < main.tex > mainTotal.tex
. Then you have one TeX document which can use texcount or something else. However, sometimes it is easier to create a pdf and count the words with other tools, like pdftotext <file>.pdf - | wc -w
#!/usr/bin/perl -w
##################################################
# build one main file
# (C) 2005 Herbert Voss
##################################################
#
#use strict;
#
# call with
#
# ./buildFile.pl main.tex > mainTotal.tex
#
# in the mainTotal.tex will be comments all starting
# with %%% which will not be of interest
#
sub p_inc {
$fileName = shift;
if ( open (my $file, "$fileName.tex") ) {
print "%%%---------- open: ", $fileName, "\n";
while (<$file>) {
if ((/^\s*\\include{\s+(\S+)/i) or (/^\s*\\input{\s+(\S+)/i)) {
my $include = $1;
chomp($include);chop($include);
print "%%%%%%%%% jump to ", $include, "\n";
p_inc($include);
} else { print unless /^\s*(#|$)/; }
}
print "%%%---------- close: ", $fileName, "\n";
close $file;
} else { print "%%%<===== file does'n exist\n"; }
}
#
@lines = (<>);
for $line (@lines) {
next if $line =~ /^\s*(%)/;
if (($line =~ /^\s*\\include{\s*(\S+)/i) or ($line =~ /^\s*\\input{\s*(\S+)/i)) {
my $include = $1;
chomp($include);
chop($include);
print "%%%%%%%%%%% jump to ", $include, "\n";
p_inc($include);
} else { print $line; }
}
-f
-l
for pdftotext
, you can give the page range and you can exclude toc, tof etc. by this way.