diff options
34 files changed, 1395 insertions, 1 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index 8bf078399aa..ad4072b3b4e 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -120,6 +120,7 @@ texmf_other_scripts = \ lilyglyphs/lily-glyph-commands.py \ lilyglyphs/lily-image-commands.py \ lilyglyphs/lily-rebuild-pdfs.py \ + ltximg/ltximg.pl \ luaotfload/luaotfload-tool.lua \ m-tx/m-tx.lua \ match_parens/match_parens \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index 709b6ba3752..a9f4da2293d 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -325,6 +325,7 @@ texmf_other_scripts = \ lilyglyphs/lily-glyph-commands.py \ lilyglyphs/lily-image-commands.py \ lilyglyphs/lily-rebuild-pdfs.py \ + ltximg/ltximg.pl \ luaotfload/luaotfload-tool.lua \ m-tx/m-tx.lua \ match_parens/match_parens \ diff --git a/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl b/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl new file mode 100755 index 00000000000..ccb7f92fe2d --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl @@ -0,0 +1,516 @@ +#!/usr/bin/perl +use v5.14; +use strict; # to be sure, that all is safe ... :-) +use File::Path; +use File::Copy; +use File::Basename; +use IO::File; +use Getopt::Long; +use autodie; + +my $tempDir = "."; # temporary directory +my $clear = 0; # 0 or 1, clears all temporary files +my $DPI = "300"; # value for ppm +my $margins = "0"; # margins for pdf crop +my $imageDir = "images"; # directorio de imágenes (images por defecto) +my $skip = "skip"; # skip environment +my $latex = 0; # 1->create all images using latex +my $xetex = 0; # 1->create all images using xelatex +my $luatex = 0; # 1->create all images using lualatex +my $IMO = ""; # 1->Options for ImageMagick +my $GSCMD = "gs"; # Ghostscript name +my $other = "other"; # search other environment for export +my $pdf = 0; # 1->create .pdf using ghostscript +my $png = 0; # 1->create .png +my $jpg = 0; # 1->create .jpg +my $eps = 0; # 1->create .eps using pdftops +my $ppm = 0; # 1->create .ppm using pdftoppm +my $useppm = 0; # 1->create jpg/png using mogrify and ppm +my $usemog = 0; # 1->create jpg/png using mogrify +my $all = 0; # 1->create all images and files for type + +#----------------------- User part end --------------------------- +#-----------------program identification, options and help-------- +my $program = "ltximg"; +my $ident = '$Id: ltximg v1.0, 2013-03-12 pablo $'; +my $copyright = <<END_COPYRIGHT ; +Copyright 2013-01-12 (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 file.tex [options] +ltximg create a copy for TeX source whit all TiKZ|Pstricks environments + and convert all environments into single images (pdf/png/eps/jpg). + By default search and extract TiKZ environments using (pdf)LaTeX + and ghostscript (gs). + +Options: + + --h|help - display this help and exit + --v|version - display version information and exit + --li|license - display license information and exit + --imageDir= - the dir for the created images (default images) + --d|DPI= - dots per inch for gs, pdftoppm and mogrify (default 300) + --IMO="..." - aditional options for mogrify (need double quotes) + --c|clear - delete all temp files + --xe|xetex - create all image using xelatex (tikz and pstricks) + --lu|luatex - create all image using lualatex (tikz) + --la|latex - create all image using latex (pstricks) + --up|useppm - create jpg and png using mogrify and ppm + --um|usemog - create jpg and png (transparent) using mogrify and pdf + --m|margins= - margins for pdfcrop (default 0) + --pdf - create .pdf files using gs + --ppm - create .ppm files (need pdftoppm) + --eps - create .eps files (need pdftops) + --jpg - create .jpg files (deafult use gs) + --png - create .png files (deafult use gs) + --s|skip= - name for skip environmet in input file (default skip) + --o|other= - name for other export environmet (default other) + --a|all - create pdf/jpg/png/eps image type + +Example: +* $program test.tex --xe -eps -jpg -c +* produce test-fig-1.pdf, test-fig-2.pdf, test-fig-3.pdf,... +* and test-fig-1.eps, test-fig-2.eps, test-fig-3.eps,... and +* test-fig-1.jpg, test-fig-2.jpg, test-fig-3.jpg,... for all +* TiKZ|Pst environments in image dir using gs and (Xe)latex. +END_OF_USAGE + +# Options +my $result = GetOptions ("imageDir=s" => \$imageDir, + "s|skip=s" => \$skip, + 'h|help' => \$::opt_help, + 'v|version' => \$::opt_version, + 'li|license' => \$::opt_license, + 'd|DPI=i' => \$DPI, + "tempDir=s" => \$tempDir, + 'c|clear' => \$clear, + "la|latex" => \$latex, + "xe|xetex" => \$xetex, + "lu|luatex" => \$luatex, + "o|other=s" => \$other, + "m|margins=s" => \$margins, + "GSCMD=s" => \$GSCMD, + "IMO=s" => \$IMO, + "png" => \$png, + "jpg" => \$jpg, + "eps" => \$eps, + "ppm" => \$ppm, + "up|useppm" => \$useppm, + "um|usemog" => \$usemog, + "pdf" => \$pdf, + "a|all" => \$all + ) 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); +} +# General options +if ($latex) { + $latex = 1; +} +if ($xetex) { + $xetex = 1; +} +if ($luatex) { + $luatex = 1; +} +if ($pdf) { + $pdf = 1; +} +if ($eps) { + $pdf =$eps = 1; +} +if ($jpg) { + $jpg = 1; +} +if ($png) { + $png = 1; +} +if ($ppm) { + $ppm = 1; +} +if ($^O eq 'MSWin32'){ + $GSCMD = "gswin32c"; +} +if ($^O eq 'MSWin64'){ + $GSCMD = "gswin64c"; +} +if ($useppm){ + $ppm = $useppm = 1; +} +if ($usemog){ + $pdf = $usemog = 1; +} +if ($all){ + $pdf =$eps = $png = $jpg = 1; +} +## Create image dir +if (! -e $imageDir) { + mkdir($imageDir,0744) or die "Can't create $imageDir"; +} + +# 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"; + +# Define in file +my $archivo_entrada = shift; + +# Read in file +open my $ENTRADA, '<', $archivo_entrada; +my $archivo; +{ + local $/; + $archivo = <$ENTRADA>; +} +close $ENTRADA; +## cambiar +$archivo =~ +s/(?<inicio>\\begin\{)(?<verb>verbatim|verbatim\*|lstlisting|LTXexample|Verbatim|comment|alltt|minted|tcblisting|xcomment|$skip) (?:\}) +/\\begin\{nopreview} +$+{inicio}$+{verb}\}/gmxs; + +$archivo =~ +s/(?<fin>\\end\{)(?<verb>verbatim|verbatim\*|lstlisting|LTXexample|Verbatim|comment|alltt|minted|tcblisting|xcomment|$skip) (?:\}) +/$+{fin}$+{verb}\} +\\end\{nopreview}/gmxs; +# Save +open my $SALIDA, '>', "$tempDir/$name-tmp.tex"; +print $SALIDA $archivo; +close $SALIDA; + +# Add preview in preamble + +open my $INFILE,'<', "$tempDir/$name-tmp.tex"; +open my $OUTFIlE,'>',"$tempDir/$name-fig.tex"; +print $OUTFIlE "\\AtBeginDocument\{\n"; + if($xetex){ + print $OUTFIlE "\\RequirePackage\[xetex,active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{tikzpicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{pspicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + elsif($latex){ + print $OUTFIlE "\\RequirePackage\[active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{pspicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + else { + print $OUTFIlE "\\RequirePackage\[pdftex,active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{tikzpicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + + while ( my $line = <$INFILE> ) { + print $OUTFIlE $line; + } +close $INFILE; +close $OUTFIlE; + +if ($clear) {unlink "$tempDir/$name-tmp.tex";} + +# Parser inline verbatim + +## Lectura del archivo +open my $PARSER, '<', "$tempDir/$name-fig.tex"; +undef $/; # read al file +my $file_PARSER = <$PARSER>; +close $PARSER; + +## Partición del documento +my($cabeza,$cuerpo,$final) = $file_PARSER =~ m/\A (.+? ^\\begin{document}) \s* (.+?) \s* (^ \\end{document}) \s* \z/msx; + +## Cambios a realizar +my %cambios = ( + '\pspicture' => '\TRICKS', + '\endpspicture' => '\ENDTRICKS', + + '\begin{pspicture' => '\begin{TRICKS', + '\end{pspicture' => '\end{TRICKS', + + '\begin{postscript}' => '\begin{POSTRICKS}', + '\end{postscript}' => '\end{POSTRICKS}', + + '\begin{tikzpicture' => '\begin{TIKZPICTURE', + '\end{tikzpicture' => '\end{TIKZPICTURE', + + "\\begin\{$other" => '\begin{OTHER', + "\\end\{$other" => '\end{OTHER', +); + + +## Variables y constantes +my $no_del = "\0"; +my $del = $no_del; + +## Reglas +my $llaves = qr/\{ .+? \} /x; +my $no_corchete = qr/(?:\[ .+? \])? /x; +my $delimitador = qr/\{ (?<del>.+?) \} /x; +my $verb = qr/verb [*]? /ix; +my $lst = qr/lstinline (?!\*) $no_corchete /ix; +my $mint = qr/mint (?!\*) $no_corchete $llaves /ix; +my $marca = qr/\\ (?:$verb | $lst | $mint) (\S) .+? \g{-1} /x; +my $comentario = qr/^ \s* \%+ .+? $ /mx; +my $definedel = qr/\\ (?: DefineShortVerb | lstMakeShortInline ) $no_corchete $delimitador /ix; +my $indefinedel = qr/\\ (?: UndefineShortVerb | lstDeleteShortInline) $llaves /ix; + + +# Changes + +while ($cuerpo =~ + / $marca + | $comentario + | $definedel + | $indefinedel + | $del .+? $del # delimitado + /gimx) { + + my($pos_inicial, $pos_final) = ($-[0], $+[0]); # posiciones + my $encontrado = ${^MATCH}; # lo encontrado + + given ($encontrado) { + when (/$definedel/) { # definimos delimitador + $del = $+{del}; + $del = "\Q$+{del}" if substr($del,0,1) ne '\\'; # es necesario "escapar" el delimitador + } + when (/$indefinedel/) { # indefinimos delimitador + $del = $no_del; + } + default { # Aquí se hacen los cambios + while (my($busco, $cambio) = each %cambios) { + + $encontrado =~ s/\Q$busco\E/$cambio/g; # es necesario escapar $busco, ya que contiene caracteres extraños + } + + substr $cuerpo, $pos_inicial, $pos_final-$pos_inicial, $encontrado; # insertamos los nuevos cambios + + pos($cuerpo)= $pos_inicial + length $encontrado; # reposicionamos la siguiente búsqueda + } + } +} + +# Write + +open my $OUTPARSER, '>', "$tempDir/$name-fig.tex"; +print $OUTPARSER "$cabeza\n$cuerpo\n$final\n"; +close $OUTPARSER; + +# Compiling files... + +# Using LaTeX + +if($latex){ + print "Compiled using LaTeX\n"; + system("latex -interaction=batchmode $tempDir/$name-fig.tex"); + system("dvips -q -Ppdf $tempDir/$name-fig.dvi"); + system("ps2pdf -dPDFSETTINGS=\/prepress $tempDir/$name-fig.ps $tempDir/$name-fig.pdf"); +if ($clear) { + unlink "$tempDir/$name-fig.dvi"; + unlink "$tempDir/$name-fig.ps"; + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using XeLaTeX + +elsif($xetex){ + print "Compiled using (Xe)LaTeX\n"; + system("xelatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using LuaLaTeX + +elsif($luatex){ + print "Compiled using (lua)LaTeX\n"; + system("lualatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using pdfLaTeX (default) + +else{ + print "Compiled using (pdf)LaTeX\n"; + system("pdflatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Croping + +print "Done, $name-fig.pdf need croping, using pdfcrop whit margin $margins\n"; +system("pdfcrop --margins $margins $tempDir/$name-fig.pdf $tempDir/$name-fig.pdf"); + +# Gs for split file + +if ($pdf) { +print "Create pdf figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=pdfwrite -dPDFSETTINGS=\/prepress -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.pdf $tempDir/$name-fig.pdf"); + +# Delete last pdf (bug from gs) + +my $i = 1; +while (-e "$imageDir/$name-fig-${i}.pdf") { # if exisit search + $i++; # next +} # search end + +$i--; # back the last + +unlink "$imageDir/$name-fig-${i}.pdf"; + +} + +# Fix pdftops error message in windows + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ +open my $ppmconf, '>', "$tempDir/xpd"; +print $ppmconf <<'EOH'; +errQuiet yes +EOH +close $ppmconf; + } + +# Create eps files using pdftops + +if ($eps) { +print "Create eps figs in $imageDir dir using pdftops\n"; +# Search pdf in $imageDir + for my $image_pdf (<$imageDir/*.pdf>) { + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftops -cfg $tempDir/xpd -q -level3 -eps $image_pdf"); + } +else{ + system("pdftops -level3 -eps $image_pdf"); + } + } + } + +# Create ppm files and renamig files + +if($ppm){ +print "Create ppm figs in $imageDir dir using pdftoppm\n"; +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftoppm -cfg $tempDir/xpd -q -r $DPI $tempDir/$name-fig.pdf $imageDir/$name-fig"); + } +else{ + system("pdftoppm -r $DPI $tempDir/$name-fig.pdf $imageDir/$name-fig"); + } + +# Renaming .ppm (only need in windows) + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ +my $dren = "$tempDir/$imageDir"; +my $fichero = ''; +my $ppmren = ''; +my $renNo = 1; +if(opendir(DIR,$dren)){ +foreach (readdir DIR){ + $fichero = $_; + if ( $fichero =~ /($name-fig-)(\d+|\d+[-]\d+).ppm/) { + my $renNo = int($2); + my $newname="$1$renNo.ppm"; + $ppmren = rename("$dren/$fichero","$dren/$newname"); + } + } + } +closedir DIR; + } + } + +# Change dir and create png/jpg formats using mogrify and ppm + +if($usemog){ +chdir ($imageDir) or die "$imageDir not exist\n"; +if ($png) { +print "Create png transparent in $imageDir dir using mogrify and pdf\n"; +system("mogrify $IMO -define png:format=png32 -define png:compression-filter=4 -quality 100 -transparent white -density $DPI -format png \*\.pdf"); + } +if ($jpg) { +print "Create jpg figs in $imageDir dir using mogrify and pdf\n"; +system("mogrify $IMO -quality 100 -density $DPI -format jpg \*\.pdf"); + } +} +elsif($useppm){ +chdir ($imageDir) or die "$imageDir not exist\n"; +if ($png) { +print "Create png figs in $imageDir dir using mogrify and ppm\n"; +system("mogrify $IMO -quality 100 -define png:format=png32 -define png:compression-filter=4 -density $DPI -format png \*\.ppm"); + } +if ($jpg) { +print "Create jpg figs in $imageDir dir using mogrify and ppm\n"; +system("mogrify $IMO -quality 100 -density $DPI -format jpg \*\.ppm"); + } +} +else{ + +# Create png using gs (default) + +if ($png) { +print "Create png figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=png16m -r$DPI -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.png $tempDir/$name-fig.pdf"); + } + +if ($jpg) { +print "Create jpg figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.jpg $tempDir/$name-fig.pdf"); + } + } + + +print "Finish, all figures are in $imageDir dir\n"; + +__END__ diff --git a/Build/source/texk/texlive/linked_scripts/scripts.lst b/Build/source/texk/texlive/linked_scripts/scripts.lst index 16920dc4b34..3af7edd4b5a 100644 --- a/Build/source/texk/texlive/linked_scripts/scripts.lst +++ b/Build/source/texk/texlive/linked_scripts/scripts.lst @@ -69,6 +69,7 @@ latexpand/latexpand lilyglyphs/lily-glyph-commands.py lilyglyphs/lily-image-commands.py lilyglyphs/lily-rebuild-pdfs.py +ltximg/ltximg.pl luaotfload/luaotfload-tool.lua m-tx/m-tx.lua match_parens/match_parens diff --git a/Master/bin/alpha-linux/ltximg b/Master/bin/alpha-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/alpha-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/amd64-freebsd/ltximg b/Master/bin/amd64-freebsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/amd64-freebsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/amd64-kfreebsd/ltximg b/Master/bin/amd64-kfreebsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/amd64-kfreebsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/amd64-netbsd/ltximg b/Master/bin/amd64-netbsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/amd64-netbsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/armel-linux/ltximg b/Master/bin/armel-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/armel-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/armhf-linux/ltximg b/Master/bin/armhf-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/armhf-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-cygwin/ltximg b/Master/bin/i386-cygwin/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-cygwin/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-freebsd/ltximg b/Master/bin/i386-freebsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-freebsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-kfreebsd/ltximg b/Master/bin/i386-kfreebsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-kfreebsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-linux/ltximg b/Master/bin/i386-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-netbsd/ltximg b/Master/bin/i386-netbsd/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-netbsd/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/i386-solaris/ltximg b/Master/bin/i386-solaris/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/i386-solaris/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/mips-irix/ltximg b/Master/bin/mips-irix/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/mips-irix/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/mipsel-linux/ltximg b/Master/bin/mipsel-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/mipsel-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/powerpc-linux/ltximg b/Master/bin/powerpc-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/powerpc-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/sparc-solaris/ltximg b/Master/bin/sparc-solaris/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/sparc-solaris/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/universal-darwin/ltximg b/Master/bin/universal-darwin/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/universal-darwin/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/win32/ltximg.exe b/Master/bin/win32/ltximg.exe Binary files differnew file mode 100755 index 00000000000..5777d90a17a --- /dev/null +++ b/Master/bin/win32/ltximg.exe diff --git a/Master/bin/x86_64-darwin/ltximg b/Master/bin/x86_64-darwin/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/x86_64-darwin/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/x86_64-linux/ltximg b/Master/bin/x86_64-linux/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/x86_64-linux/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/bin/x86_64-solaris/ltximg b/Master/bin/x86_64-solaris/ltximg new file mode 120000 index 00000000000..0e9bba6fed9 --- /dev/null +++ b/Master/bin/x86_64-solaris/ltximg @@ -0,0 +1 @@ +../../texmf-dist/scripts/ltximg/ltximg.pl
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/ltximg/README b/Master/texmf-dist/doc/support/ltximg/README new file mode 100644 index 00000000000..29e0f955e71 --- /dev/null +++ b/Master/texmf-dist/doc/support/ltximg/README @@ -0,0 +1,45 @@ +ltximg is a Perl script which isolates all Tikz or +PSTricks related parts of the TeX document into single +pdf file, split and convert in eps/pdf/png/jpg format. + +The advantage of "ltximg" is the ability to discuss the +environments that give problems using the "preview" package +as "verbatim" in line (verb|...|) or beginning with %, and +other environments (LTXexample, Verbatim,etc). + +The images files are saved in a subdirectory images. + +Syntax: perl ltximg.pl file.tex [options] + +ltximg create a copy for TeX source whit all TiKZ|Pstricks environments + and convert all environments into single images (pdf/png/eps/jpg). + By default search and extract TiKZ environments using (pdf)LaTeX + and ghostscript (gs). + +Options: + + --h|help - display this help and exit + --v|version - display version information and exit + --li|license - display license information and exit + --imageDir= - the dir for the created images (default images) + --d|DPI= - dots per inch for gs, pdftoppm and mogrify (default 300) + --IMO="..." - aditional options for mogrify need double quotes + --c|clear - delete all temp files + --xe|xetex - create all image using xelatex (tikz and pstricks) + --lu|luatex - create all image using lualatex (tikz) + --la|latex - create all image using latex (pstricks) + --up|useppm - create jpg and png using mogrify and ppm + --um|usemog - create jpg and png (transparent) using mogrify and pdf + --m|margins= - margins for pdfcrop (default 0) + --pdf - create .pdf files using gs + --ppm - create .ppm files (need pdftoppm) + --eps - create .eps files (need pdftops) + --jpg - create .jpg files (deafult use gs) + --png - create .png files (deafult use gs) + --s|skip= - name for skip environmet in input file (default skip) + --o|other= - name for other export environmet (default other) + --a|all - create pdf/jpg/png/eps image type + + + +Pablo González 2013-01-12 diff --git a/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf Binary files differnew file mode 100644 index 00000000000..3d64cbf462b --- /dev/null +++ b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf diff --git a/Master/texmf-dist/doc/support/ltximg/ltximg-doc.tex b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.tex new file mode 100644 index 00000000000..9903dcf280a --- /dev/null +++ b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.tex @@ -0,0 +1,244 @@ +\documentclass[11pt]{article} +\usepackage[T1]{fontenc}% +\usepackage{libertine}% +\usepackage{booktabs}% +\usepackage{tabularx}% +\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} +\usepackage[margin=0.85in,letterpaper]{geometry} +\usepackage[scaled=0.9]{inconsolata} +\usepackage{listings} + +\definecolor{lightgrey}{rgb}{0.9,0.9,0.9} +\definecolor{darkgreen}{rgb}{0,0.6,0} +\definecolor{darkred}{rgb}{0.6,0,0} +\definecolor{myblue}{RGB}{20,105,176} +\definecolor{darkgreen}{rgb}{0,0.6,0} + +\lstdefinelanguage{mytex}[LaTeX]{TeX}{ + columns=flexible, + frame=single, + framerule=0pt,% + backgroundcolor=\color{gray!10},% + xleftmargin=\fboxsep,% + xrightmargin=\fboxsep, + alsoletter={\\,*,\&}, + morekeywords={\\AtBeginDocument, + \\RequirePackage, + \\PreviewEnvironment, + \&}, + morekeywords=[2]{pspicture, + verbatim, + table, + other, + tikzpicture, + postscript, + preview, + TRICKS, + POSTRICKS, + TIKZPICTURE, + OTHER, + nopreview}, + morekeywords=[3]{\\begin, + \\pspicture, + \\TRICKS, + \\ENDTRICKS, + \\endpspicture, + \\end}, + literate=*{\{}{{\textcolor{myblue}{\{}}}{1} + {\}}{{\textcolor{myblue}{\}}}}{1} + {[}{{\textcolor{myblue}{[}}}{1} + {]}{{\textcolor{myblue}{]}}}{1}, +} + +\lstset{language=mytex} + +\lstdefinestyle{mystyle1}{ + basicstyle=\small\ttfamily, + keywordstyle=\bfseries\color{red}, + keywordstyle=[2]{\color{magenta}}, + keywordstyle=[3]{\color{blue}}, + commentstyle=\color{darkgreen}, + stringstyle=\color{orange}, + identifierstyle=\ttfamily, + showstringspaces=true, + breaklines=true, + tabsize=4, + columns=fullflexible, + keepspaces=true, +} + +\lstset{style=mystyle1} +\begin{document} +\title{{\huge\textsf{lxtimg}}\\export tikz|pstricks environments to image format\\ \small v. 1.0} +\author{Pablo Gonz\'{a}lez Luengo\\ \small \ttfamily pablgonz at yahoo dot com} +\date{\today} +\maketitle +\begin{abstract} +\noindent + +\textsf{ltximg}\footnote{Thanks to Giuseppe Matarazzo for his kind help on testing the script.} is a \textsf{Perl} script that automates the process to export \textsf{tikzpicture} or \textsf{pspicture} environments to image formats (PDF, EPS, PPM, PNG). +\end{abstract} +\tableofcontents +\section{Required Software} + +For the full operation of the script you need the following opensource programs +(available for windows and linux), external to \textsc{ctan} repositories. + +\begin{itemize} +\item \textsf{Perl}. + +\item \textsf{Ghostscript}. + +\item \textsf{pdftops} (optional, for images in EPS format). + +\item \textsf{pdftoppm} (optional, for images in PPM format). + +\item \textsf{ImageMagick} (optional, for conversion images). +\end{itemize} +\newpage +\section{Run and options} +For \TeX Live or Mik\TeX\ users the syntax for \textsf{ltximg} script is simple: + +\begin{lstlisting} +perl ltximg file.tex -options +\end{lstlisting} + + +\begin{table}[htp] +\caption{Options for ltximg} +\begin{tabularx}{\linewidth}{@{}>{\ttfamily} l>{\ttfamily} l >{\ttfamily}l X @{}}\\\toprule +\emph{name} & \emph{short} & \emph{default} & \emph{description}\\\midrule +--help & --h & & display help information and exit.\\ +--version & --v & & display version information and exit.\\ +--license & --li & & display license information and exit.\\ +--imageDir= & & images & The dir for the created images.\\ +--DPI= & --d & 300 & Dots per inch for gs, pdftoppm and mogrify.\\ +--IMO="..." & & & Aditional options for mogrify (need double quotes).\\ +--clear & --c & & Delete all temp files.\\ +--xetex & --xe & & Create all image using xelatex (tikz and pstricks).\\ +--luatex & --lu & & Create all image using lualatex (tikz).\\ +--latex & --la & & Create all image using latex(pstricks).\\ +--useppm & --up & & Create jpg and png using mogrify and ppm\\ +--usemog & --um & & Create jpg and png (transparent) using mogrify and pdf\\ +--margins= & --m & 0 & Margins for pdfcrop.\\ +--pdf & & & Create .pdf files using gs.\\ +--ppm & & & Create .ppm files (need pdftoppm).\\ +--eps & & & Create .eps files (need pdftops).\\ +--jpg & & & Create .jpg files (deafult use gs).\\ +--png & & & Create .png files (deafult use gs).\\ +--skip= & --s & skip & Name for skip environmet in input file.\\ +--other= & --o & other & Name for other export environmet.\\ +--all & --a & & Create pdf/jpg/png/eps image type.\\ +\bottomrule +\end{tabularx} +\end{table} + +\section{How it works} + +The script works in two steps, but giving the same result, a new file +\emph{without tikzpicture} environments and a folder with the images from +these environments. + +\subsection{Comment and ignore} + +The first step \textsf{ltximg } script create a image dir calls \textsf{images} +and create a copy for in file, processing is as follows, being assumed that our file is \texttt{test.tex}: + +\begin{enumerate} +\item Create a copy file called test-tmp.tex and put the problematic environments (verbatim, verbatim\*, lstlisting, + LTXexample, Verbatim, comment, alltt, minted, tcblisting, xcomment and skip) inside the: + +\begin{lstlisting} +\begin{nopreview} +... +\end{nopreview} +\end{lstlisting} + +and: +\begin{enumerate} +\item If the option is latex adds the following lines to the beginning of the test-fig.tex: + +\begin{lstlisting} +\AtBeginDocument{ +\RequirePackage[active,tightpage]{preview} +\PreviewEnvironment{pspicture} +\PreviewEnvironment{other}} +\end{lstlisting} + +\item If options its xetex adds the following lines to the beginning of the test-fig.tex: + +\begin{lstlisting} +\AtBeginDocument{ +\RequirePackage[xetex,active,tightpage]{preview} +\PreviewEnvironment{tikzpicture} +\PreviewEnvironment{pspicture} +\PreviewEnvironment{other}} +\end{lstlisting} + +\item And if no option is given, adds the following lines at the beginning of the test-fig.tex. This is the default for +lualatex and pdflatex. + +\begin{lstlisting} +\AtBeginDocument{ +\RequirePackage[pdftex,active,tightpage]{preview} +\PreviewEnvironment{tikzpicture} +\PreviewEnvironment{other}} +\end{lstlisting} + +\end{enumerate} + +\item Open test-tmp.tex and change the problematic words for verbatin in line or after \% symbol: + +\begin{lstlisting} +\pspicture => \TRICKS +\endpspicture => \ENDTRICKS +\begin{pspicture => \begin{TRICKS +\end{pspicture => \end{TRICKS +\begin{postscript} => \begin{POSTRICKS} +\end{postscript} => \end{POSTRICKS} +\begin{tikzpicture => \begin{TIKZPICTURE +\end{tikzpicture => \end{TIKZPICTURE +\begin{other => \begin{OTHER +\end{other => \end{OTHER +\end{lstlisting} + +and save file called test-fig.tex then runs (pdf/lua/xe)latex in \texttt{test-fig.tex} and \textsf{pdfcrop} in +\texttt{test-fig.pdf}. +\end{enumerate} +\subsection{Split and convert} +If \textsf{ltximg} called with option \textsf{-pdf} or \textsf{-eps} or \textsf{-um} the file \texttt{test-fig.pdf} +is splitting in \texttt{test-fig-1.pdf, test-fig-2.pdf,\ldots} and puts them into \texttt{images} dir. The invoked behind this command is: + +\begin{lstlisting} +gs -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dBATCH -sOutputFile=imageDir/test-fig-%d.pdf \ +test-fig.pdf +\end{lstlisting} +and then processes the remaining options. + +For example, if you use the option \textsf{-pdf -um} the command behind this is: + +\begin{lstlisting} +mogrify -define png:format=png32 -define png:compression-filter=4 -quality 100 -transparent white \ +-density 300 -format png *.pdf +\end{lstlisting} + +And if you use the option \textsf{-pdf -up} the command behind this is: + +\begin{lstlisting} +mogrify -quality 100 -define png:format=png32 -define png:compression-filter=4 -density 300 \ +-format png *.ppm +\end{lstlisting} + + +\section{Creating other images format} +If you need to create other image formats we first need to generate the PPM format or PDF, then the procedure is simple +using the \textsf{ImageMagick} \texttt{convert} command, command usage is so: +\begin{lstlisting} +mogrify -format ext *.ppm +\end{lstlisting} +for TIFF use +\begin{lstlisting} +mogrify -format tiff *.ppm +\end{lstlisting} + +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/ltximg/test.tex b/Master/texmf-dist/doc/support/ltximg/test.tex new file mode 100644 index 00000000000..32872a9ec33 --- /dev/null +++ b/Master/texmf-dist/doc/support/ltximg/test.tex @@ -0,0 +1,47 @@ +\documentclass{article} +\usepackage[cmyk]{xcolor} +\usepackage{tikz} +\usepackage{pstricks-add} +\begin{document} +Text inline \verb|\begin{pspicture*} o \begin{tikzpicture} \begin{other}| + +\begin{tikzpicture} +\shadedraw [shading=ball] (0,0) circle (2cm); +\end{tikzpicture} + +\begin{verbatim} +\begin{tikzpicture} +\shadedraw [shading=ball] (0,0) circle (2cm); +\end{tikzpicture} +\end{verbatim} + +\begin{pspicture}(-0.5,-0.5)(5,3.5) +\psset{unit=1.0cm,algebraic=true,dimen=middle,linewidth=0.8pt} +\pscustom[linewidth=0.7pt,linecolor=red,fillcolor=red,fillstyle=solid,opacity=0.25]{ +\parametricplot{-2.39}{-1.14}{0.52*cos(t)+3.25|0.52*sin(t)+3} +\lineto(3.25,3)\closepath} +\pspolygon[linewidth=0.7pt,linecolor=cyan,fillcolor=green,fillstyle=solid,opacity=0.25](0.25,0.25)(3.25,3)(4.5,0.25) +\begin{scriptsize} +\uput[d](0.25,0.25){\red{$A$}} +\uput[u](3.25,3){\red{$B$}} +\uput[d](4.5,0.25){\red{$C$}} +\uput{7pt}[-100](3.25,3){\red{$\alpha$}} +\end{scriptsize} +\end{pspicture} + +\begin{verbatim} +\begin{pspicture}(-0.5,-0.5)(5,3.5) +\psset{unit=1.0cm,algebraic=true,dimen=middle,linewidth=0.8pt} +\pscustom[linewidth=0.7pt,linecolor=red,fillcolor=red,fillstyle=solid,opacity=0.25]{ +\parametricplot{-2.39}{-1.14}{0.52*cos(t)+3.25|0.52*sin(t)+3} +\lineto(3.25,3)\closepath} +\pspolygon[linewidth=0.7pt,linecolor=cyan,fillcolor=blue,fillstyle=solid,opacity=0.25](0.25,0.25)(3.25,3)(4.5,0.25) +\begin{scriptsize} +\uput[d](0.25,0.25){\red{$A$}} +\uput[u](3.25,3){\red{$B$}} +\uput[d](4.5,0.25){\red{$C$}} +\uput{7pt}[-100](3.25,3){\red{$\alpha$}} +\end{scriptsize} +\end{pspicture} +\end{verbatim} +\end{document} diff --git a/Master/texmf-dist/scripts/ltximg/ltximg.pl b/Master/texmf-dist/scripts/ltximg/ltximg.pl new file mode 100755 index 00000000000..ccb7f92fe2d --- /dev/null +++ b/Master/texmf-dist/scripts/ltximg/ltximg.pl @@ -0,0 +1,516 @@ +#!/usr/bin/perl +use v5.14; +use strict; # to be sure, that all is safe ... :-) +use File::Path; +use File::Copy; +use File::Basename; +use IO::File; +use Getopt::Long; +use autodie; + +my $tempDir = "."; # temporary directory +my $clear = 0; # 0 or 1, clears all temporary files +my $DPI = "300"; # value for ppm +my $margins = "0"; # margins for pdf crop +my $imageDir = "images"; # directorio de imágenes (images por defecto) +my $skip = "skip"; # skip environment +my $latex = 0; # 1->create all images using latex +my $xetex = 0; # 1->create all images using xelatex +my $luatex = 0; # 1->create all images using lualatex +my $IMO = ""; # 1->Options for ImageMagick +my $GSCMD = "gs"; # Ghostscript name +my $other = "other"; # search other environment for export +my $pdf = 0; # 1->create .pdf using ghostscript +my $png = 0; # 1->create .png +my $jpg = 0; # 1->create .jpg +my $eps = 0; # 1->create .eps using pdftops +my $ppm = 0; # 1->create .ppm using pdftoppm +my $useppm = 0; # 1->create jpg/png using mogrify and ppm +my $usemog = 0; # 1->create jpg/png using mogrify +my $all = 0; # 1->create all images and files for type + +#----------------------- User part end --------------------------- +#-----------------program identification, options and help-------- +my $program = "ltximg"; +my $ident = '$Id: ltximg v1.0, 2013-03-12 pablo $'; +my $copyright = <<END_COPYRIGHT ; +Copyright 2013-01-12 (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 file.tex [options] +ltximg create a copy for TeX source whit all TiKZ|Pstricks environments + and convert all environments into single images (pdf/png/eps/jpg). + By default search and extract TiKZ environments using (pdf)LaTeX + and ghostscript (gs). + +Options: + + --h|help - display this help and exit + --v|version - display version information and exit + --li|license - display license information and exit + --imageDir= - the dir for the created images (default images) + --d|DPI= - dots per inch for gs, pdftoppm and mogrify (default 300) + --IMO="..." - aditional options for mogrify (need double quotes) + --c|clear - delete all temp files + --xe|xetex - create all image using xelatex (tikz and pstricks) + --lu|luatex - create all image using lualatex (tikz) + --la|latex - create all image using latex (pstricks) + --up|useppm - create jpg and png using mogrify and ppm + --um|usemog - create jpg and png (transparent) using mogrify and pdf + --m|margins= - margins for pdfcrop (default 0) + --pdf - create .pdf files using gs + --ppm - create .ppm files (need pdftoppm) + --eps - create .eps files (need pdftops) + --jpg - create .jpg files (deafult use gs) + --png - create .png files (deafult use gs) + --s|skip= - name for skip environmet in input file (default skip) + --o|other= - name for other export environmet (default other) + --a|all - create pdf/jpg/png/eps image type + +Example: +* $program test.tex --xe -eps -jpg -c +* produce test-fig-1.pdf, test-fig-2.pdf, test-fig-3.pdf,... +* and test-fig-1.eps, test-fig-2.eps, test-fig-3.eps,... and +* test-fig-1.jpg, test-fig-2.jpg, test-fig-3.jpg,... for all +* TiKZ|Pst environments in image dir using gs and (Xe)latex. +END_OF_USAGE + +# Options +my $result = GetOptions ("imageDir=s" => \$imageDir, + "s|skip=s" => \$skip, + 'h|help' => \$::opt_help, + 'v|version' => \$::opt_version, + 'li|license' => \$::opt_license, + 'd|DPI=i' => \$DPI, + "tempDir=s" => \$tempDir, + 'c|clear' => \$clear, + "la|latex" => \$latex, + "xe|xetex" => \$xetex, + "lu|luatex" => \$luatex, + "o|other=s" => \$other, + "m|margins=s" => \$margins, + "GSCMD=s" => \$GSCMD, + "IMO=s" => \$IMO, + "png" => \$png, + "jpg" => \$jpg, + "eps" => \$eps, + "ppm" => \$ppm, + "up|useppm" => \$useppm, + "um|usemog" => \$usemog, + "pdf" => \$pdf, + "a|all" => \$all + ) 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); +} +# General options +if ($latex) { + $latex = 1; +} +if ($xetex) { + $xetex = 1; +} +if ($luatex) { + $luatex = 1; +} +if ($pdf) { + $pdf = 1; +} +if ($eps) { + $pdf =$eps = 1; +} +if ($jpg) { + $jpg = 1; +} +if ($png) { + $png = 1; +} +if ($ppm) { + $ppm = 1; +} +if ($^O eq 'MSWin32'){ + $GSCMD = "gswin32c"; +} +if ($^O eq 'MSWin64'){ + $GSCMD = "gswin64c"; +} +if ($useppm){ + $ppm = $useppm = 1; +} +if ($usemog){ + $pdf = $usemog = 1; +} +if ($all){ + $pdf =$eps = $png = $jpg = 1; +} +## Create image dir +if (! -e $imageDir) { + mkdir($imageDir,0744) or die "Can't create $imageDir"; +} + +# 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"; + +# Define in file +my $archivo_entrada = shift; + +# Read in file +open my $ENTRADA, '<', $archivo_entrada; +my $archivo; +{ + local $/; + $archivo = <$ENTRADA>; +} +close $ENTRADA; +## cambiar +$archivo =~ +s/(?<inicio>\\begin\{)(?<verb>verbatim|verbatim\*|lstlisting|LTXexample|Verbatim|comment|alltt|minted|tcblisting|xcomment|$skip) (?:\}) +/\\begin\{nopreview} +$+{inicio}$+{verb}\}/gmxs; + +$archivo =~ +s/(?<fin>\\end\{)(?<verb>verbatim|verbatim\*|lstlisting|LTXexample|Verbatim|comment|alltt|minted|tcblisting|xcomment|$skip) (?:\}) +/$+{fin}$+{verb}\} +\\end\{nopreview}/gmxs; +# Save +open my $SALIDA, '>', "$tempDir/$name-tmp.tex"; +print $SALIDA $archivo; +close $SALIDA; + +# Add preview in preamble + +open my $INFILE,'<', "$tempDir/$name-tmp.tex"; +open my $OUTFIlE,'>',"$tempDir/$name-fig.tex"; +print $OUTFIlE "\\AtBeginDocument\{\n"; + if($xetex){ + print $OUTFIlE "\\RequirePackage\[xetex,active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{tikzpicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{pspicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + elsif($latex){ + print $OUTFIlE "\\RequirePackage\[active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{pspicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + else { + print $OUTFIlE "\\RequirePackage\[pdftex,active,tightpage\]\{preview\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{tikzpicture\}\n"; + print $OUTFIlE "\\PreviewEnvironment\{$other\}\}\n"; + } + + while ( my $line = <$INFILE> ) { + print $OUTFIlE $line; + } +close $INFILE; +close $OUTFIlE; + +if ($clear) {unlink "$tempDir/$name-tmp.tex";} + +# Parser inline verbatim + +## Lectura del archivo +open my $PARSER, '<', "$tempDir/$name-fig.tex"; +undef $/; # read al file +my $file_PARSER = <$PARSER>; +close $PARSER; + +## Partición del documento +my($cabeza,$cuerpo,$final) = $file_PARSER =~ m/\A (.+? ^\\begin{document}) \s* (.+?) \s* (^ \\end{document}) \s* \z/msx; + +## Cambios a realizar +my %cambios = ( + '\pspicture' => '\TRICKS', + '\endpspicture' => '\ENDTRICKS', + + '\begin{pspicture' => '\begin{TRICKS', + '\end{pspicture' => '\end{TRICKS', + + '\begin{postscript}' => '\begin{POSTRICKS}', + '\end{postscript}' => '\end{POSTRICKS}', + + '\begin{tikzpicture' => '\begin{TIKZPICTURE', + '\end{tikzpicture' => '\end{TIKZPICTURE', + + "\\begin\{$other" => '\begin{OTHER', + "\\end\{$other" => '\end{OTHER', +); + + +## Variables y constantes +my $no_del = "\0"; +my $del = $no_del; + +## Reglas +my $llaves = qr/\{ .+? \} /x; +my $no_corchete = qr/(?:\[ .+? \])? /x; +my $delimitador = qr/\{ (?<del>.+?) \} /x; +my $verb = qr/verb [*]? /ix; +my $lst = qr/lstinline (?!\*) $no_corchete /ix; +my $mint = qr/mint (?!\*) $no_corchete $llaves /ix; +my $marca = qr/\\ (?:$verb | $lst | $mint) (\S) .+? \g{-1} /x; +my $comentario = qr/^ \s* \%+ .+? $ /mx; +my $definedel = qr/\\ (?: DefineShortVerb | lstMakeShortInline ) $no_corchete $delimitador /ix; +my $indefinedel = qr/\\ (?: UndefineShortVerb | lstDeleteShortInline) $llaves /ix; + + +# Changes + +while ($cuerpo =~ + / $marca + | $comentario + | $definedel + | $indefinedel + | $del .+? $del # delimitado + /gimx) { + + my($pos_inicial, $pos_final) = ($-[0], $+[0]); # posiciones + my $encontrado = ${^MATCH}; # lo encontrado + + given ($encontrado) { + when (/$definedel/) { # definimos delimitador + $del = $+{del}; + $del = "\Q$+{del}" if substr($del,0,1) ne '\\'; # es necesario "escapar" el delimitador + } + when (/$indefinedel/) { # indefinimos delimitador + $del = $no_del; + } + default { # Aquí se hacen los cambios + while (my($busco, $cambio) = each %cambios) { + + $encontrado =~ s/\Q$busco\E/$cambio/g; # es necesario escapar $busco, ya que contiene caracteres extraños + } + + substr $cuerpo, $pos_inicial, $pos_final-$pos_inicial, $encontrado; # insertamos los nuevos cambios + + pos($cuerpo)= $pos_inicial + length $encontrado; # reposicionamos la siguiente búsqueda + } + } +} + +# Write + +open my $OUTPARSER, '>', "$tempDir/$name-fig.tex"; +print $OUTPARSER "$cabeza\n$cuerpo\n$final\n"; +close $OUTPARSER; + +# Compiling files... + +# Using LaTeX + +if($latex){ + print "Compiled using LaTeX\n"; + system("latex -interaction=batchmode $tempDir/$name-fig.tex"); + system("dvips -q -Ppdf $tempDir/$name-fig.dvi"); + system("ps2pdf -dPDFSETTINGS=\/prepress $tempDir/$name-fig.ps $tempDir/$name-fig.pdf"); +if ($clear) { + unlink "$tempDir/$name-fig.dvi"; + unlink "$tempDir/$name-fig.ps"; + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using XeLaTeX + +elsif($xetex){ + print "Compiled using (Xe)LaTeX\n"; + system("xelatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using LuaLaTeX + +elsif($luatex){ + print "Compiled using (lua)LaTeX\n"; + system("lualatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Using pdfLaTeX (default) + +else{ + print "Compiled using (pdf)LaTeX\n"; + system("pdflatex -interaction=batchmode $tempDir/$name-fig.tex"); +if ($clear) { + unlink "$tempDir/$name-fig.log"; + unlink "$tempDir/$name-fig.aux"; + unlink "$tempDir/$name-fig.tex"; + } + } + +# Croping + +print "Done, $name-fig.pdf need croping, using pdfcrop whit margin $margins\n"; +system("pdfcrop --margins $margins $tempDir/$name-fig.pdf $tempDir/$name-fig.pdf"); + +# Gs for split file + +if ($pdf) { +print "Create pdf figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=pdfwrite -dPDFSETTINGS=\/prepress -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.pdf $tempDir/$name-fig.pdf"); + +# Delete last pdf (bug from gs) + +my $i = 1; +while (-e "$imageDir/$name-fig-${i}.pdf") { # if exisit search + $i++; # next +} # search end + +$i--; # back the last + +unlink "$imageDir/$name-fig-${i}.pdf"; + +} + +# Fix pdftops error message in windows + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ +open my $ppmconf, '>', "$tempDir/xpd"; +print $ppmconf <<'EOH'; +errQuiet yes +EOH +close $ppmconf; + } + +# Create eps files using pdftops + +if ($eps) { +print "Create eps figs in $imageDir dir using pdftops\n"; +# Search pdf in $imageDir + for my $image_pdf (<$imageDir/*.pdf>) { + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftops -cfg $tempDir/xpd -q -level3 -eps $image_pdf"); + } +else{ + system("pdftops -level3 -eps $image_pdf"); + } + } + } + +# Create ppm files and renamig files + +if($ppm){ +print "Create ppm figs in $imageDir dir using pdftoppm\n"; +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftoppm -cfg $tempDir/xpd -q -r $DPI $tempDir/$name-fig.pdf $imageDir/$name-fig"); + } +else{ + system("pdftoppm -r $DPI $tempDir/$name-fig.pdf $imageDir/$name-fig"); + } + +# Renaming .ppm (only need in windows) + +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ +my $dren = "$tempDir/$imageDir"; +my $fichero = ''; +my $ppmren = ''; +my $renNo = 1; +if(opendir(DIR,$dren)){ +foreach (readdir DIR){ + $fichero = $_; + if ( $fichero =~ /($name-fig-)(\d+|\d+[-]\d+).ppm/) { + my $renNo = int($2); + my $newname="$1$renNo.ppm"; + $ppmren = rename("$dren/$fichero","$dren/$newname"); + } + } + } +closedir DIR; + } + } + +# Change dir and create png/jpg formats using mogrify and ppm + +if($usemog){ +chdir ($imageDir) or die "$imageDir not exist\n"; +if ($png) { +print "Create png transparent in $imageDir dir using mogrify and pdf\n"; +system("mogrify $IMO -define png:format=png32 -define png:compression-filter=4 -quality 100 -transparent white -density $DPI -format png \*\.pdf"); + } +if ($jpg) { +print "Create jpg figs in $imageDir dir using mogrify and pdf\n"; +system("mogrify $IMO -quality 100 -density $DPI -format jpg \*\.pdf"); + } +} +elsif($useppm){ +chdir ($imageDir) or die "$imageDir not exist\n"; +if ($png) { +print "Create png figs in $imageDir dir using mogrify and ppm\n"; +system("mogrify $IMO -quality 100 -define png:format=png32 -define png:compression-filter=4 -density $DPI -format png \*\.ppm"); + } +if ($jpg) { +print "Create jpg figs in $imageDir dir using mogrify and ppm\n"; +system("mogrify $IMO -quality 100 -density $DPI -format jpg \*\.ppm"); + } +} +else{ + +# Create png using gs (default) + +if ($png) { +print "Create png figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=png16m -r$DPI -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.png $tempDir/$name-fig.pdf"); + } + +if ($jpg) { +print "Create jpg figs in $imageDir dir using Ghostscript \($GSCMD\)\n"; +system("$GSCMD -q -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -dBATCH -sOutputFile=$imageDir/$name-fig-%d.jpg $tempDir/$name-fig.pdf"); + } + } + + +print "Finish, all figures are in $imageDir dir\n"; + +__END__ diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 523b95f37e7..499fdf22a23 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -285,7 +285,7 @@ my @TLP_working = qw( lshort-polish lshort-portuguese lshort-russian lshort-slovak lshort-slovenian lshort-spanish lshort-thai lshort-turkish lshort-ukr lshort-vietnamese lstaddons ltablex ltabptch - ltxdockit ltxfileinfo ltxindex ltxkeys ltxmisc ltxnew ltxtools + ltxdockit ltxfileinfo ltximg ltxindex ltxkeys ltxmisc ltxnew ltxtools lua-alt-getopt lua-check-hyphen lua-visual-debug lua2dox luabibentry luabidi luacode luaindex luainputenc luaintro lualatex-doc lualatex-doc-de diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index ea7354afc7d..3b3ddf2c81a 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2448,6 +2448,7 @@ $standardxmt='\.xmt'; 'listbib' => 'listbib$', 'listings-ext' => '\.sh$', 'ltxfileinfo' => 'ltxfileinfo$', + 'ltximg' => 'ltximg\.pl$', 'lua2dox' => 'lua2dox_filter?$', 'luaotfload' => 'luaotfload-tool', # doscripts() does mklua*db 'match_parens' => '^match_parens$', diff --git a/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc index f14dad6385d..6ce7c0e82ad 100644 --- a/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc @@ -43,6 +43,7 @@ depend latexmk depend latexpand depend latexindent depend ltxfileinfo +depend ltximg depend listings-ext depend match_parens depend mkjobtexmf diff --git a/Master/tlpkg/tlpsrc/ltximg.tlpsrc b/Master/tlpkg/tlpsrc/ltximg.tlpsrc new file mode 100644 index 00000000000..dca338c719c --- /dev/null +++ b/Master/tlpkg/tlpsrc/ltximg.tlpsrc @@ -0,0 +1 @@ +binpattern f bin/${ARCH}/${PKGNAME} |