eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
if 0;
use strict; # to be sure, that all is safe ... :-)
# $Id: tikzimg.pl 2012-02-10 Pablo $
# v. 1.0 Extract tikzpicture, based on pst2pdf by Herbert Voss
# 2012-02-10 (c) Pablo González Luengo
# Thanks to Giuseppe Matarazzo
# Couple to have the complete operation of the script, you need some software (Linux and Windows)
# xpdf (needed to create EPS/PPM, called poppler-utils in Linux)
# gnuplot (not necessary if not called from TiKZ)
# pdftk (not necessary with the-pdftk)
# ImageMagick (required if you want to create JPG/PNG/SVG or other format)
#
use File::Path;
use File::Copy;
use File::Basename;
use IO::File;
use Getopt::Long;
use autodie;
#----------------------- User part begin ------------------------
my $imageDir = "images";
my $Iext = ".pdf"; # leave empty, if not a special one
my $tempDir = "."; # temporary directory
my $Verbose = 1; # 0 or 1, logfile
my $clear = 0; # 0 or 1, clears all temporary files
my $DPI = 75; # very low value for ppm files
my $Iscale = 1; # for \includegraphics
my $noImages = 0; # 1->create no images
my $single = 0; # 1->create images in single mode
my $ppm = 0; # 1->create .ppm files
my $norun = 0; # 1->create file, but not compiled
my $miktex = 0; # 1->run in miktex distro
my $eps = 0; # 1->create .eps files
my $files = 0; # 1->create file.tex for all enviroment
my $all = 0; # 1->create all images and files for type
my $nopdftk = 0; # 1->create all images and files for type in force mode
my $xetex = 0; # 1->create all images using xelatex
my $luatex = 0; # 1->create all images using lualatex
#----------------------- User part end ---------------------------
#-----------------program identification, options and help--------
my $program = "tikzimg";
my $ident = '$Id: tikzimg v1.0, 2012-02-10 pablo $';
my $copyright = <<END_COPYRIGHT ;
Copyright 2012-02-10 (c) Pablo Gonzalez L <pablgonz\@yahoo.com>
END_COPYRIGHT
my $licensetxt = <<END_LICENSE ;
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
END_LICENSE
my $title = "$program $ident\n";
my $usage = <<"END_OF_USAGE";
${title}Usage: $program <texfile.tex> [options]
tikzimg run a LaTeX file, and extract all TiKZ-related part as
single images (pdf or eps or ppm, default pdf) and
then runs (pdf/Xe/Lua)latex. See tikzimg
documentation for more info.
Options:
--h|help - display this help and exit
--v|version - display version information and exit
--l|license - display license information and exit
--imageDir - the dir for the created images (default images)
--DPI=<int> - the dots per inch for a cretaed ppm files (default 75)
--p|ppm - create .ppm files
--e|eps - create .eps files
--Iscale=<real> - the value for [scale=] in \\includegraphics
--noImages - generate files without compile (need -norun)
--Verbose - creates long log
--c|clear - delete all temp files
--n|norun - create file-pdf.tex, but, no run pdflatex
--m|miktex - for miktex users -enable-write18
--f|files - create images files (.tex) for all TiKZ enviroment
--s|single - create images whitout pdftk.
--all - create all image type and images.tex
--nopdftk - create all image type and images.tex in single mode
--xetex - create all image using xelatex
--luatex - create all image using lualatex
Examples:
* $program test.tex --all
* produce test-pdf.tex and .ppm,.eps,.tex,.pdf
* for all TiKZ-enviroment.
END_OF_USAGE
#
my $result = GetOptions(
'h|help' => \$::opt_help,
'v|version' => \$::opt_version,
'l|license' => \$::opt_license,
'd|DPI=i' => \$DPI,
"Iscale=f" => \$Iscale,
'id|imageDir=s' => \$imageDir,
"tempDir=s" => \$tempDir,
"Iext=s" => \$Iext,
'c|clear' => \$clear,
"noImages" => \$noImages,
's|single' => \$single,
'p|ppm' => \$ppm,
'n|norun' => \$norun,
'm|miktex' => \$miktex,
'e|eps' => \$eps,
'f|files' => \$files,
'a|all' => \$all,
"nopdftk" => \$nopdftk,
"Verbose" => \$Verbose,
"xetex" => \$xetex,
"luatex" => \$luatex,
) or die $usage;
# help functions
sub errorUsage { die "Error: @_ (try --help for more information)\n"; }
# options for command line
if ($::opt_help) {
print $usage;
exit(0);
}
if ($::opt_version) {
print $title;
print $copyright;
exit(0);
}
if ($::opt_license) {
print $licensetxt;
exit(0);
}
# open file
my $InputFilename = "";
@ARGV > 0 or errorUsage "Input filename missing";
@ARGV < 2 or errorUsage "Unknown option or too many input files";
$InputFilename = $ARGV[0];
# end open file
my @SuffixList = ( ".tex", "", ".ltx" ); # possible extensions
my ( $name, $path, $ext ) = fileparse( $ARGV[0], @SuffixList );
if ( $ext eq "" ) { $ext = ".tex"; } # me need the extension as well
my $TeXfile = "$path$name$ext";
open my $LOGfile,'>', "$tempDir/$name.plog";
LOG("Parameters:");
LOG("==> imageDir = $imageDir");
LOG("==> Iext = $Iext");
LOG("==> DPI = $DPI");
LOG("==> Iscale = $Iscale");
LOG("==> tempDir = $tempDir");
LOG("==> Verbose = $Verbose");
LOG("==> clear = $clear");
LOG("==> noImages = $noImages");
LOG("==> single = $single");
LOG("==> ppm = $ppm");
LOG("==> miktex = $miktex");
LOG("==> eps = $eps");
LOG("==> files = $files");
LOG("==> xetex = $xetex");
LOG("==> luatex = $luatex");
# General options
if ($ppm) {
LOG("Generate .ppm files ...");
$ppm = 1;
}
if ($norun) {
LOG("no compile file-pdf.tex");
$norun = 1;
}
if ($miktex) {
LOG("enable write 18 ...");
$miktex = 1;
}
if ($eps) {
LOG("Generate .eps files ...");
$eps = 1;
}
if ($files) {
LOG("Generate .tex images files ...");
$files = 1;
}
if ($all) {
LOG("Generate all images files ...");
$files = $eps = $ppm = $clear = 1;
}
if ($nopdftk) {
LOG("Generate all images in single mode ...");
$single = $files = $eps = $ppm = $clear = 1;
}
if ($xetex) {
LOG("Generate all images using XeLaTeX");
$xetex = 1;
}
if ($luatex) {
LOG("Generate all images using LuaLaTeX");
$luatex = 1;
}
# Internal image counter
my $imgNo = 1;
# ------------------ simgle mode , compile separte files
if ($single) {
LOG("Running on [$path][$name][$ext]");
open my $FILE, '<', "$TeXfile";
LOG("Generate images in single mode...");
if ( -d $imageDir ) { LOG("$imageDir exists") }
else { mkdir $imageDir, 0744; }
savePreamble($name);
runFile($name);
close $FILE;
close $LOGfile;
}
else {
LOG("Running on [$path][$name][$ext]");
open my $FILE, '<', "$TeXfile";
if ( !$noImages) {if ( -d $imageDir ) { LOG("$imageDir exists") }
else {mkdir $imageDir, 0744;
LOG("Imagedir created");
}
LOG("go to savePreamble ... ");
runBurst($tempDir);
savePreamble($name);
runFile($name);
LOG("done!\n go to runFile ...");
LOG("done!");
close $LOGfile;
}
close $FILE;
}
#------------ Create filename-pics.pdf, split and generate .ppm
sub runBurst {
if ($single) { print "Force mode"; }
else {
my $entrada = "$TeXfile";
my $salida = "$name-pics.tex";
open my $ENTRADA,'<', "$entrada";
open my $SALIDA,'>',"$salida";
print $SALIDA "\\AtBeginDocument\{\n";
if($xetex){
print $SALIDA "\\RequirePackage\[xetex,active,tightpage\]\{preview\}\n";}
else{
print $SALIDA "\\RequirePackage\[active,tightpage\]\{preview\}\n";}
print $SALIDA "\\renewcommand\\PreviewBbAdjust\{-600pt -600pt 600pt 600pt\}\n";
print $SALIDA "\\newenvironment{tikzexport}{}{}\n";
print $SALIDA "\\PreviewEnvironment\{tikzexport\}\n";
print $SALIDA "\\PreviewEnvironment\{tikzpicture\}\}\n";
while ( my $linea = <$ENTRADA> ) {
print $SALIDA $linea;
}
close $ENTRADA;
close $SALIDA;
if($xetex){
if ($miktex){
system("xelatex -enable-write18 -interaction=batchmode $tempDir/$name-pics.tex");}
else{
system("xelatex -shell-escape -interaction=batchmode $tempDir/$name-pics.tex");}
system("pdfcrop -xetex -margin 2 $tempDir/$name-pics.pdf $tempDir/$name-pics.pdf");
}
elsif($luatex){
if ($miktex){
system("lualatex -enable-write18 -interaction=batchmode $tempDir/$name-pics.tex");}
else{
system("lualatex -shell-escape -interaction=batchmode $tempDir/$name-pics.tex");}
system("pdfcrop -luatex -margin 2 $tempDir/$name-pics.pdf $tempDir/$name-pics.pdf");
}
else{
if ($miktex){
system("pdflatex -enable-write18 -interaction=batchmode $tempDir/$name-pics.tex");}
else{
system("pdflatex -shell-escape -interaction=batchmode $tempDir/$name-pics.tex");}
system("pdfcrop -margin 2 $tempDir/$name-pics.pdf $tempDir/$name-pics.pdf");
}
system("pdftk $name-pics.pdf burst output $imageDir/$name-tikz-\%1d.pdf");
if($ppm){
system("pdftoppm -r $DPI $name-pics.pdf $imageDir/$name-tikz");
}
}
}
#------------ end pdftk burst
LOG("runpdfTeX ... ");
runpdfTeX( "$path$name", $name );
LOG("all finished ... ");
# Save preable
sub savePreamble {
my $filename = pop;
LOG("----- Start Preamble -----");
open my $FILEp, '>', "$tempDir/$filename.preamble";
open my $FILE, '<', "$name.tex";
while (<$FILE>) {
my $i = index( $_, "begin{document}\n" );
if ( $i > 0 ) {
if ( $i > 1 ) { print $FILEp substr( $_, 0, --$i ); }
if ($single) {
print $FILEp "\\newenvironment{tikzexport}{}{}\n";
print $FILEp "\\pagestyle{empty}\n";
}
close $FILEp;
LOG("----- Close Preamble ------");
return;
}
else {
print $FILEp "$_";
LOG("$_");
}
}
close $FILE;
close $FILEp;
if ($Verbose) { LOG("<-----Preamble<----"); }
return;
}
sub searchTiKZ {
my @TiKZ = ();
my @TiKZtotal = ();
my $depth = -1;
my $type = -1;
my $EndDocument = 0;
my $iVerb = 0;
open my $FILE, '<', "$name.tex";
while (<$FILE>) {
if (!$EndDocument) {
chomp;
my $line = $_;
if ( !$iVerb ) {
$iVerb = ((index($line,"begin{verbatim*}") > 0) or (index($line,"begin{verbatim}") > 0) or (index($line,"begin{lstlisting}") > 0) or (index($line,"begin{Verbatim}") > 0));
}
if ( !$iVerb ) {
my $iTiKE = index($line,"begin{tikzexport}");
my $iTiKZ = index($line,"begin{tikzpicture}");
if ($iTiKZ < 0) { $iTiKZ = index($line,"begin{dependency}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"begin{circuitikz}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"begin{tikzcd}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"begin{ganttchart}"); }
if (($iTiKE > 0) && ( $type == 1 )){ print "tikzexport environment must be of outer level!\n"; exit 1; }
if ( $type < 0 ) {
if ($iTiKE > 0) {
$type = 2;
$line = substr($line,$iTiKE-1);
LOG("TikZ -line: $line");
}
elsif ( $iTiKZ > 0 ) {
$type = 1;
$depth++;
$line = substr($line,$iTiKZ-1);
LOG("TiKE-line: $line");
}
}
#
if ($type > 0) {
LOG ("searchTiKZ: set \$type=$type");
$iTiKZ = index($line,"end{tikzpicture}");
if ($iTiKZ < 0) { $iTiKZ = index($line,"end{tikzcd}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"end{dependency}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"end{circuitikz}"); }
if ($iTiKZ < 0) { $iTiKZ = index($line,"end{ganttchart}"); }
$iTiKE = index($line,"end{tikzexport}");
if ($iTiKZ > 0) {
if ( $type < 2) {
LOG ("searchTiKZ: $line");
$depth--;
if ($depth < 0) {
$type = -1;
if (index($line,"end{tikzcd}") > 0)
{push @TiKZ,substr($line,0,$iTiKZ+11); }
if (index($line,"end{circuitikz}") > 0)
{push @TiKZ,substr($line,0,$iTiKZ+15); }
if (index($line,"end{tikzpicture}") > 0)
{ push @TiKZ,substr($line,0,$iTiKZ+16); }
if (index($line,"end{dependency}") > 0)
{ push @TiKZ,substr($line,0,$iTiKZ+15); }
if (index($line,"end{ganttchart}") > 0)
{ push @TiKZ,substr($line,0,$iTiKZ+15); }
LOG ("searchTiKZ: set \$type=$type");
push @TiKZtotal,[@TiKZ];
LOG ("---->TikZ---->\n@TiKZ\n<----TikZ<----");
@TiKZ = ();
}
} else { push @TiKZ,$line; }
} elsif ($iTiKE > 0) {
LOG ("searchTiKZ: $line");
$type = -1;
push @TiKZ,substr($line,0,$iTiKE+15);
LOG ("searchTiKZ: set \$type=$type");
push @TiKZtotal,[@TiKZ];
LOG ("---->tikzexp---->\n@TiKZ\n<----tikzexp<----");
@TiKZ =();
} else { push @TiKZ,$line; } # add line
}
my $i = index($line,"end{document}");
if ($i > 0) { $EndDocument++; LOG("EndDocument in searchTiKZ"); }
}
if ((index($line,"end{verbatim*}") > 0) or ( index($line,"end{verbatim}") > 0 ) or ( index($line,"end{lstlisting}") > 0 ) or (index($line,"end{Verbatim}") > 0 )) { $iVerb = 0; }
}}
if ( $Verbose ) {
LOG("---->TikZtotal---->");
for my $aref ( @TiKZtotal ) {
my @a = @$aref;
my $i = 1;
foreach ( @a ) { LOG ($a[$i]); $i=$i+1; }
}
LOG ("<----tikzotal<----");
}
close $FILE;
return @TiKZtotal;
}
# Creating files, eps, pdf and ppm for images
if ($single) {
sub runFORCE{
my $filename = pop;
if($xetex){
if($miktex){
system("xelatex -enable-write18 -interaction=batchmode $tempDir/$filename-tikz");}
else {
system("xelatex -shell-escape -interaction=batchmode $tempDir/$filename-tikz");}
system("pdfcrop -xetex -margin 2 $tempDir/$filename-tikz.pdf $imageDir/$filename-tikz-$imgNo.pdf");
}
elsif($luatex){
if($miktex){
system("lualatex -enable-write18 -interaction=batchmode $tempDir/$filename-tikz");}
else {
system("lualatex -shell-escape -interaction=batchmode $tempDir/$filename-tikz");}
system("pdfcrop -luatex -margin 2 $tempDir/$filename-tikz.pdf $imageDir/$filename-tikz-$imgNo.pdf");
}
else{
if($miktex){
system("pdflatex -enable-write18 -interaction=batchmode $tempDir/$filename-tikz");}
else {
system("pdflatex -shell-escape -interaction=batchmode $tempDir/$filename-tikz");}
system("pdfcrop -margin 2 $tempDir/$filename-tikz.pdf $imageDir/$filename-tikz-$imgNo.pdf");
}
if($files){
copy( "$filename-tikz.tex", "$imageDir/$filename-tikz-$imgNo.tex" );}
if($eps){
system("pdftops -level3 -eps $imageDir/$filename-tikz-$imgNo.pdf $imageDir/$filename-tikz-$imgNo.eps");}
if ($ppm) {
system("pdftoppm -r $DPI $imageDir/$filename-tikz-$imgNo.pdf $imageDir/$filename-tikz-$imgNo");}
$imgNo = $imgNo + 1;
}
}
else {
# Creating files and eps for images
sub runTeX {
my $filename = pop;
if ($eps) {
system("pdftops -level3 -eps $imageDir/$filename-$imgNo.pdf $imageDir/$filename-$imgNo.eps");}
if ($files) {
copy( "$filename.tex", "$imageDir/$filename-$imgNo.tex" );}
$imgNo = $imgNo + 1;
}
}
sub runFile {
my $filename = pop;
my @TiKZarray = searchTiKZ();
if ( $Verbose ) {
LOG("---->TiKZarray---->");
for my $aref ( @TiKZarray ) {
my @a = @$aref;
my $i = 1;
foreach ( @a ) { print LOG $a[$i]."\n"; $i=$i+1; }
}
LOG("<----TiKZarray<----");
my $no = @TiKZarray;
LOG("TiKZ: ".$no." TiKZ sequence(s)");
}
for my $aref ( @TiKZarray ) {
my @TiKZ = @$aref;
open my $FILEp,'<',"$tempDir/$filename.preamble";
open my $FILEsub,'>',"$tempDir/$filename-tikz.tex";
while (<$FILEp>) {print $FILEsub $_; }
print $FILEsub "\\begin{document}\n";
if ( $Verbose ) { LOG("\@TiKZ: $_"); }
foreach ( @TiKZ ) { print $FILEsub "$_\n"; }
print $FILEsub "\\end{document}";
close $FILEsub;
close $FILEp;
if ($single) {
runFORCE("$name");
}
else{
runTeX("$tempDir/$name-tikz");
}
}
}
# Renaming ppm need for correct name
if (!$noImages){
my $dren = "$tempDir/$imageDir";
my $fichero = '';
my $ppmren = '';
my $renNo = 1;
if(opendir(DIR,$dren)){
foreach (readdir DIR){
$fichero = $_;
if ( $fichero =~ /($name-tikz-)(\d+|\d+[-]\d+).ppm/) {
my $renNo = int($2);
my $newname="$1$renNo.ppm";
$ppmren = rename("$dren/$fichero","$dren/$newname");
}
}
}
closedir DIR;
}
#----------------------- Replace files ----------------
sub runpdfTeX() {
my ($name,$pdfname) = @_;
open my $PDF,'>',"$tempDir/$pdfname-pdf.tex";
open my $FILE,'<',"$name.tex";
my $ignore = 0;
my $IMGno = 1;
my $depth = -1;
my $type = -1;
my $EndDocument = 0;
my $iVerb = 0;
while (<$FILE>) {
if ( !$iVerb ) {
$iVerb = ((index($_,"begin{verbatim*}") > 0) or (index($_,"begin{verbatim}") > 0) or (index($_,"begin{lstlisting}") > 0) or (index($_,"begin{Verbatim}") > 0));
}
if ( !$iVerb ) {
my $i = index($_,"end{document}");
if ($i > 0) { print $PDF $_; $EndDocument++; LOG("EndDocument in runpdfTeX"); }
if ( !$EndDocument ) {
my $iTiKE = index($_,"begin{tikzexport}");
if ( $iTiKE > 0 ) {
$type = 2;
$ignore = 1;
if ($iTiKE > 1) { print $PDF substr($_,0,--$iTiKE); }
print $PDF "\\includegraphics[scale=$Iscale]{$pdfname-tikz-$IMGno}";
$IMGno=$IMGno+1;
}
if ( $type < 2 ) {
my $iTiKZ = index($_,"begin{tikzpicture}");
if ($iTiKZ < 0) { $iTiKZ = index($_,"begin{tikzcd}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"begin{dependency}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"begin{circuitikz}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"begin{ganttchart}"); }
if ( $iTiKZ >= 0 ) {
$ignore = 1;
$type = 1;
$depth++;
LOG("Increase depth: $depth");
if ( $depth == 0 ) {
if ($iTiKZ > 1) { print $PDF substr($_,0,--$iTiKZ); }
print $PDF "\\includegraphics[scale=$Iscale]{$pdfname-tikz-$IMGno}";
$IMGno=$IMGno+1;
LOG("Increase Image counter: $IMGno");
}
}
}
if ( !$ignore ) { print $PDF "$_"; }
if ( $type == 2 ) {
my $iTiKE = index($_,"end{tikzexport}");
if ($iTiKE > 0) {
print $PDF substr($_,$iTiKE+15);
$ignore = 0;
$type=-1;
}
} elsif ( $type == 1 ) {
my $iTiKZ = index($_,"end{tikzpicture}");
if ($iTiKZ < 0) { $iTiKZ = index($_,"end{dependency}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"end{tikzcd}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"end{circuitikz}"); }
if ($iTiKZ < 0) { $iTiKZ = index($_,"end{ganttchart}"); }
if ($iTiKZ > 0) {
if (index($_,"end{tikzpicture}") > 0)
{ print $PDF substr($_,$iTiKZ+16); }
if (index($_,"end{dependency}") > 0)
{ print $PDF substr($_,$iTiKZ+15); }
if (index($_,"end{tikzcd}") > 0)
{ print $PDF substr($_,$iTiKZ+11); }
if (index($_,"end{circuitikz}") > 0)
{ print $PDF substr($_,$iTiKZ+15); }
if (index($_,"end{ganttchart}") > 0)
{ print $PDF substr($_,$iTiKZ+15); }
$depth--;
LOG("Decrease depth: $depth");
if ($depth < 0) { $ignore = 0; }
}
}
}
}
else { print $PDF $_; }
if ((index($_,"begin{verbatim*}") > 0) or ( index($_,"end{verbatim}") > 0 ) or ( index($_,"end{lstlisting}") > 0 ) or ( index($_,"end{Verbatim}") > 0 )) { $iVerb = 0; }
}
close $FILE;
close $PDF;
# --------------- Adding lines in preamble ----------------------
open my $IPDF,'<', "$tempDir/$pdfname-pdf.tex";
undef $/; # read all file
my ($uno,$dos) = split(/\\begin\{document\}/,<$IPDF>,2);
close $IPDF;
my @coment = split /\n/, $uno;
my @preamb;
foreach my $line (@coment) {
chomp($line);
$line =~ s/\\usepackage(?:\[.+?\])?\{grfext\}//g;
$line =~ s/\\PrependGraphicsExtensions\*\{.+?\}//g;
$line =~ s/(\\usepackage(?:\[.+?\])?)\{graph/\%$1\{graph/g;
$line =~ s/(\\graphicspath)\{\{/\%$1\{\{/g;
next if $line =~ m/^\s*$/;
push(@preamb,$line);
}
my $clean = join("\n", @preamb, "\\usepackage{grfext}\n\\\PrependGraphicsExtensions*{$Iext}\n\\usepackage{graphicx}\n\\graphicspath{{$imageDir/}}\n\\begin{document}". $dos);
open my $OPDF,'>',"$tempDir/$pdfname-pdf.tex";
print $OPDF $clean;
close $OPDF;
#------------------------- Compiled final file --------------------------
if ($norun) { print "Done\n"; }
else{
if ($xetex) {
system("xelatex -interaction=batchmode $tempDir/$pdfname-pdf.tex");}
elsif ($luatex) {
system("lualatex -interaction=batchmode $tempDir/$pdfname-pdf.tex");}
else {
system("pdflatex -interaction=batchmode $tempDir/$pdfname-pdf.tex");}
print "Done\n";
}
if ($ppm){
print "If you need to create jpg/png/svg type cd $imageDir and run\n";
print "mogrify -format [ext] *.ppm\n";
}
}
#----------------Clear Temp files -----------------------------
if ($clear) {
if ($norun){}
if ($single) {
unlink "$tempDir/$name-tikz.pdf";
unlink "$tempDir/$name-tikz.aux";
unlink "$tempDir/$name-tikz.log";
unlink "$tempDir/$name-tikz.tex";
unlink "$tempDir/$name.plog";
unlink "$tempDir/$name.preamble";
unlink "$tempDir/$name-pdf.aux";
unlink "$tempDir/$name-pdf.log";
}
else {
unlink "$tempDir/$name.plog";
unlink "$tempDir/$name.preamble";
unlink "$tempDir/$name-pdf.aux";
unlink "$tempDir/$name-pdf.log";
unlink "$tempDir/$name-pics.pdf";
unlink "$tempDir/$name-pics.tex";
unlink "$tempDir/$name-pics.aux";
unlink "$tempDir/$name-pics.log";
unlink "$tempDir/$name-tikz.tex";
}
}
sub LOG() {
if ($Verbose) { print $LOGfile "@_\n"; }
}
__END__