你好,有没有类似的东西texcount
可以计算乳胶文件中的所有单词,包括由input
和链接的单词include
?
对我来说,适用于 Linux 和 Windows 的解决方案都很好。
答案1
TeXcount 可以包含 或 包中包含的子文件\input
。\include
为此subfiles
,您需要使用选项-inc
,这将自动解析子文件,或-merge
将包含的子文件合并到主文档中。
答案2
将此脚本另存为buildFile.pl
并使用 Perl 运行它或执行它:buildFile.pl < main.tex > mainTotal.tex
。然后您有一个可以使用 texcount 或其他东西的 TeX 文档。但是,有时创建 pdf 并使用其他工具来计算单词更容易,例如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; }
}