This is my first post. Yesterday I saw this question and I made some PERL code. I know is not exactly the same than you want, and I know it would be better to do it in TeX, but maybe this is useful for some people. It has two options:
Make wordcloud of index entries:
./latextotagcloud.pl index file.tex > file.html
Make wordcloud of cite authors:
./latextotagcloud.pl citea file.tex > file.html
Make wordcloud of cite documents:
./latextotagcloud.pl cited file.tex > file.html
NEW CODE (v 2.0) UPDATED OCTOBER 18, 2011
This new code allows color images
I like them because a small word can be highlighted by it's color.
I saw in monocolor clouds that long words catch eye because of it's width.
#!/usr/bin/perl -w
#v. 2.0
#(c) Xavier de Blas, 2011. This code is GPL 2.0.
use HTML::TagCloud_colors;
#recommended:
$background = "#ffffff"; $color_small ="#333333"; $color_big ="#ff0000";
#alternatives
#$background = "#000066"; $color_small ="white"; $color_big ="red";
#$background = "#ffffff"; $color_small ="#333333"; $color_big ="blue";
if( @ARGV != 2 or ( $ARGV[0] ne "index" and $ARGV[0] ne "citea" and $ARGV[0] ne "cited") ) {
print STDERR "Usage:\n ./latextotagcloud.pl option file.tex > file.html \n(option: index or citea or cited)\n";
exit(0);
}
$option = shift(@ARGV);
open(IN,shift(@ARGV));
undef $/;
while(<IN>) {
if($option eq "index") {
while($_ =~ /\\index{([^@!}\|]*)([^}]*)}/g) {
# while($_ =~ /\\index{([^!}\|]*)([^}]*)}/g) {
$matched = $1;
unless ($2 =~ m/^\|see/) { #don't use the "see other concept" entries
$matched =~ s/ /-/g; #Converts: Index A B -> Index-A-B
# if($matched =~ m/@/) { ($matchedSorting, $matched)=split(/@ /,$matched); }
$seen{$matched}++;
}
}
} elsif($option eq "citea") {
#next line gets "Bosco" in "Bosco1993", but "W3Schools" is written to match "W3Schools2001"
while($_ =~ /\\cite[^{]*{(W3Schools|[A-Za-z'\-]+)[^}]*}/g) {
$seen{$1}++;
}
} elsif($option eq "cited") {
while($_ =~ /\\cite[^{]*{([A-Za-z0-9'\-]+)[^}]*}/g) {
$seen{$1}++;
}
}
}
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<style type=\"text/css\">\n \@import url(latextotagcloud.css);\n</style>";
$maxLevels = 1;
foreach(keys %seen) {
if($seen{$_} > $maxLevels) { $maxLevels = $seen{$_}; }
}
my $cloud = HTML::TagCloud->new(levels=>$maxLevels);
foreach(sort keys %seen) {
$latinized = $_;
$latinized =~ s/'a/á/g;
$latinized =~ s/'e/é/g;
$latinized =~ s/'i/í/g;
$latinized =~ s/'o/ó/g;
$latinized =~ s/'u/ú/g;
$cloud->add("$latinized", "", $seen{$_});
}
print $cloud->html_and_css();#if put a value, limit to that number of tags
open RFILE,">colors.R";
print RFILE "as.data.frame(colorRampPalette(c('$color_small', '$color_big'))($maxLevels+1))"; #ELMILLOR
close RFILE;
system("R CMD BATCH --slave --no-timing colors.R latextotagcloud_pre.css");
open CSSFILE1,"latextotagcloud_pre.css";
open CSSFILE2,">latextotagcloud.css";
$/="\n";
$line = 0;
print CSSFILE2 "<style type=\"text/css\">\n
#htmltagcloud {
text-align: center;
line-height: 1;
}
body { background: $background; }
";
while(<CSSFILE1>){
unless($line == 0) {
$_ =~ /#(......)/;
print CSSFILE2 "span.tagcloud" . ($line-1) ." a {text-decoration: none; color: #$1;}\n";
}
$line ++;
}
print CSSFILE2 "</style>";
close CSSFILE1;
close CSSFILE2;
THIS IS THE OLD CODE (v 1.0) DO NOT USE!
#!/usr/bin/perl -w
#(c) Xavier de Blas, 2011. This code is GPL 2.0.
use HTML::TagCloud;
if( @ARGV != 2 or ( $ARGV[0] ne "index" and $ARGV[0] ne "citea" and $ARGV[0] ne "cited") ) {
print STDERR "Usage:\n ./latextotagcloud.pl option file.tex > file.html \n(option: index or citea or cited)\n";
exit(0);
}
$option = shift(@ARGV);
open(IN,shift(@ARGV));
undef $/;
while(<IN>) {
if($option eq "index") {
while($_ =~ /\\index{([^@!}\|]*)[^}]*}/g) {
($underscored = $1) =~ s/ /_/g; #Converts: Index A B -> Index_A_B
$seen{$underscored}++;
}
} elsif($option eq "citea") {
#next line gets "Bosco" in "Bosco1993", but "W3Schools" is written to match "W3Schools2001"
while($_ =~ /\\cite[^{]*{(W3Schools|[A-Za-z\-]+)[^}]*}/g) {
$seen{$1}++;
}
} elsif($option eq "cited") {
while($_ =~ /\\cite[^{]*{([A-Za-z0-9\-]+)[^}]*}/g) {
$seen{$1}++;
}
}
}
my $cloud = HTML::TagCloud->new();
foreach(sort keys %seen) { $cloud->add("$_", "", $seen{$_}); }
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print $cloud->html_and_css();
save in in a file named:
latextotagcloud.pl
and do:
chmod +x latextotagcloud.pl
you need to have libhtml-tagcloud-perl (and obviously perl) installed.
With new 2.0 code you will need R installed (eg. instal r-base on debian/ubuntu systems)
With new 2.0 code you also need to modify libtagcloud. Instructions for Debian/Ubuntu:
- dpkg -L libhtml-tagcloud-perl
- Find: TagCloud.pm
- In Linux Mint (Debian/Ubuntu) is here: /usr/share/perl5/HTML/TagCloud.pm
- Go to /usr/share/perl5/HTML and copy the file:
- sudo cp TagCloud.pm TagCloud_colors.pm
- Change this in TagCloud_colors:
foreach my $level (0 .. $self->{levels}) {
my $font = 12 + $level;
To this:
my $fontMin = 12;
my $fontMax = 36;
my $fontRang = $fontMax - $fontMin;
foreach my $level (0 .. $self->{levels}) {
#my $font = 12 + $level;
my $font = $fontMin + ( $fontRang * $level / $self->{levels} );
With this you will have an html cloud, to have it nicer in your document, you can:
- Open in browser, print as PDF.
- Open PDF in Inkscape, select all words (cutoff blank paper), properties (adjust to selection), print as PDF.
- Include PDF in your LaTeX or LyX document.
Here is the result on the authors cited on my PhD document today (v1.0):

Result of (v2.0):


Maybe you can use the same and the connect to Wordle, I haven't done this because Worlde is not free software.
Hope it helps