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.
TeXcount 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.
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.
– wipet
Jun 04 '14 at 09:52
texcount inhalt.tex -inc -totalwas exactly what I was looking for. – magu_ Jun 04 '14 at 11:37texcount main.texwith no result: no words counted. Is there a simpler and complete way to execute this command? – nilon Jan 10 '17 at 11:49