summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-07-13 21:39:16 +0000
committerKarl Berry <karl@freefriends.org>2019-07-13 21:39:16 +0000
commitac24b25f17ff492d41266a15f5c9aa894ffd74d7 (patch)
treecac6f3e8375f7fe4458c04e8141cc8ae9f20d1b9
parent1776a53c2baec4adbb7c7b4eeff63bbbffd7608e (diff)
ltximg (13jul19)
git-svn-id: svn://tug.org/texlive/trunk@51633 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/ltximg/ltximg.pl1341
-rw-r--r--Master/texmf-dist/doc/support/ltximg/CHANGUES.md25
-rw-r--r--Master/texmf-dist/doc/support/ltximg/README.md30
-rw-r--r--Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdfbin190044 -> 147447 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/ltximg/ltximg.pl1341
-rw-r--r--Master/texmf-dist/source/support/ltximg/ltximg-doc.dtx1076
6 files changed, 1915 insertions, 1898 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl b/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl
index 738ccb51cc0..676c96fa72e 100755
--- a/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl
+++ b/Build/source/texk/texlive/linked_scripts/ltximg/ltximg.pl
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
-use v5.22; # minimum version
+use v5.24;
use File::Basename;
use Getopt::Long qw(:config bundling_values require_order no_ignore_case);
use File::Temp qw(tempdir);
@@ -7,58 +7,62 @@ use File::Copy;
use Config;
use File::Spec::Functions qw(catfile devnull);
use File::Find;
+use IO::Compress::Zip qw(:all);
+use Archive::Tar;
+use POSIX qw(strftime);
use Cwd;
use autodie;
-#use Data::Dumper; # for test
+#use Data::Dumper;
-### Directory for work and tmp files
-my $tempDir = tempdir( CLEANUP => 1);
-my $tempSys = dirname($tempDir);
-my $workdir = cwd;
-my $null = devnull();
+### Directory for work and temp files
+my $tempDir = tempdir( CLEANUP => 1);
+my $workdir = cwd;
+my $null = devnull();
### Program identification
my $program = "LTXimg";
-my $nv='v1.5';
+my $nv = 'v1.6';
my $copyright = <<END_COPYRIGHT ;
-[2018-04-12] (c) 2013-2018 by Pablo Gonzalez, pablgonz<at>yahoo.com
+[2019-07-13] (c) 2013-2019 by Pablo Gonzalez, pablgonz<at>yahoo.com
END_COPYRIGHT
### Default values
-my $prefix = 'fig'; # defaul prefix for extract files
-my $skiptag = 'noltximg'; # internal tag for regex
-my $extrtag = 'ltximg'; # internal tag for regex
-my $imageDir = "images"; # dir for images
-my $verbcmd = "myverb"; # set \myverb command
-my $margins = "0"; # margins for pdfcrop
-my $DPI = "150"; # dpi for image formats
-my $arara = 0; # use arara to compiler
-my $force = 0; # force capture \psset|\tikzset
-my $latex = 0; # compiling all images using latex
-my $dvips = 0; # compiling output using dvips>ps2pdf
-my $dvipdf = 0; # compiling all images using dvipdfmx
-my $xetex = 0; # compiling all images using xelatex
-my $luatex = 0; # compiling all images using lualatex
-my $noprew = 0; # don't use preview packpage
-my $srcenv = 0; # create src code for environments
-my $subenv = 0; # create sub document for environments
-my @extr_env_tmp; # save extract environments
-my @skip_env_tmp; # save skip some environments
-my @verb_env_tmp; # save verbatim environments
-my @verw_env_tmp; # save verbatim write environments
-my @delt_env_tmp; # save delete environments in output file
-my @clean; # clean options
-my $pdf = 1; # create a PDF image file
-my $run = 1; # run mode compiler
-my $crop = 1; # croped pdf image files
-my $gray = 0; # create a gray scale images
-my $output; # set output name for outfile
-my $outfile = 0; # write output file
-my $outsrc = 0; # enable write src env files
-my $debug = 0; # debug
-my $PSTexa = 0; # extract PSTexample environment
-my $STDenv = 0; # extract standart environments
-my $verbose = 0; # verbose
+my $prefix = 'fig'; # defaul prefix for extract files
+my $skiptag = 'noltximg'; # internal tag for regex
+my $extrtag = 'ltximg'; # internal tag for regex
+my $imageDir = "images"; # dir for images
+my $verbcmd = "myverb"; # set \myverb command
+my $margins = "0"; # margins for pdfcrop
+my $DPI = "150"; # dpi for image formats
+my $zip = 0; # zip images dir
+my $tar = 0; # tar.gz images dir
+my $arara = 0; # use arara to compiler
+my $force = 0; # force capture \psset|\tikzset
+my $latex = 0; # compiling all images using latex
+my $dvips = 0; # compiling output using dvips>ps2pdf
+my $dvipdf = 0; # compiling all images using dvipdfmx
+my $xetex = 0; # compiling all images using xelatex
+my $luatex = 0; # compiling all images using lualatex
+my $noprew = 0; # don't use preview packpage
+my $srcenv = 0; # create src code for environments
+my $subenv = 0; # create sub document for environments
+my @extr_env_tmp; # save extract environments
+my @skip_env_tmp; # save skip some environments
+my @verb_env_tmp; # save verbatim environments
+my @verw_env_tmp; # save verbatim write environments
+my @delt_env_tmp; # save delete environments in output file
+my @clean; # clean options
+my $pdf = 1; # create a PDF image file
+my $run = 1; # run mode compiler
+my $crop = 1; # croped pdf image files
+my $gray = 0; # create a gray scale images
+my $output; # set output name for outfile
+my $outfile = 0; # write output file
+my $outsrc = 0; # enable write src env files
+my $debug = 0; # debug
+my $PSTexa = 0; # extract PSTexample environment
+my $STDenv = 0; # extract standart environments
+my $verbose = 0; # verbose
### Search Ghostscript
# The next code it's part of pdfcrop adapted from TexLive 2014
@@ -241,9 +245,7 @@ sub SearchRegistry () {
} # end GS search
### If windows
-if ($Win and $gscmd =~ /\s/) {
- $gscmd = "\"$gscmd\"";
-}
+if ($Win and $gscmd =~ /\s/) { $gscmd = "\"$gscmd\"";}
### Call GS
find_ghostscript();
@@ -283,8 +285,8 @@ ${title}** Description **
If used without [<compiler>] and [<options>] the extracted environments
are converted to pdf image format and saved in the "/images" directory
using "pdflatex" and "preview" package. Relative or absolute paths for
- directories and files is not supported, if the last option take a list
- separated by commas you need -- at the end.
+ directories and files is not supported. If the last option take a list
+ separated by commas, you need -- at the end.
** Default environments extract **
pspicture tikzpicture pgfpicture psgraph postscript PSTexample
@@ -309,6 +311,8 @@ ${title}** Description **
-m <integer>, --margin <integer>
Set margins for pdfcrop [0]
--imgdir <dirname> Set name of directory to save images [images]
+--zip Compress files generated in .zip format [off]
+--tar Compress files generated in .tar.gz format [off]
-o <filename>, --output <filename>
Create output file [off]
--verbose Verbose printing [off]
@@ -354,7 +358,7 @@ END_OF_USAGE
### Error in command line
sub errorUsage { die "@_ (try ltximg --help for more information)\n"; }
-### Getopt::Long configuration
+### Getopt::Long configuration for command line
my %opts_cmd;
my $result=GetOptions (
@@ -384,6 +388,8 @@ my $result=GetOptions (
'luatex' => \$luatex, # lualatex compiler
'dvips' => \$dvips, # dvips compiler
'dvipdf' => \$dvipdf, # dvipdfmx compiler
+ 'zip' => \$zip, # zip images dir
+ 'tar' => \$tar, # tar images dir
# string options from command line
'extrenv=s{1,9}' => \@extr_env_tmp, # extract environments
'skipenv=s{1,9}' => \@skip_env_tmp, # skip environment
@@ -418,37 +424,37 @@ s/^\s*(\=):?|\s*//mg foreach @delt_env_tmp;
@delt_env_tmp = split(/,/,join('',@delt_env_tmp));
### Validate input string options
-if ( grep( /(^\-|^\.).*?/, @extr_env_tmp ) ) {
- die errorUsage "Invalid option for --extrenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @extr_env_tmp )) {
+ die errorUsage "Invalid argument for --extrenv option";
}
-if ( grep( /(^\-|^\.).*?/, @skip_env_tmp ) ) {
- die errorUsage "Invalid option for --skipenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @skip_env_tmp )) {
+ die errorUsage "Invalid argument for --skipenv option";
}
-if ( grep( /(^\-|^\.).*?/, @verb_env_tmp ) ) {
- die errorUsage "Invalid option for --verbenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @verb_env_tmp )) {
+ die errorUsage "Invalid argument for --verbenv option";
}
-if ( grep( /(^\-|^\.).*?/, @verw_env_tmp ) ) {
- die errorUsage "Invalid option for --verwenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @verw_env_tmp )) {
+ die errorUsage "Invalid argument for --writenv option";
}
-if ( grep( /(^\-|^\.).*?/, @delt_env_tmp ) ) {
- die errorUsage "Invalid option for --deltenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @delt_env_tmp )) {
+ die errorUsage "Invalid argument for --deltenv option";
}
### Help
-if (defined $opts_cmd{help}){
+if (defined $opts_cmd{help}) {
find_ghostscript();
print $usage;
exit(0);
}
### Version
-if (defined $opts_cmd{version}){
+if (defined $opts_cmd{version}) {
print $title;
exit(0);
}
### Licence
-if (defined $opts_cmd{license}){
+if (defined $opts_cmd{license}) {
print $licensetxt;
exit(0);
}
@@ -458,7 +464,7 @@ my $tmp = "$$";
### Check --srcenv and --subenv option from command line
if ($srcenv && $subenv) {
- die errorUsage "--srcenv and --subenv options are mutually exclusive";
+ die errorUsage "--srcenv and --subenv options are mutually exclusive";
}
### Check the input file from command line
@@ -472,10 +478,10 @@ $ext = '.tex' if not $ext;
### Read input file in memory (slurp), need :crlf for windows/linux
open my $INPUTfile, '<:crlf', "$name$ext";
-my $archivo;
+my $ltxfile;
{
local $/;
- $archivo = <$INPUTfile>;
+ $ltxfile = <$INPUTfile>;
}
close $INPUTfile;
@@ -492,134 +498,134 @@ sub array_minus(\@\@) {
}
### Funtion to create hash begin -> BEGIN, end -> END
-sub crearhash{
+sub crearhash {
my %cambios;
for my $aentra(@_){
- for my $initend (qw(begin end)) {
- $cambios{"\\$initend\{$aentra"} = "\\\U$initend\E\{$aentra";
+ for my $initend (qw(begin end)) {
+ $cambios{"\\$initend\{$aentra"} = "\\\U$initend\E\{$aentra";
}
}
return %cambios;
}
### Default environment to extract
-my @extr_tmp = qw (
- postscript tikzpicture pgfpicture pspicture psgraph
- );
+my @extr_tmp = qw (
+ postscript tikzpicture pgfpicture pspicture psgraph
+ );
-push(@extr_env_tmp,@extr_tmp);
+push (@extr_env_tmp, @extr_tmp);
### Default verbatim environment
-my @verb_tmp = qw (
- Example CenterExample SideBySideExample PCenterExample PSideBySideExample
- verbatim Verbatim BVerbatim LVerbatim SaveVerbatim PSTcode
- LTXexample tcblisting spverbatim minted listing lstlisting
- alltt comment chklisting verbatimtab listingcont boxedverbatim
- demo sourcecode xcomment pygmented pyglist program programl
- programL programs programf programsc programt
- );
+my @verb_tmp = qw (
+ Example CenterExample SideBySideExample PCenterExample PSideBySideExample
+ verbatim Verbatim BVerbatim LVerbatim SaveVerbatim PSTcode
+ LTXexample tcblisting spverbatim minted listing lstlisting
+ alltt comment chklisting verbatimtab listingcont boxedverbatim
+ demo sourcecode xcomment pygmented pyglist program programl
+ programL programs programf programsc programt
+ );
-push(@verb_env_tmp,@verb_tmp);
+push (@verb_env_tmp, @verb_tmp);
### Default verbatim write environment
my @verbw_tmp = qw (
- filecontents tcboutputlisting tcbexternal extcolorbox extikzpicture
- VerbatimOut verbatimwrite PSTexample filecontentsdef filecontentshere
- );
+ filecontents tcboutputlisting tcbexternal tcbwritetmp extcolorbox extikzpicture
+ VerbatimOut verbatimwrite PSTexample filecontentsdef filecontentshere
+ );
-push(@verw_env_tmp,@verbw_tmp);
+push (@verw_env_tmp, @verbw_tmp);
### Rules to capture in regex
-my $braces = qr/ (?:\{)(.+?)(?:\}) /msx;
-my $braquet = qr/ (?:\[)(.+?)(?:\]) /msx;
-my $no_corchete = qr/ (?:\[ .+? \])? /msx;
+my $braces = qr/ (?:\{)(.+?)(?:\}) /msx;
+my $braquet = qr/ (?:\[)(.+?)(?:\]) /msx;
+my $no_corchete = qr/ (?:\[ .*? \])? /msx;
### Capture new verbatim environments defined in input file
my @new_verb = qw (
- newtcblisting DeclareTCBListing ProvideTCBListing NewTCBListing
- lstnewenvironment NewListingEnvironment NewProgram specialcomment
- includecomment DefineVerbatimEnvironment newverbatim newtabverbatim
- );
+ newtcblisting DeclareTCBListing ProvideTCBListing NewTCBListing
+ lstnewenvironment NewListingEnvironment NewProgram specialcomment
+ includecomment DefineVerbatimEnvironment newverbatim newtabverbatim
+ );
### Regex to capture names for new verbatim environments from input file
my $newverbenv = join "|", map quotemeta, sort { length $a <=> length $b } @new_verb;
-$newverbenv = qr/\b(?:$newverbenv) $no_corchete $braces/msx;
+ $newverbenv = qr/\b(?:$newverbenv) $no_corchete $braces/msx;
### Capture new verbatim write environments defined in input file
my @new_verb_write = qw (
- renewtcbexternalizetcolorbox renewtcbexternalizeenvironment
- newtcbexternalizeenvironment newtcbexternalizetcolorbox
- );
+ renewtcbexternalizetcolorbox renewtcbexternalizeenvironment
+ newtcbexternalizeenvironment newtcbexternalizetcolorbox
+ );
### Regex to capture names for new verbatim write environments from input file
my $newverbwrt = join "|", map quotemeta, sort { length $a <=> length $b } @new_verb_write;
-$newverbwrt = qr/\b(?:$newverbwrt) $no_corchete $braces/msx;
+ $newverbwrt = qr/\b(?:$newverbwrt) $no_corchete $braces/msx;
### Regex to capture MINTED related environments
-my $mintdenv = qr/\\ newminted $braces (?:\{.+?\}) /x;
-my $mintcenv = qr/\\ newminted $braquet (?:\{.+?\}) /x;
-my $mintdshrt = qr/\\ newmint $braces (?:\{.+?\}) /x;
-my $mintcshrt = qr/\\ newmint $braquet (?:\{.+?\}) /x;
-my $mintdline = qr/\\ newmintinline $braces (?:\{.+?\}) /x;
-my $mintcline = qr/\\ newmintinline $braquet (?:\{.+?\}) /x;
+my $mintdenv = qr/\\ newminted $braces (?:\{.+?\}) /x;
+my $mintcenv = qr/\\ newminted $braquet (?:\{.+?\}) /x;
+my $mintdshrt = qr/\\ newmint $braces (?:\{.+?\}) /x;
+my $mintcshrt = qr/\\ newmint $braquet (?:\{.+?\}) /x;
+my $mintdline = qr/\\ newmintinline $braces (?:\{.+?\}) /x;
+my $mintcline = qr/\\ newmintinline $braquet (?:\{.+?\}) /x;
### Pass input file to @array and remove % and comments
-my @verbinput = $archivo;
-s/%.*\n//mg foreach @verbinput; # del comments
-s/^\s*|\s*//mg foreach @verbinput; # del white space
-my $verbinput = join '', @verbinput;
+my @filecheck = $ltxfile;
+s/%.*\n//mg foreach @filecheck; # del comments
+s/^\s*|\s*//mg foreach @filecheck; # del white space
+my $filecheck = join '', @filecheck;
### Capture \newverbatim write names in input file
-my @newv_write = $verbinput =~ m/$newverbwrt/xg;
+my @newv_write = $filecheck =~ m/$newverbwrt/xg;
### Add @newv_write defined in input file to @verw_env_tmp
-push(@verw_env_tmp,@newv_write);
+push (@verw_env_tmp, @newv_write);
### Capture \newminted{$mintdenv}{options} (for)
-my @mint_denv = $verbinput =~ m/$mintdenv/xg;
+my @mint_denv = $filecheck =~ m/$mintdenv/xg;
### Capture \newminted[$mintcenv]{lang} (for)
-my @mint_cenv = $verbinput =~ m/$mintcenv/xg;
+my @mint_cenv = $filecheck =~ m/$mintcenv/xg;
### Capture \newmint{$mintdshrt}{options} (while)
-my @mint_dshrt = $verbinput =~ m/$mintdshrt/xg;
+my @mint_dshrt = $filecheck =~ m/$mintdshrt/xg;
### Capture \newmint[$mintcshrt]{lang}{options} (while)
-my @mint_cshrt = $verbinput =~ m/$mintcshrt/xg;
+my @mint_cshrt = $filecheck =~ m/$mintcshrt/xg;
### Capture \newmintinline{$mintdline}{options} (while)
-my @mint_dline = $verbinput =~ m/$mintdline/xg;
+my @mint_dline = $filecheck =~ m/$mintdline/xg;
### Capture \newmintinline[$mintcline]{lang}{options} (while)
-my @mint_cline = $verbinput =~ m/$mintcline/xg;
+my @mint_cline = $filecheck =~ m/$mintcline/xg;
### Capture \newverbatim environments in input file (for)
-my @verb_input = $verbinput =~ m/$newverbenv/xg;
+my @verb_input = $filecheck =~ m/$newverbenv/xg;
### Add new verbatim environment defined in input file to @vrbenv
-push(@verb_env_tmp,@mint_denv,@mint_cenv,@verb_input);
+push (@verb_env_tmp,@mint_denv,@mint_cenv,@verb_input);
### Append "code" (minted)
-if (!@mint_denv == 0){
-$mintdenv = join "\n", map { qq/$_\Qcode\E/ } @mint_denv;
-@mint_denv = split /\n/, $mintdenv;
+if (!@mint_denv == 0) {
+ $mintdenv = join "\n", map { qq/$_\Qcode\E/ } @mint_denv;
+ @mint_denv = split /\n/, $mintdenv;
}
### Append "inline" (minted)
-if (!@mint_dline == 0){
-$mintdline = join "\n", map { qq/$_\Qinline\E/ } @mint_dline;
-@mint_dline = split /\n/, $mintdline;
+if (!@mint_dline == 0) {
+ $mintdline = join "\n", map { qq/$_\Qinline\E/ } @mint_dline;
+ @mint_dline = split /\n/, $mintdline;
}
### Join all minted inline/short and lstinline in @array
my @mintline;
-my @mint_tmp = qw ( mint mintinline lstinline);
-push(@mintline,@mint_dline,@mint_cline,@mint_dshrt,@mint_cshrt,@mint_tmp);
-@mintline = uniq(@mintline);
+my @mint_tmp = qw ( mint mintinline lstinline);
+push (@mintline,@mint_dline,@mint_cline,@mint_dshrt,@mint_cshrt,@mint_tmp);
+ @mintline = uniq(@mintline);
### Create a regex using @mintline
my $mintline = join "|", map quotemeta, sort { length $a <=> length $b } @mintline;
-$mintline = qr/\b(?:$mintline)/x;
+ $mintline = qr/\b(?:$mintline)/x;
### Options from input file
# % ltximg : extrenv : {extrenv1, extrenv2, ... , extrenvn}
@@ -629,8 +635,8 @@ $mintline = qr/\b(?:$mintline)/x;
# % ltximg : deltenv : {deltenv1, deltenv2, ... , deltenvn}
# % ltximg : options : {opt1=arg, opt2=arg, ... , bolean}
-### Regex to capture before preamble
-my $rx_myscrypt = qr/
+### Regex to capture before preamble $readoptfile, %opt_from_file;
+my $readoptfile = qr/
^ %+ \s* ltximg (?&SEPARADOR) (?<clave>(?&CLAVE)) (?&SEPARADOR) \{ (?<argumentos>(?&ARGUMENTOS)) \}
(?(DEFINE)
(?<CLAVE> \w+ )
@@ -639,35 +645,33 @@ my $rx_myscrypt = qr/
)
/mx;
-### Split input file, $optin contain % ltximg : <argument>
-my($optin, $documento) = $archivo =~ m/\A (\s* .*? \s*) (\\documentclass.*)\z/msx;
+### Split input file, $atbegindoc contain % ltximg : <argument>
+my ($atbegindoc, $document) = $ltxfile =~ m/\A (\s* .*? \s*) (\\documentclass.*)\z/msx;
### Process options from input file
my %opts_file;
-while ($optin =~ /$rx_myscrypt/g) {
- my($clave, $argumentos) = @+{qw(clave argumentos)};
- my @argumentos = split /\s*,\s*?/, $argumentos;
- for (@argumentos) {
- s/^ \s* | \s* $//gx;
- }
- if ($clave eq 'options') {
- for my $argumento (@argumentos) {
- if ($argumento =~ /(?<key>\S+) \s* = \s* (?<valor>\S+)/x) {
- $opts_file{$clave}{$+{'key'}} = $+{'valor'};
- } # close for
- else {
- $opts_file{$clave}{$argumento} = 1;
- }
+while ($atbegindoc =~ /$readoptfile/g) {
+ my ($clave, $argumentos) = @+{qw(clave argumentos)};
+ my @argumentos = split /\s*,\s*?/, $argumentos;
+ for (@argumentos) { s/^ \s* | \s* $//gx; }
+ if ($clave eq 'options') {
+ for my $argumento (@argumentos) {
+ if ($argumento =~ /(?<key>\S+) \s* = \s* (?<valor>\S+)/x) {
+ $opts_file{$clave}{$+{'key'}} = $+{'valor'};
+ } # close for
+ else {
+ $opts_file{$clave}{$argumento} = 1;
+ }
} # close for
- } # close if
- else {
- push @{ $opts_file{ $clave } }, @argumentos;
- }
+ } # close if
+ else {
+ push @{ $opts_file{ $clave } }, @argumentos;
+ }
} # close while
### Validate clean
-my %clean = map { $_ => 1 } @clean;
+my %clean = map { $_ => 1 } @clean;
### By default clean = doc
$clean{doc} = 1 ;
@@ -680,50 +684,44 @@ $clean{tkz} = 1 if ($opts_file{options}{clean} eq 'tkz');
$clean{all} = 1 if ($opts_file{options}{clean} eq 'all');
### Set clean options for script
-if ($clean{pst} or $clean{tikz}) {
- $clean{doc} = 1;
-}
-if ($clean{all}) {
- @clean{qw(pst doc tkz)} = (1) x 3;
-}
-if ($clean{off}) {
- undef %clean;
-}
+if ($clean{pst} or $clean{tikz}) { $clean{doc} = 1; }
+if ($clean{all}) { @clean{qw(pst doc tkz)} = (1) x 3; }
+if ($clean{off}) { undef %clean; }
### Add extract options from input file
-if (exists $opts_file{extract} ) {
+if (exists $opts_file{extract}) {
push @extr_env_tmp, @{ $opts_file{extract} };
}
### Add skipenv options from input file
-if (exists $opts_file{skipenv} ) {
+if (exists $opts_file{skipenv}) {
push @skip_env_tmp, @{ $opts_file{skipenv} };
}
### Add verbenv options from input file
-if (exists $opts_file{verbenv} ) {
+if (exists $opts_file{verbenv}) {
push @verb_env_tmp, @{ $opts_file{verbenv} };
}
### Add writenv options from input file
-if (exists $opts_file{writenv} ) {
+if (exists $opts_file{writenv}) {
push @verw_env_tmp, @{ $opts_file{writenv} };
}
### Add deltenv options from input file
-if (exists $opts_file{deltenv} ) {
+if (exists $opts_file{deltenv}) {
push @delt_env_tmp, @{ $opts_file{deltenv} };
}
### Set \myverb|<code>| options from input file
-if (exists $opts_file{options}{verbcmd}){
+if (exists $opts_file{options}{verbcmd}) {
$verbcmd = $opts_file{options}{verbcmd};
}
### Create @env_all_tmp contain all environments
my @env_all_tmp;
push(@env_all_tmp,@extr_env_tmp,@skip_env_tmp,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
-@env_all_tmp = uniq(@env_all_tmp);
+@env_all_tmp = uniq(@env_all_tmp);
### Create @no_env_all_tmp contain all No extracted environments
my @no_env_all_tmp;
@@ -732,21 +730,21 @@ push(@no_env_all_tmp,@skip_env_tmp,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
### The operation return @extract environment
my @extract = array_minus(@env_all_tmp,@no_env_all_tmp);
-@extract = uniq(@extract);
+ @extract = uniq(@extract);
### The operation return @no_extract
my @no_extract = array_minus(@env_all_tmp,@extract);
my @no_skip;
push(@no_skip,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
my @skipped = array_minus(@no_extract,@no_skip);
-@skipped = uniq(@skipped);
+ @skipped = uniq(@skipped);
### The operation return @delte_env environment
my @no_ext_skip = array_minus(@no_extract,@skipped);
my @no_del;
push(@no_del,@verb_env_tmp,@verw_env_tmp);
my @delete_env = array_minus(@no_ext_skip,@no_del);
-@delete_env = uniq(@delete_env);
+ @delete_env = uniq(@delete_env);
### The operation return @verbatim environment
my @no_ext_skip_del = array_minus(@no_ext_skip,@delete_env);
@@ -764,47 +762,47 @@ push(@no_verw_env,@extract,@skipped,@delete_env,@verbatim);
### Reserved words in verbatim inline (while)
my %changes_in = (
# ltximg tags
- '%<*ltximg>' => '%<*LTXIMG>',
- '%</ltximg>' => '%</LTXIMG>',
- '%<*noltximg>' => '%<*NOLTXIMG>',
- '%</noltximg>' => '%</NOLTXIMG>',
- '%<*remove>' => '%<*REMOVE>',
- '%</remove>' => '%</REMOVE>',
- '%<*ltximgverw>' => '%<*LTXIMGVERW>',
- '%</ltximgverw>' => '%</LTXIMGVERW>',
+ '%<*ltximg>' => '%<*LTXIMG>',
+ '%</ltximg>' => '%</LTXIMG>',
+ '%<*noltximg>' => '%<*NOLTXIMG>',
+ '%</noltximg>' => '%</NOLTXIMG>',
+ '%<*remove>' => '%<*REMOVE>',
+ '%</remove>' => '%</REMOVE>',
+ '%<*ltximgverw>' => '%<*LTXIMGVERW>',
+ '%</ltximgverw>' => '%</LTXIMGVERW>',
# pst/tikz set
- '\psset' => '\PSSET',
- '\tikzset' => '\TIKZSET',
+ '\psset' => '\PSSET',
+ '\tikzset' => '\TIKZSET',
# pspicture
- '\pspicture' => '\TRICKS',
- '\endpspicture' => '\ENDTRICKS',
+ '\pspicture' => '\TRICKS',
+ '\endpspicture' => '\ENDTRICKS',
# pgfpicture
- '\pgfpicture' => '\PGFTRICKS',
- '\endpgfpicture' => '\ENDPGFTRICKS',
+ '\pgfpicture' => '\PGFTRICKS',
+ '\endpgfpicture' => '\ENDPGFTRICKS',
# tikzpicture
- '\tikzpicture' => '\TKZTRICKS',
- '\endtikzpicture' => '\ENDTKZTRICKS',
+ '\tikzpicture' => '\TKZTRICKS',
+ '\endtikzpicture' => '\ENDTKZTRICKS',
# psgraph
- '\psgraph' => '\PSGRAPHTRICKS',
- '\endpsgraph' => '\ENDPSGRAPHTRICKS',
+ '\psgraph' => '\PSGRAPHTRICKS',
+ '\endpsgraph' => '\ENDPSGRAPHTRICKS',
# some reserved
- '\usepackage' => '\USEPACKAGE',
- '{graphicx}' => '{GRAPHICX}',
- '\graphicspath{' => '\GRAPHICSPATH{',
+ '\usepackage' => '\USEPACKAGE',
+ '{graphicx}' => '{GRAPHICX}',
+ '\graphicspath{' => '\GRAPHICSPATH{',
);
-### Changues for \begin... \end inline verbatim
+### Changues \begin... \end in verbatim inline
my %init_end = (
# begin{ and end{
- '\begin{' => '\BEGIN{',
- '\end{' => '\END{',
+ '\begin{' => '\BEGIN{',
+ '\end{' => '\END{',
);
### Changues for \begin{document} ... \end{document}
my %document = (
# begin/end document for split
- '\begin{document}' => '\BEGIN{document}',
- '\end{document}' => '\END{document}',
+ '\begin{document}' => '\BEGIN{document}',
+ '\end{document}' => '\END{document}',
);
### Reverse for extract and output file
@@ -839,27 +837,27 @@ my %changes_out = (
### Reverse tags, need back in all file to extract
my %reverse_tag = (
# ltximg tags
- '%<*LTXIMG>' => '%<*ltximg>',
- '%</LTXIMG>' => '%</ltximg>',
- '%<*NOLTXIMG>' => '%<*noltximg>',
- '%</NOLTXIMG>' => '%</noltximg>',
- '%<*REMOVE>' => '%<*remove>',
- '%</REMOVE>' => '%</remove>',
- '%<*LTXIMGVERW>' => '%<*ltximgverw>',
- '%</LTXIMGVERW>' => '%</ltximgverw>',
+ '%<*LTXIMG>' => '%<*ltximg>',
+ '%</LTXIMG>' => '%</ltximg>',
+ '%<*NOLTXIMG>' => '%<*noltximg>',
+ '%</NOLTXIMG>' => '%</noltximg>',
+ '%<*REMOVE>' => '%<*remove>',
+ '%</REMOVE>' => '%</remove>',
+ '%<*LTXIMGVERW>' => '%<*ltximgverw>',
+ '%</LTXIMGVERW>' => '%</ltximgverw>',
);
### Creatate a hash for changues
-my %extract_env = crearhash(@extract);
-my %skiped_env = crearhash(@skipped);
-my %verb_env = crearhash(@verbatim);
-my %verbw_env = crearhash(@verbatim_w);
-my %delete_env = crearhash(@delete_env);
+my %extract_env = crearhash(@extract);
+my %skiped_env = crearhash(@skipped);
+my %verb_env = crearhash(@verbatim);
+my %verbw_env = crearhash(@verbatim_w);
+my %delete_env = crearhash(@delete_env);
my %change_verbw_env = crearhash(@no_verw_env);
my %change_verb_env = crearhash(@no_verb_env);
### Join changues in new hash
-my %cambios = (%changes_in,%init_end);
+my %cambios = (%changes_in, %init_end);
### Variables y constantes
my $no_del = "\0";
@@ -869,9 +867,9 @@ my $del = $no_del;
my $llaves = qr/\{ .+? \} /x;
my $no_llaves = qr/(?: $llaves )? /x;
my $corchetes = qr/\[ .+? \] /x;
-my $anidado = qr/(\{(?:[^\{\}]++|(?1))*\}) /x;
+my $nestedbr = qr/(\{(?:[^\{\}]++|(?1))*\}) /x;
my $delimitador = qr/\{ (?<del>.+?) \} /x;
-my $verb = qr/(?:((spv|(?:q|f)?v|V)erb|$verbcmd)[*]?) /ix;
+my $verb = qr/(?:((spv|(?:q|f)?v|V)erb|$verbcmd)[*]?) /ix;
my $lst = qr/(?:(lst|pyg)inline)(?!\*) $no_corchete /ix;
my $mint = qr/(?: $mintline |SaveVerb) (?!\*) $no_corchete $no_llaves $llaves /ix;
my $no_mint = qr/(?: $mintline) (?!\*) $no_corchete /ix;
@@ -880,16 +878,16 @@ my $comentario = qr/^ \s* \%+ .+? $
my $definedel = qr/\\ (?: DefineShortVerb | lstMakeShortInline| MakeSpecialShortVerb ) [*]? $no_corchete $delimitador /ix;
my $indefinedel = qr/\\ (?: (Undefine|Delete)ShortVerb | lstDeleteShortInline) $llaves /ix;
-### Changues in input file in memory
-while ($documento =~
- / $marca
- | $comentario
- | $definedel
- | $indefinedel
- | $del .+? $del
+### Changues in input file (in memory)
+while ($document =~
+ / $marca
+ | $comentario
+ | $definedel
+ | $indefinedel
+ | $del .+? $del
/pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
if ($encontrado =~ /$definedel/) {
$del = $+{del};
$del = "\Q$+{del}" if substr($del,0,1) ne '\\';
@@ -899,160 +897,160 @@ while ($documento =~
}
else {
while (my($busco, $cambio) = each %cambios) {
- $encontrado =~ s/\Q$busco\E/$cambio/g;
- }
- substr $documento, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
- pos($documento) = $pos_inicial + length $encontrado;
+ $encontrado =~ s/\Q$busco\E/$cambio/g;
+ } # close while
+ substr $document, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
+ pos ($document) = $pos_inicial + length $encontrado;
}
}
### Regex for verbatim inline whit braces {...}
-my $mintd_ani = qr/\\ (?:$mintline|pygment) (?!\*) $no_corchete $no_llaves /x;
-my $tcbxverb = qr/\\ (?: tcboxverb [*]?|$verbcmd [*]?|lstinline) $no_corchete /x;
-my $tcbxmint = qr/(?:$tcbxverb|$mintd_ani) (?:\s*)? $anidado /x;
-
-### Changue \verb*{code} inline
-while ($documento =~ /$tcbxmint/pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
+my $fvextra = qr /\\ (?: (Save|Esc)Verb [*]?) $no_corchete /x;
+my $mintedbr = qr /\\ (?:$mintline|pygment) (?!\*) $no_corchete $no_llaves /x;
+my $tcbxverb = qr /\\ (?: tcboxverb [*]?|$verbcmd [*]?|lstinline) $no_corchete /x;
+my $verb_brace = qr / (?:$tcbxverb|$mintedbr|$fvextra) (?:\s*)? $nestedbr /x;
+
+### Changue \verb*{code} for verbatim inline
+while ($document =~ /$verb_brace/pgmx) {
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
while (my($busco, $cambio) = each %cambios) {
- $encontrado =~ s/\Q$busco\E/$cambio/g;
- } # close while
- substr $documento, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
- pos($documento)= $pos_inicial + length $encontrado;
+ $encontrado =~ s/\Q$busco\E/$cambio/g;
+ } # close while
+ substr $document, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
+ pos ($document) = $pos_inicial + length $encontrado;
} # close while
-### Changue <*TAGS> to <*tags> in file
-my $ltxtags = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %reverse_tag;
-$documento =~ s/^($ltxtags)/$reverse_tag{$1}/gmsx;
+### Changue <*TAGS> to <*tags>
+my $ltxtags = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %reverse_tag;
+ $document =~ s/^($ltxtags)/$reverse_tag{$1}/gmsx;
-### Defined environments Verbatim standart
+### Define environments Verbatim standart
my $verbatim = join "|", map quotemeta, sort { length $a <=> length $b } @verbatim;
-$verbatim = qr/$verbatim/x;
+ $verbatim = qr/$verbatim/x;
-### Defined environments Verbatim write
+### Define environments Verbatim write
my $verbatim_w = join "|", map quotemeta, sort { length $a <=> length $b } @verbatim_w;
-$verbatim_w = qr/$verbatim_w/x;
+ $verbatim_w = qr/$verbatim_w/x;
### Define environments to skip
my $skipenv = join "|", map quotemeta, sort { length $a <=> length $b } @skipped;
-$skipenv = qr/$skipenv/x;
+ $skipenv = qr/$skipenv/x;
### Define environments to extract
my $environ = join "|", map quotemeta, sort { length $a <=> length $b } @extract;
-$environ = qr/$environ/x;
+ $environ = qr/$environ/x;
### Define environments to delete
my $delenv = join "|", map quotemeta, sort { length $a <=> length $b } @delt_env_tmp;
-$delenv = qr/$delenv/x;
+ $delenv = qr/$delenv/x;
### Split file by lines
-my @lineas = split /\n/, $documento;
+my @lineas = split /\n/, $document;
### Hash and Regex for changues
my %replace = (%change_verb_env,%changes_in,%document);
-my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
### Change in $verbatim and $verbatim_w
my $DEL;
for (@lineas) {
if (/\\begin\{($verbatim\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
my %replace = (%change_verbw_env,%changes_in,%document);
- my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
- s/($find)/$replace{$1}/g;
- }
+ my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $documento
-$documento = join("\n", @lineas);
+### Join lines in $document
+$document = join("\n", @lineas);
### Split input file
-my($cabeza,$cuerpo,$final) = $documento =~ m/\A (.+?) (\\begin\{document\} .+?)(\\end\{document\}.*)\z/msx;
+my ($preamble,$bodydoc,$enddoc) = $document =~ m/\A (.+?) (\\begin\{document\} .+?)(\\end\{document\}.*)\z/msx;
### Regex for delete environment
my $delt_env = qr /
- (
- (?:
- \\begin\{$delenv\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$delenv\*?\})
- (?!end\{$delenv\*?\})|
- (?-1)
- )*
- \\end\{$delenv\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$delenv\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$delenv\*?\})
+ (?!end\{$delenv\*?\})|
+ (?-1)
+ )*
+ \\end\{$delenv\*?\}
+ )
+ )
+ /x;
### Regex for verbatim write environment
my $verb_wrt = qr /
- (
- (?:
- \\begin\{$verbatim_w\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$verbatim_w\*?\})
- (?!end\{$verbatim_w\*?\})|
- (?-1)
- )*
- \\end\{$verbatim_w\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$verbatim_w\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$verbatim_w\*?\})
+ (?!end\{$verbatim_w\*?\})|
+ (?-1)
+ )*
+ \\end\{$verbatim_w\*?\}
+ )
+ )
+ /x;
### Pass $verb_wrt to %<*ltximgverw> ... %</ltximgverw>
-$cuerpo =~ s/($verb_wrt)/\%<\*ltximgverw>\n$1\n\%<\/ltximgverw>/gmsx;
+$bodydoc =~ s/($verb_wrt)/\%<\*ltximgverw>\n$1\n\%<\/ltximgverw>/gmsx;
### Regex for skip environment
my $skip_env = qr /
- (
- (?:
- \\begin\{$skipenv\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$skipenv\*?\})
- (?!end\{$skipenv\*?\})|
- (?-1)
- )*
- \\end\{$skipenv\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$skipenv\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$skipenv\*?\})
+ (?!end\{$skipenv\*?\})|
+ (?-1)
+ )*
+ \\end\{$skipenv\*?\}
+ )
+ )
+ /x;
### Pass %<*noltximg> ... %</noltximg> to \begin{nopreview} ... \end{nopreview}
-$cuerpo =~ s/^\%<\*$skiptag>(.+?)\%<\/$skiptag>/\\begin\{nopreview\}$1\\end\{nopreview\}/gmsx;
+$bodydoc =~ s/^\%<\*$skiptag>(.+?)\%<\/$skiptag>/\\begin\{nopreview\}$1\\end\{nopreview\}/gmsx;
### Pass $skip_env to \begin{nopreview} .+? \end{nopreview}
-$cuerpo =~ s/
- \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- ($skip_env)/\\begin\{nopreview\}\n$1\n\\end\{nopreview\}\n/gmsx;
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ ($skip_env)/\\begin\{nopreview\}\n$1\n\\end\{nopreview\}\n/gmsx;
### Regex to extract environments
my $extr_env = qr /
- (
- (?:
- \\begin\{$environ\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$environ\*?\})
- (?!end\{$environ\*?\})|
- (?-1)
- )*
- \\end\{$environ\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$environ\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$environ\*?\})
+ (?!end\{$environ\*?\})|
+ (?-1)
+ )*
+ \\end\{$environ\*?\}
+ )
+ )
+ /x;
### Set bolean options from input file
+$zip = 1 if exists $opts_file{options}{zip};
+$tar = 1 if exists $opts_file{options}{tar};
$force = 1 if exists $opts_file{options}{force};
$run = 0 if exists $opts_file{options}{norun};
$pdf = 0 if exists $opts_file{options}{nopdf};
@@ -1069,174 +1067,156 @@ $srcenv = 1 if exists $opts_file{options}{srcenv};
$subenv = 1 if exists $opts_file{options}{subenv};
### Check plain TeX syntax
-my %special = map { $_ => 1 } @extract; # anon hash
+my %special = map { $_ => 1 } @extract; # anon hash
### Convert \pspicture to LaTeX syntax
-if(exists($special{pspicture})){
- $cuerpo =~ s/
+if (exists($special{pspicture})) {
+ $bodydoc =~ s/
\\pspicture(\*)?(.+?)\\endpspicture/\\begin{pspicture$1}$2\\end{pspicture$1}/gmsx;
}
### Convert \psgraph to LaTeX syntax
-if(exists($special{psgraph})){
- $cuerpo =~ s/
+if (exists($special{psgraph})) {
+ $bodydoc =~ s/
\\psgraph(\*)?(.+?)\\endpsgraph/\\begin{psgraph$1}$2\\end{psgraph$1}/gmsx;
}
### Convert \tikzpicture to LaTeX syntax
-if(exists($special{tikzpicture})){
- $cuerpo =~ s/
+if (exists($special{tikzpicture})) {
+ $bodydoc =~ s/
\\tikzpicture(.+?)\\endtikzpicture/\\begin{tikzpicture}$1\\end{tikzpicture}/gmsx;
}
### Convert \pgfpicture to LaTeX syntax
-if(exists($special{pgfpicture})){
- $cuerpo =~ s/
+if (exists($special{pgfpicture})) {
+ $bodydoc =~ s/
\\pgfpicture(.+?)\\endpgfpicture/\\begin{pgfpicture}$1\\end{pgfpicture}/gmsx;
}
### Pass %<*ltximg> (.+?) %</ltximg> to \begin{preview} (.+?) \end{preview}
-$cuerpo =~ s/^\%<\*$extrtag>(.+?)\%<\/$extrtag>/\\begin\{preview\}$1\\end\{preview\}/gmsx;
+$bodydoc =~ s/^\%<\*$extrtag>(.+?)\%<\/$extrtag>/\\begin\{preview\}$1\\end\{preview\}/gmsx;
### $force mode for pstricks/psgraph/tikzpiture
if ($force) {
-# pspicture or psgraph found
-if(exists($special{pspicture}) or exists($special{psgraph})){
-$cuerpo =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
- (?<code>
- (?:\\psset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
- \\begin\{(?<env> pspicture\*?| psgraph)\} .+? \\end\{\k<env>\}
- )
- /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
+if (exists($special{pspicture}) or exists($special{psgraph})) { # pspicture or psgraph found
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
+ (?<code>
+ (?:\\psset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
+ \\begin\{(?<env> pspicture\*?| psgraph)\} .+? \\end\{\k<env>\}
+ )
+ /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
} # close pspicture
-# tikzpicture found
-if(exists($special{tikzpicture})){
-$cuerpo =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
- (?<code>
- (?:\\tikzset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
- \\begin\{(?<env> tikzpicture)\} .+? \\end\{\k<env>\}
- )
- /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
+if (exists($special{tikzpicture})) {# tikzpicture found
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
+ (?<code>
+ (?:\\tikzset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
+ \\begin\{(?<env> tikzpicture)\} .+? \\end\{\k<env>\}
+ )
+ /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
} # close tikzpicture
-} # close force mode
+} # close $force mode
### Pass $extr_env to \begin{preview} .+? \end{preview}
-$cuerpo =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- ($extr_env)/\\begin\{preview\}\n$1\n\\end\{preview\}/gmsx;
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ ($extr_env)/\\begin\{preview\}\n$1\n\\end\{preview\}/gmsx;
-### The extract environments need back word to original
+### The extract environments need back words to original
%replace = (%changes_out,%reverse_tag);
-$find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+ $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
-### Split $cabeza by lines
-@lineas = split /\n/, $cabeza;
+### Split $preamble by lines
+@lineas = split /\n/, $preamble;
### Changues in verbatim write
for (@lineas) {
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $cabeza
-$cabeza = join("\n", @lineas);
+### Join lines in $preamble
+$preamble = join("\n", @lineas);
### Change back betwen \begin{preview} ... \end{preview}
-@lineas = split /\n/, $cuerpo;
+@lineas = split /\n/, $bodydoc;
for (@lineas) {
if (/\\begin\{(preview)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) { # range operator
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $cuerpo
-$cuerpo = join("\n", @lineas);
+### Join lines in $bodydoc
+$bodydoc = join("\n", @lineas);
-### If environment extract found, the run script
-my $BP = '\\\\begin\{preview\}';
-my $EP = '\\\\end\{preview\}';
+### preview environment for extract
+my $BP = '\\\\begin\{preview\}';
+my $EP = '\\\\end\{preview\}';
-my @env_extract = $cuerpo =~ m/(?<=$BP)(.+?)(?=$EP)/gms;
+my @env_extract = $bodydoc =~ m/(?<=$BP)(.+?)(?=$EP)/gms;
my $envNo = scalar @env_extract;
-### PSTexample suport
-my $BE = '\\\\begin\{PSTexample\}';
-my $EE = '\\\\end\{PSTexample\}';
+### PSTexample environment for extract
+my $BE = '\\\\begin\{PSTexample\}';
+my $EE = '\\\\end\{PSTexample\}';
-my @exa_extract = $cuerpo =~ m/(?<=$BE)(.+?)(?=$EE)/gms;
+my @exa_extract = $bodydoc =~ m/(?<=$BE)(.+?)(?=$EE)/gms;
my $exaNo = scalar @exa_extract;
-### Check if PSTexample environment found
-if($exaNo!= 0){
- $PSTexa=1;
-}
+### Check if PSTexample environment found, 1 = run script
+if ($exaNo!=0) { $PSTexa = 1; }
-### Check if standart environment found
-if($envNo!= 0){
- $STDenv=1;
-}
+### Check if standart environment found, , 1 = run script
+if ($envNo!=0) { $STDenv=1; }
### PSTexample environment suport
-### Append graphic= to \begin{PSTexample}[...]
-if($PSTexa){
-my $exaNo = 1;
-while ($cuerpo =~ /\\begin\{PSTexample\}(\[.+?\])?/gsm) {
+if ($PSTexa) { # append [graphic={[...]...}]
+$exaNo = 1;
+while ($bodydoc =~ /\\begin\{PSTexample\}(\[.+?\])?/gsm) {
my $swpl_grap = "graphic=\{\[scale=1\]$imageDir/$name-$prefix-exa";
my $corchetes = $1;
- my($pos_inicial, $pos_final) = ($-[1], $+[1]);
- if (not $corchetes) {
- $pos_inicial = $pos_final = $+[0];
- }
- if (not $corchetes or $corchetes =~ /\[\s*\]/) {
- $corchetes = "[$swpl_grap-$exaNo}]";
- }
- else {
- $corchetes =~ s/\]/,$swpl_grap-$exaNo}]/;
+ my ($pos_inicial, $pos_final) = ($-[1], $+[1]);
+ if (not $corchetes) { $pos_inicial = $pos_final = $+[0]; }
+ if (not $corchetes or $corchetes =~ /\[\s*\]/) {
+ $corchetes = "[$swpl_grap-$exaNo}]";
}
- substr($cuerpo, $pos_inicial, $pos_final - $pos_inicial) = $corchetes;
- pos($cuerpo) = $pos_inicial + length $corchetes;
+ else { $corchetes =~ s/\]/,$swpl_grap-$exaNo}]/; }
+ substr($bodydoc, $pos_inicial, $pos_final - $pos_inicial) = $corchetes;
+ pos($bodydoc) = $pos_inicial + length $corchetes;
} # close while
-continue {
- $exaNo++;
- }
-
-### Pass PSTexample to nopreview envirnment
-$cuerpo =~ s/\%<\*ltximgverw>\n
- (?<code>
- \\begin\{PSTexample\} .+? \\end\{PSTexample\}
- )
- \n\%<\/ltximgverw>
- /\\begin\{nopreview\}\n$+{code}\n\\end\{nopreview\}/gmsx;
+continue { $exaNo++; } # increment counter
+
+### Pass PSTexample to nopreview environment
+$bodydoc =~ s/\%<\*ltximgverw>\n
+ (?<code>
+ \\begin\{PSTexample\} .+? \\end\{PSTexample\}
+ )
+ \n\%<\/ltximgverw>
+ /\\begin\{nopreview\}\n$+{code}\n\\end\{nopreview\}/gmsx;
} # close PSTexa
### Command line script identification
print "$program $nv $copyright" ;
### Check if enviroment found in input file
-if ($envNo == 0 and $exaNo == 0){
+if ($envNo == 0 and $exaNo == 0) {
die errorUsage "ltximg can not find any environment to extract in file $name$ext";
- }
-elsif ($envNo!= 0 and $exaNo!= 0){
+ }
+elsif ($envNo!= 0 and $exaNo!= 0) {
say "The file $name$ext contain $envNo environment to extract and $exaNo PSTexample environment to extract";
- }
-elsif ($envNo == 0 and $exaNo!= 0){
+ }
+elsif ($envNo == 0 and $exaNo!= 0) {
say "The file $name$ext contain $exaNo PSTexample environment to extract";
- }
-else {
- say "The file $name$ext contain $envNo environment to extract";
- }
+ }
+else { say "The file $name$ext contain $envNo environment to extract"; }
### Set output file name from input file
if (exists $opts_file{options}{output}){
@@ -1246,57 +1226,43 @@ if (exists $opts_file{options}{output}){
### Validate output file name
if (defined $output) {
# Not contain - at begin
-if ($output =~ /(^\-|^\.).*?/){
+if ($output =~ /(^\-|^\.).*?/) {
die errorUsage "$output it is not a valid name for output file";
}
-
# The name of the output file must be different that $name
-if ($output eq "$name") { # $output = $input
- $output = "$name-out$ext";
-}
+if ($output eq "$name") { $output = "$name-out$ext"; }
+
# The name of the output file must be different that $name.ext
-if ($output eq "$name$ext") { # $output = $input.tex
- $output = "$name-out$ext";
-}
+if ($output eq "$name$ext") { $output = "$name-out$ext"; }
+
# Remove .ltx or .tex extension
-if ($output =~ /.*?$ext/){
- $output =~ s/(.+?)$ext/$1/gms;
- }
-} # close output string check
+if ($output =~ /.*?$ext/) { $output =~ s/(.+?)$ext/$1/gms;}
+} # close check
### If output name are ok, then $outfile = 1
-if(defined($output)){
- $outfile = 1;
-}
+if (defined($output)) { $outfile = 1; }
### If --srcenv or --subenv option are OK then execute script
-if($srcenv){
- $outsrc = 1;
- $subenv = 0;
-}
-
-if ($subenv){
- $outsrc = 1;
- $srcenv = 0;
-}
+if ($srcenv) { $outsrc = 1; $subenv = 0; }
+if ($subenv) { $outsrc = 1; $srcenv = 0; }
### Set imgdir name from input file
-if (exists $opts_file{options}{imgdir}){
+if (exists $opts_file{options}{imgdir}) {
$imageDir = $opts_file{options}{imgdir};
}
### Set prefix name from input file
-if (exists $opts_file{options}{prefix}){
+if (exists $opts_file{options}{prefix}) {
$prefix = $opts_file{options}{prefix};
}
### Set pdfcrop margins from input file
-if (exists $opts_file{options}{margins}){
+if (exists $opts_file{options}{margins}) {
$margins = $opts_file{options}{margins};
}
### Set DPI resolution for images from input file
-if (exists $opts_file{options}{dpi}){
+if (exists $opts_file{options}{dpi}) {
$DPI = $opts_file{options}{dpi};
}
@@ -1308,12 +1274,13 @@ my $opt_page = $crop ? "\n\\pagestyle\{empty\}\n\\begin\{document\}"
: "\n\\begin\{document\}"
;
-### Preamble options for subfiles
-my $sub_prea = "$optin$cabeza$opt_page";
+### Add options to preamble for subfiles
+my $sub_prea = "$atbegindoc$preamble$opt_page";
### Delete <*remove> ... </remove> in $sub_prea
-$sub_prea =~s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+$sub_prea =~ s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+### Options for preview packpage
my $opt_prew = $xetex ? 'xetex,'
: $latex ? ''
: 'pdftex,'
@@ -1333,98 +1300,84 @@ my $srcNo = 1;
### Source file whitout preamble for standart environment
if ($srcenv) {
-
-### Extract standart environment in single files
-if($STDenv){
-say "Creating $envNo files with source code for all environments";
-while ($cuerpo =~ m/$BP\s*(?<env_src>.+?)\s*$EP/gms) {
-open my $OUTsrc, '>', "$imageDir/$src_name$srcNo$ext";
- print $OUTsrc $+{env_src};
-close $OUTsrc;
- } # close while
-continue {
- $srcNo++;
- }
+if ($STDenv) { # extract standard environments in individual files
+ say "Creating $envNo files with source code for all environments";
+ while ($bodydoc =~ m/$BP\s*(?<env_src>.+?)\s*$EP/gms) {
+ open my $OUTsrc, '>', "$imageDir/$src_name$srcNo$ext";
+ print $OUTsrc $+{env_src};
+ close $OUTsrc;
+ } # close while
+ continue { $srcNo++; } # increment counter
} # close STDenv
-
-### Extract PSTexample in single files
-if($PSTexa){
-say "Creating $exaNo files with source code for all PSTexample environments";
-while ($cuerpo =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
-open my $OUTexa, '>', "$+{'pst_exa_name'}$ext";
- print $OUTexa $+{'exa_src'};
-close $OUTexa;
+if ($PSTexa) { # extract PSTexample environments in individual files
+ say "Creating $exaNo files with source code for all PSTexample environments";
+ while ($bodydoc =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
+ open my $OUTexa, '>', "$+{'pst_exa_name'}$ext";
+ print $OUTexa $+{'exa_src'};
+ close $OUTexa;
}
} # close PSTexa
} # close srcenv
### Subfile whit preamble
if ($subenv) {
-
-### Extract standart environments in subfiles
-if($STDenv){
+if ($STDenv) { # extract standard environments (with preamble) in individual files
say "Creating a $envNo files whit source code and preamble for all environments";
-while ($cuerpo =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms) { # search $cuerpo
+while ($bodydoc =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms) { # search $bodydoc
open my $OUTsub, '>', "$imageDir/$src_name$srcNo$ext";
print $OUTsub <<"EOC";
$sub_prea$+{'env_src'}\\end\{document\}
EOC
close $OUTsub;
} # close while
-continue {
- $srcNo++;
- }
+continue { $srcNo++; }
} # close STDenv
-
-### Extract PSTexample environments in subfiles
-if($PSTexa){
+if ($PSTexa) { # extract PSTexample environments (with preamble) in individual files
say "Creating a $exaNo files whit source code and preamble for all PSTexample environments";
-while ($cuerpo =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
-open my $OUTsub, '>', "$+{'pst_exa_name'}$ext";
-print $OUTsub "$sub_prea\n$+{'exa_src'}\n\\end\{document\}";
-close $OUTsub;
- } # close while
- } # close $PSTexa
+while ($bodydoc =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
+ open my $OUTsub, '>', "$+{'pst_exa_name'}$ext";
+ print $OUTsub "$sub_prea\n$+{'exa_src'}\n\\end\{document\}";
+ close $OUTsub;
+ } # close while
+ } # close $PSTexa
} # close subenv
} # close $outsrc
-### Create a one file whit all PSTexample environments
-if($PSTexa){
+### Create a one file with "all" PSTexample environments extracted
+if ($PSTexa) {
say "Creating the temporary file $name-$prefix-exa-$tmp$ext whit $exaNo PSTexample environments extracted";
@exa_extract = undef;
-while ( $cuerpo =~ m/$BE\[.+? $imageDir\/.+?-\d+\}\](?<exa_src>.+?)$EE/gmsx ) { # search $cuerpo
-push @exa_extract, $+{exa_src}."\n\\newpage\n";
-open my $OUTfig, '>', "$name-$prefix-exa-$tmp$ext";
- print $OUTfig "$optin"."$cabeza"."$opt_page"."@exa_extract\n"."\\end\{document\}";
-close $OUTfig;
- }# close while
-
-### Move and rename tmp-exa-rand file to /image dir
-if(!$run){
+ while ( $bodydoc =~ m/$BE\[.+? $imageDir\/.+?-\d+\}\](?<exa_src>.+?)$EE/gmsx ) { # search $bodydoc
+ push @exa_extract, $+{exa_src}."\n\\newpage\n";
+ open my $OUTfig, '>', "$name-$prefix-exa-$tmp$ext";
+ print $OUTfig "$atbegindoc"."$preamble"."$opt_page"."@exa_extract\n"."\\end\{document\}";
+ close $OUTfig;
+ }# close while
+if (!$run) { # Move and rename tmp-exa-rand file to /image dir
say "Moving the file $name-$prefix-exa-$tmp$ext to /$imageDir/$name-$prefix-exa-all$ext";
move("$workdir/$name-$prefix-exa-$tmp$ext", "$imageDir/$name-$prefix-exa-all$ext");
}
}# close $PSTexa
-### Creating one file whit all environments extracted (noprew option)
-if($STDenv){
+### Create a one file whit "all" standard environments extracted
+if ($STDenv) {
open my $OUTfig, '>', "$name-$prefix-$tmp$ext";
-if ($noprew) {
-say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environments extracted";
-my @env_extract;
-while ( $cuerpo =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms ) { # search $cuerpo
- push @env_extract, $+{env_src}."\n\\newpage\n";
+ if ($noprew) { # $noprew option
+ say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environments extracted";
+ my @env_extract;
+ while ( $bodydoc =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms ) { # search $bodydoc
+ push @env_extract, $+{env_src}."\n\\newpage\n";
} # close while
-print $OUTfig "$optin"."$cabeza"."$opt_page"."@env_extract\n"."\\end{document}";
- } # close noprew
-else {
-say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environment extracted using preview package";
-print $OUTfig $optin.$preview.$cabeza."\n".$cuerpo."\n\\end{document}";
- }
+ print $OUTfig "$atbegindoc"."$preamble"."$opt_page"."@env_extract\n"."\\end{document}";
+ } # close $noprew
+ else { # default
+ say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environment extracted using preview package";
+ print $OUTfig $atbegindoc.$preview.$preamble."\n".$bodydoc."\n\\end{document}";
+ }
close $OUTfig;
### Move tmp-rand file to /image dir
-if(!$run){
+if (!$run) {
say "Moving the file $name-$prefix-$tmp$ext to /$imageDir/$name-$prefix-all$ext";
move("$workdir/$name-$prefix-$tmp$ext", "$imageDir/$name-$prefix-all$ext");
}
@@ -1445,94 +1398,92 @@ my $silence = $verbose ? ''
: ">$null"
;
-### Append -q to gs/poppler for system command line
-my $quiet = $verbose ? ''
- : '-q'
- ;
+### Append -q to gs and poppler for system command line
+my $quiet = $verbose ? ''
+ : '-q'
+ ;
### Compilers
-my $compiler = $xetex ? "xelatex $opt_compiler"
+my $compiler = $xetex ? "xelatex $opt_compiler"
: $luatex ? "lualatex $opt_compiler"
- : $latex ? "latex $opt_compiler"
- : $dvips ? "latex $opt_compiler"
+ : $latex ? "latex $opt_compiler"
+ : $dvips ? "latex $opt_compiler"
: $dvipdf ? "latex $opt_compiler"
- : $arara ? 'arara'
+ : $arara ? 'arara'
: "pdflatex $opt_compiler"
;
### Message in command line for compilers
-my $msg_compiler = $xetex ? 'xelatex'
+my $msg_compiler = $xetex ? 'xelatex'
: $luatex ? 'lualatex'
- : $latex ? 'latex>dvips>ps2pdf'
- : $dvips ? 'latex>dvips>ps2pdf'
+ : $latex ? 'latex>dvips>ps2pdf'
+ : $dvips ? 'latex>dvips>ps2pdf'
: $dvipdf ? 'latex>dvipdfmx'
- : $arara ? 'arara'
+ : $arara ? 'arara'
: 'pdflatex'
;
### Options for ghostscript in command line
my %opt_gs_dev = (
- pdf => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress",
- gray => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray",
- png => "$gscmd $quiet -dNOSAFER -sDEVICE=pngalpha -r$DPI",
- bmp => "$gscmd $quiet -dNOSAFER -sDEVICE=bmp32b -r$DPI",
- jpg => "$gscmd $quiet -dNOSAFER -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4",
- tif => "$gscmd $quiet -dNOSAFER -sDEVICE=tiff32nc -r$DPI",
- );
+ pdf => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress",
+ gray => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray",
+ png => "$gscmd $quiet -dNOSAFER -sDEVICE=pngalpha -r$DPI",
+ bmp => "$gscmd $quiet -dNOSAFER -sDEVICE=bmp32b -r$DPI",
+ jpg => "$gscmd $quiet -dNOSAFER -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4",
+ tif => "$gscmd $quiet -dNOSAFER -sDEVICE=tiff32nc -r$DPI",
+ );
### Options for poppler-utils in command line
my %opt_poppler = (
- eps => "pdftops $quiet -eps",
- ppm => "pdftoppm $quiet -r $DPI",
- svg => "pdftocairo $quiet -svg",
- );
+ eps => "pdftops $quiet -eps",
+ ppm => "pdftoppm $quiet -r $DPI",
+ svg => "pdftocairo $quiet -svg",
+ );
### Option for pdfcrop in command line
-my $opt_crop = $xetex ? "--xetex --margins $margins"
+my $opt_crop = $xetex ? "--xetex --margins $margins"
: $luatex ? "--luatex --margins $margins"
- : $latex ? "--margins $margins"
+ : $latex ? "--margins $margins"
: "--pdftex --margins $margins"
;
### Compiler generate file whit all environment extracted
-if($run){
+if ($run) {
opendir(my $DIR, $workdir);
while (readdir $DIR) {
### Compiler generate file
-if (/(?<nombre>$name-$prefix(-exa)?)(?<type>-$tmp$ext)/) {
- system("$compiler $+{nombre}$+{type} $silence");
- say "Compiling the file $+{nombre}$+{type} using $msg_compiler";
+if (/(?<name>$name-$prefix(-exa)?)(?<type>-$tmp$ext)/) {
+ system("$compiler $+{name}$+{type} $silence");
+ say "Compiling the file $+{name}$+{type} using $msg_compiler";
### Compiling file using latex>dvips>ps2pdf
-if($dvips or $latex){
- system("dvips -q -Ppdf -o $+{nombre}-$tmp.ps $+{nombre}-$tmp.dvi");
- system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $+{nombre}-$tmp.ps $+{nombre}-$tmp.pdf");
+if ($dvips or $latex) {
+ system("dvips -q -Ppdf -o $+{name}-$tmp.ps $+{name}-$tmp.dvi");
+ system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $+{name}-$tmp.ps $+{name}-$tmp.pdf");
} # close latex
### Compiling file using latex>dvipdfmx
-if($dvipdf){
- system("dvipdfmx -q $+{nombre}-$tmp.dvi");
-} # close dvipdfmx
+if ($dvipdf) { system("dvipdfmx -q $+{name}-$tmp.dvi"); }
### If option gray
-if($gray){
-say "Moving the file $+{nombre}-$tmp.pdf to $tempDir/$+{nombre}-all.pdf (gray scale)";
-system("$opt_gs_dev{gray} -o $tempDir/$+{nombre}-all.pdf $workdir/$+{nombre}-$tmp.pdf");
- move("$workdir/$+{nombre}-$tmp.pdf","$tempDir/$+{nombre}-$tmp.pdf");
- }
-else{
- say "Moving the file $+{nombre}-$tmp.pdf to $tempDir/$+{nombre}-all.pdf";
- move("$workdir/$+{nombre}-$tmp.pdf", "$tempDir/$+{nombre}-all.pdf");
+if ($gray) {
+ say "Moving the file $+{name}-$tmp.pdf to $tempDir/$+{name}-all.pdf (gray scale)";
+ system("$opt_gs_dev{gray} -o $tempDir/$+{name}-all.pdf $workdir/$+{name}-$tmp.pdf");
+ move("$workdir/$+{name}-$tmp.pdf","$tempDir/$+{name}-$tmp.pdf");
+ }
+else {
+ say "Moving the file $+{name}-$tmp.pdf to $tempDir/$+{name}-all.pdf";
+ move("$workdir/$+{name}-$tmp.pdf", "$tempDir/$+{name}-all.pdf");
}
### Crop generate file
-if($crop){
-say "The file $+{nombre}-all.pdf need a crop, using pdfcrop $opt_crop";
-system("pdfcrop $opt_crop $tempDir/$+{nombre}-all.pdf $tempDir/$+{nombre}-all.pdf $silence");
+if ($crop) {
+ say "The file $+{name}-all.pdf need a crop, using pdfcrop $opt_crop";
+ system("pdfcrop $opt_crop $tempDir/$+{name}-all.pdf $tempDir/$+{name}-all.pdf $silence");
}
### Move tmp-rand.tex file whit all source code for environments to /images dir
-move("$workdir/$+{nombre}$+{type}", "$imageDir/$+{nombre}-all$ext");
+move("$workdir/$+{name}$+{type}", "$imageDir/$+{name}-all$ext");
} # close if m/.../
} # close while
closedir $DIR;
@@ -1553,42 +1504,42 @@ my %format = (%opts_cmd);
my $format = join " ",grep { defined $format{$_} } keys %format;
### Create image formats in separate files
-if($run){
+if ($run) {
opendir(my $DIR, $tempDir);
while (readdir $DIR) {
### PDF/PNG/JPG/BMP/TIFF format suported by ghostscript
-if (/(?<nombre>$name-$prefix(-exa)?)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix(-exa)?)(?<type>-all\.pdf)/) {
for my $var (qw(pdf png jpg bmp tif)) {
if (defined $opts_cmd{$var}) {
- my $ghostcmd = "$opt_gs_dev{$var} -o $workdir/$imageDir/$+{nombre}-%1d.$var $tempDir/$+{nombre}$+{type}";
+ my $ghostcmd = "$opt_gs_dev{$var} -o $workdir/$imageDir/$+{name}-%1d.$var $tempDir/$+{name}$+{type}";
system("$ghostcmd");
- print "Create a $var image format: runing command $opt_gs_dev{$var} in $+{nombre}$+{type}\r\n";
- } # close defined for ghostscript
+ print "Create a $var image format: runing command $opt_gs_dev{$var} in $+{name}$+{type}\r\n";
+ } # close defined for ghostscript
}# close for
} # close if m/.../
### EPS/PPM/SVG format suported by poppler-utils
-if (/(?<nombre>$name-$prefix)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix)(?<type>-all\.pdf)/) {
for my $var (qw(eps ppm svg)) {
if (defined $opts_cmd{$var}) {
for (my $epsNo = 1; $epsNo <= $envNo; $epsNo++) {
-my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{nombre}$+{type} $workdir/$imageDir/$+{nombre}-$epsNo.$var";
+my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{name}$+{type} $workdir/$imageDir/$+{name}-$epsNo.$var";
system("$poppler");
} # close for C style
-print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombre}$+{type}\r\n";
+print "Create a $var image format: runing command $opt_poppler{$var} in $+{name}$+{type}\r\n";
} # close defined
} # close for my $var
} # close if m/.../
### EPS/PPM/SVG for pst-exa package
-if (/(?<nombre>$name-$prefix-exa)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix-exa)(?<type>-all\.pdf)/) {
for my $var (qw(eps ppm svg)) {
if (defined $opts_cmd{$var}) {
for (my $epsNo = 1; $epsNo <= $exaNo; $epsNo++) {
-my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{nombre}$+{type} $workdir/$imageDir/$+{nombre}-$epsNo.$var";
+my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{name}$+{type} $workdir/$imageDir/$+{name}-$epsNo.$var";
system("$poppler");
} # close for C style
-print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombre}$+{type}\r\n";
+print "Create a $var image format: runing command $opt_poppler{$var} in $+{name}$+{type}\r\n";
} # close defined
} # close for my $var
} # close if m/.../
@@ -1596,26 +1547,26 @@ print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombr
closedir $DIR; #close dir
### Renaming PPM image files
-if(defined $opts_cmd{ppm}){
-opendir(my $DIR, $imageDir);
-while (readdir $DIR) {
- if (/(?<nombre>$name-fig(-exa)?-\d+\.ppm)(?<sep>-\d+)(?<ppm>\.ppm)/) {
- move("$imageDir/$+{nombre}$+{sep}$+{ppm}", "$imageDir/$+{nombre}");
- } # close if m/.../
+if (defined $opts_cmd{ppm}) {
+ opendir(my $DIR, $imageDir);
+ while (readdir $DIR) {
+ if (/(?<name>$name-fig(-exa)?-\d+\.ppm)(?<sep>-\d+)(?<ppm>\.ppm)/) {
+ move("$imageDir/$+{name}$+{sep}$+{ppm}", "$imageDir/$+{name}");
+ } # close if m/.../
} # close while
-closedir $DIR;
- } # close renaming PPM
+ closedir $DIR;
+ } # close renaming PPM
} # close run
### Create a output file
if ($outfile) {
-say "Creating the file $output$ext, changue extracted environments to \\includegraphics";
+say "Creating the file $output$ext, convert extracted environments to \\includegraphics";
### Convert extracted environments to \includegraphics
-my $grap="\\includegraphics[scale=1]{$name-$prefix-";
-my $close = '}';
-my $imgNo = 1;
-$cuerpo =~ s/$BP.+?$EP/$grap@{[$imgNo++]}$close/msg; # changes
+my $grap = "\\includegraphics[scale=1]{$name-$prefix-";
+my $close = '}';
+my $imgNo = 1;
+$bodydoc =~ s/$BP.+?$EP/$grap@{[$imgNo++]}$close/msg; # changes
### Constant
my $USEPACK = quotemeta('\usepackage');
@@ -1630,97 +1581,96 @@ my $FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
my $graphix = qr/(\\ usepackage \s*\[\s* .+? \s*\] \s*\{\s* graphicx \s*\} )/ix;
### Capture graphix package for future use
-my (@graphix) = $cabeza =~ m/$graphix/x;
+my (@graphix) = $preamble =~ m/$graphix/x;
### Remove graphix package
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
### Comment \graphicspath for order and future use
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ ($GRAPHICPATH) /%$1/msxg;
+$preamble =~s /\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ ($GRAPHICPATH) /%$1/msxg;
### Regex to capture [options] for pst-exa package
-my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x;
+my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x;
### Capture [option] for pst-exa package
-my (@pst_exa) = $cabeza =~ m/$pstexa/xg;
+my (@pst_exa) = $preamble =~ m/$pstexa/xg;
### Search [option] in pst-exa package
-my %pst_exa = map { $_ => 1 } @pst_exa;
+my %pst_exa = map { $_ => 1 } @pst_exa;
### Clean file (pst/tags)
-if($clean{pst}){
-$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add )? | psfrag |psgo |vaucanson-g| auto-pst-pdf )/x;
-$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
+if ($clean{pst}) {
+$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add )? | psfrag |psgo |vaucanson-g| auto-pst-pdf )/x;
+$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
-### Remove package lines
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
+### Remove pst packages lines
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
### Delete package words
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
(?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx;
### Delete \psset
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
### Delete \SpecialCoor
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx;
} # close clean{pst}
### Delete empty package line \usepackage{}
-$cabeza =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx;
-### Append graphix to end of preamble
-if(!@graphix == 0){
-$cabeza .= <<"EXTRA";
+### Append graphicx to end of preamble
+if (!@graphix == 0) {
+$preamble .= <<"EXTRA";
@graphix
EXTRA
-}else{
-$cabeza .= <<"EXTRA";
-
+ } else {
+$preamble .= <<"EXTRA";
\\usepackage{graphicx}
EXTRA
}
### Regex to capture \graphicspath
-my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix;
+my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix;
### If preamble contain \graphicspath
-if($cabeza =~ m/($graphicspath)/m){
-while ($cabeza =~ /$graphicspath /pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
- if ($encontrado =~ /$graphicspath/) {
- my $argumento = $1;
- if ($argumento !~ /\{$imageDir\\\}/) {
- $argumento .= "\{$imageDir/\}";
- my $cambio = "\\graphicspath{$argumento}";
- substr $cabeza, $pos_inicial, $pos_final-$pos_inicial, $cambio;
- pos($cabeza) = $pos_inicial + length $cambio;
+if ($preamble =~ m/($graphicspath)/m) {
+ while ($preamble =~ /$graphicspath /pgmx) {
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
+ if ($encontrado =~ /$graphicspath/) {
+ my $argumento = $1;
+ if ($argumento !~ /\{$imageDir\\\}/) {
+ $argumento .= "\{$imageDir/\}";
+ my $cambio = "\\graphicspath{$argumento}";
+ substr $preamble, $pos_inicial, $pos_final-$pos_inicial, $cambio;
+ pos($preamble) = $pos_inicial + length $cambio;
}
}
} #close while
### Regex to capture
-my ($GraphicsPath) = $cabeza =~ m/($graphicspath)/msx;
+my ($GraphicsPath) = $preamble =~ m/($graphicspath)/msx;
-### Append graphicspath to end of preamble
-$cabeza .= <<"EXTRA";
+### Append \graphicspath to end of preamble
+$preamble .= <<"EXTRA";
$GraphicsPath
\\usepackage{grfext}
\\PrependGraphicsExtensions*{.pdf}
EXTRA
- } # close if ($cabeza)
-else{
+ } # close if ($preamble)
+else {
### If preamble not contain graphicspath, append to premble
my $GraphicsPath = "\\graphicspath\{\{$imageDir/\}\}";
### Append graphicspath to end of preamble
-$cabeza .= <<"EXTRA";
+$preamble .= <<"EXTRA";
$GraphicsPath
\\usepackage{grfext}
\\PrependGraphicsExtensions*{.pdf}
@@ -1728,57 +1678,57 @@ EXTRA
} # close graphicspath
### Suport for \usepackage[swpl]{pst-exa}
-if(exists($pst_exa{swpl})){
-$cabeza .= <<'EXTRA';
+if (exists($pst_exa{swpl})) {
+$preamble .= <<'EXTRA';
\usepackage[swpl,pdf]{pst-exa}
EXTRA
}
### Suport for \usepackage[tcb]{pst-exa}
-if(exists($pst_exa{tcb})){
-$cabeza .= <<'EXTRA';
+if (exists($pst_exa{tcb})) {
+$preamble .= <<'EXTRA';
\usepackage[tcb,pdf]{pst-exa}
EXTRA
### Regex
-$cuerpo =~ s/(graphic=\{)\[(scale=\d*)\]($imageDir\/$name-$prefix-exa-\d*)\}/$1$2\}\{$3\}/gsmx;
+$bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imageDir\/$name-$prefix-exa-\d*)\}/$1$2\}\{$3\}/gsmx;
} # close if
### Options for out_file (add $end to outfile)
-my $out_file = $clean{doc} ? "$optin$cabeza$cuerpo\n\\end\{document\}"
- : "$optin$cabeza$cuerpo\n$final"
+my $out_file = $clean{doc} ? "$atbegindoc$preamble$bodydoc\n\\end\{document\}"
+ : "$atbegindoc$preamble$bodydoc\n$enddoc"
;
### Clean \psset content in output file
-if($clean{pst}){
-$out_file =~s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
- \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+if ($clean{pst}) {
+$out_file =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
+ \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
} # close clean
### Clean \tikzset content in output file
-if($clean{tkz}){
-$out_file =~s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
- \\tikzset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+if ($clean{tkz}) {
+$out_file =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
+ \\tikzset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
} # close clean
-### Back changues in all words in outfile
-$out_file =~s/\\begin\{nopreview\}\s*(.+?)\s*\\end\{nopreview\}/$1/gmsx;
-$out_file =~s/\%<\*ltximgverw>\s*(.+?)\s*\%<\/ltximgverw>/$1/gmsx;
-$out_file =~s/\%<\*noltximg>\n(.+?)\n\%<\/noltximg>/$1/gmsx;
-$out_file =~s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+### Revert changues in all words in outfile
+$out_file =~ s/\\begin\{nopreview\}\s*(.+?)\s*\\end\{nopreview\}/$1/gmsx;
+$out_file =~ s/\%<\*ltximgverw>\s*(.+?)\s*\%<\/ltximgverw>/$1/gmsx;
+$out_file =~ s/\%<\*noltximg>\n(.+?)\n\%<\/noltximg>/$1/gmsx;
+$out_file =~ s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))+//gmsx;
$out_file =~ s/($delt_env)(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
-$out_file =~s/($find)/$replace{$1}/g;
+$out_file =~ s/($find)/$replace{$1}/g;
### Write output file
open my $OUTfile, '>', "$output$ext";
-print $OUTfile "$out_file";
+ print $OUTfile "$out_file";
close $OUTfile;
### Process the output file
-if($run){
+if ($run) {
### Set correct $compiler, if input use latex then output use pdflatex
-$compiler = "pdflatex $opt_compiler" if $latex;
+$compiler = "pdflatex $opt_compiler" if $latex;
$msg_compiler = "pdflatex" if $latex;
### Compiling output file using pdflatex or arara
@@ -1786,20 +1736,18 @@ say "Compiling file $output$ext using $msg_compiler";
system("$compiler $output$ext $silence");
### Compiling output file using latex>dvips>ps2pdf
-if($dvips){
+if ($dvips) {
system("dvips -q -Ppdf $output.dvi");
system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $output.ps $output.pdf");
} # close dvips
### Compiling output file using latex>dvipdfmx
-if($dvipdf){
- system("dvipdfmx -q $output.dvi");
- } # close dvipdf
+if ($dvipdf) { system("dvipdfmx -q $output.dvi"); }
} # close run
} # close outfile file
-### Deleting temporary files
-if($run){
+### Remove temporary files
+if ($run) {
say "Deleting (most) temporary files created during the process";
my @protected = qw();
push (@protected,"$output$ext","$output.pdf") if defined $output;
@@ -1807,58 +1755,59 @@ push (@protected,"$output$ext","$output.pdf") if defined $output;
my $flsline = "OUTPUT";
my @flsfile;
-if ($PSTexa) {
-push @flsfile,"$name-$prefix-exa-$tmp.fls";
-}
-
-if ($STDenv) {
-push @flsfile,"$name-$prefix-$tmp.fls";
-}
-
-push(@flsfile,"$output.fls") if defined $output;
+if ($PSTexa) { push @flsfile,"$name-$prefix-exa-$tmp.fls"; }
+if ($STDenv) { push @flsfile,"$name-$prefix-$tmp.fls"; }
+push (@flsfile,"$output.fls") if defined $output;
my @tmpfiles;
for my $filename(@flsfile){
open my $RECtmp, '<', "$filename";
- push @tmpfiles, grep /^$flsline/,<$RECtmp>;
+ push @tmpfiles, grep /^$flsline/,<$RECtmp>;
close $RECtmp;
}
-foreach (@tmpfiles) {
- s/^$flsline\s+|\s+$//g;
-}
-
-if($latex or $dvips){
- push @tmpfiles,"$name-$prefix-$tmp.ps";
-}
-
-if(-e "$name-$prefix-$tmp.ps"){
- push @tmpfiles,"$name-$prefix-$tmp.ps";
-}
-
-if ($PSTexa) {
- push @tmpfiles,"$name-$prefix-exa-$tmp.ps";
-}
-
-if(-e "$output.ps"){
- push @tmpfiles,"$output.ps";
-}
+foreach (@tmpfiles) { s/^$flsline\s+|\s+$//g; }
+if ($latex or $dvips) { push @tmpfiles,"$name-$prefix-$tmp.ps"; }
+if (-e "$name-$prefix-$tmp.ps") { push @tmpfiles,"$name-$prefix-$tmp.ps"; }
+if ($PSTexa) { push @tmpfiles,"$name-$prefix-exa-$tmp.ps"; }
+if (-e "$output.ps") { push @tmpfiles,"$output.ps"; }
push @tmpfiles,@flsfile,"$name-$prefix-$tmp$ext","$name-$prefix-$tmp.pdf";
my @delfiles = array_minus(@tmpfiles, @protected);
+foreach my $tmpfile (@delfiles) { move("$tmpfile", "$tempDir"); }
+} # close clean tmp files
-foreach my $tmpfile (@delfiles){
- move("$tmpfile", "$tempDir");
+### Compress images dir whit generated files
+if ($zip or $tar) {
+my $stamp = strftime "%F", localtime;
+my $archivetar = "$imageDir-$stamp";
+
+my @savetozt;
+find(\&zip_tar, $imageDir);
+sub zip_tar{
+ my $filesto = $_;
+ if (-f $filesto && $filesto =~ m/$name-$prefix-.+?$/) { # buscamos
+ push @savetozt, $File::Find::name;
+ }
+}
+# Write compressed zip file
+if ($zip) {
+ say "Creating a file $workdir/$archivetar.zip";
+ zip \@savetozt => "$archivetar.zip";
}
-} # close clean tmp files
+
+# Write compressed tar.gz file
+if ($tar) {
+ say "Creating a file $workdir/$archivetar.tar.gz";
+ my $imgdirtar = Archive::Tar->new();
+ $imgdirtar->add_files( @savetozt );
+ $imgdirtar->write( "$archivetar.tar.gz" , 9 );
+ }
+} #close compress
### End of script process
-if($run){
- say "Finish, image formats: $format are in $workdir/$imageDir/";
- }
- else{
- say "Done";
-} # end run
+if ($run) { say "Finish, image formats: $format are in $workdir/$imageDir/"; }
+ else { say "Done"; }
__END__
diff --git a/Master/texmf-dist/doc/support/ltximg/CHANGUES.md b/Master/texmf-dist/doc/support/ltximg/CHANGUES.md
deleted file mode 100644
index c7ff7ea2fdd..00000000000
--- a/Master/texmf-dist/doc/support/ltximg/CHANGUES.md
+++ /dev/null
@@ -1,25 +0,0 @@
-## Changues
-```
- v1.5. (d) 2018-04-12 - Use GitHub to control version
- - Rewrite and optimize most part of code and options
- - Changue pdf2svg for pdftocairo
- - Complete support for pst-exa packpage
- - Clean take and optional
- v1.4. (d) 2016-11-29 - Remove and rewrite code for regex and system call
- - Append arara compiler, clean and comment code
- - Append dvips and dvipdfm for creation images
- - Append bmp, tif image format
- v1.3. (d) 2016-10-16 - All options its read from cmd line and input file
- - Rewrite some part of code (norun, nocrop, clean)
- - Suport minted and tcolorbox packpage for verbatim
- - Use /tmp dir for work process
- - Escape some characters in regex according to v5.2xx
- v1.2 (p) 2015-04-22 - Remove unused modules
- v1.1 (p) 2015-04-21 - Change mogrify to gs for image formats
- - Create output file
- - Rewrite source code and fix regex
- - Add more image format
- - Change date to iso format
- v1.0 (p) 2013-12-01 - First public release
-```
-Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
diff --git a/Master/texmf-dist/doc/support/ltximg/README.md b/Master/texmf-dist/doc/support/ltximg/README.md
index 2f56e3b6409..a04221a2310 100644
--- a/Master/texmf-dist/doc/support/ltximg/README.md
+++ b/Master/texmf-dist/doc/support/ltximg/README.md
@@ -8,11 +8,11 @@ to image formats in individual files using `ghostscript` and `poppler-utils`. Ge
with only extracted environments and other with environments converted to `\includegraphics`.
## Syntax
-```
+```bash
$ ltximg [<compiler>] [<options>] [--] <input file>.<tex|ltx>
```
## Usage
-```
+```bash
$ ltximg --latex [<options>] <file.tex>
$ ltximg --arara [<options>] <file.tex>
$ ltximg [<options>] <file.tex>
@@ -20,19 +20,19 @@ $ ltximg <file.tex>
```
If used without `[<compiler>]` and `[<options>]` the extracted environments are converted to `pdf` image format
and saved in the `/images` directory using `pdflatex` and `preview` package. Relative or absolute `paths` for files
-and directories is not supported and if the last `[<options>]` take a list separated by commas you need `--` at the end.
+and directories is not supported. If the last `[<options>]` take a *list separated by commas*, you need `--` at the end.
## Default environments extract
-```
+```bash
pspicture tikzpicture pgfpicture psgraph postscript PSTexample
```
## Options
-```
+```bash
[default]
-h, --help Display command line help and exit [off]
-l, --license Display GPL license and exit [off]
--v, --version Display current version (v1.5) and exit [off]
+-v, --version Display current version (1.6) and exit [off]
-t, --tif Create .tif files using ghostscript [gs]
-b, --bmp Create .bmp files using ghostscript [gs]
-j, --jpg Create .jpg files using ghostscript [gs]
@@ -48,6 +48,8 @@ and directories is not supported and if the last `[<options>]` take a list separ
-m <integer>, --margin <integer>
Set margins for pdfcrop [0]
--imgdir <dirname> Set name of directory to save images [images]
+--zip Compress files generated in .zip format [off]
+--tar Compress files generated in .tar.gz format [off]
-o <filename>, --output <filename>
Create output file [off]
--verbose Verbose printing [off]
@@ -75,14 +77,14 @@ and directories is not supported and if the last `[<options>]` take a list separ
--deltenv <env1,...> Delete environments in output file [empty]
```
## Example
-```
+```bash
$ ltximg --latex -e -p --srcenv --imgdir=mypics -o test-out test-in.ltx
```
-```
+```bash
$ ltximg --latex -ep --srcenv --imgdir mypics -o test-out test-in.ltx
```
Create a `/mypics` directory whit all extracted environments converted to
- image formats(`.pdf`, `.eps`, `.png`), individual files whit source code (`.tex`)
+ image formats (`.pdf`, `.eps`, `.png`), individual files whit source code (`.tex`)
for all extracted environments, a file `test-out.ltx` whit all environments converted to `\includegraphics`
and file `test-in-fig-all.tex` with only the extracted environments using
`latex>dvips>ps2pdf` and `preview` package for `<input file>` and `pdflatex`
@@ -90,9 +92,13 @@ $ ltximg --latex -ep --srcenv --imgdir mypics -o test-out test-in.ltx
## Documentation
For full documentation use:
-```
+```bash
$ texdoc ltximg
```
+ For recreation all documentation use:
+```bash
+$ arara ltximg-doc.dtx
+```
## Licence
This program is free software; you can redistribute it and/or modify it under the terms of the GNU
@@ -105,8 +111,8 @@ License for more details.
## Author
-Written by Pablo González L <pablgonz@yahoo.com>, last update 2018-04-12.
+Written by Pablo González L <pablgonz@yahoo.com>, last update 2019-07-13.
## Copyright
-Copyright 2013 - 2018 by Pablo González L
+Copyright 2013 - 2019 by Pablo González L
diff --git a/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf
index 86b856a5ed9..c862cfd8ba2 100644
--- a/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf
+++ b/Master/texmf-dist/doc/support/ltximg/ltximg-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/scripts/ltximg/ltximg.pl b/Master/texmf-dist/scripts/ltximg/ltximg.pl
index 738ccb51cc0..676c96fa72e 100755
--- a/Master/texmf-dist/scripts/ltximg/ltximg.pl
+++ b/Master/texmf-dist/scripts/ltximg/ltximg.pl
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
-use v5.22; # minimum version
+use v5.24;
use File::Basename;
use Getopt::Long qw(:config bundling_values require_order no_ignore_case);
use File::Temp qw(tempdir);
@@ -7,58 +7,62 @@ use File::Copy;
use Config;
use File::Spec::Functions qw(catfile devnull);
use File::Find;
+use IO::Compress::Zip qw(:all);
+use Archive::Tar;
+use POSIX qw(strftime);
use Cwd;
use autodie;
-#use Data::Dumper; # for test
+#use Data::Dumper;
-### Directory for work and tmp files
-my $tempDir = tempdir( CLEANUP => 1);
-my $tempSys = dirname($tempDir);
-my $workdir = cwd;
-my $null = devnull();
+### Directory for work and temp files
+my $tempDir = tempdir( CLEANUP => 1);
+my $workdir = cwd;
+my $null = devnull();
### Program identification
my $program = "LTXimg";
-my $nv='v1.5';
+my $nv = 'v1.6';
my $copyright = <<END_COPYRIGHT ;
-[2018-04-12] (c) 2013-2018 by Pablo Gonzalez, pablgonz<at>yahoo.com
+[2019-07-13] (c) 2013-2019 by Pablo Gonzalez, pablgonz<at>yahoo.com
END_COPYRIGHT
### Default values
-my $prefix = 'fig'; # defaul prefix for extract files
-my $skiptag = 'noltximg'; # internal tag for regex
-my $extrtag = 'ltximg'; # internal tag for regex
-my $imageDir = "images"; # dir for images
-my $verbcmd = "myverb"; # set \myverb command
-my $margins = "0"; # margins for pdfcrop
-my $DPI = "150"; # dpi for image formats
-my $arara = 0; # use arara to compiler
-my $force = 0; # force capture \psset|\tikzset
-my $latex = 0; # compiling all images using latex
-my $dvips = 0; # compiling output using dvips>ps2pdf
-my $dvipdf = 0; # compiling all images using dvipdfmx
-my $xetex = 0; # compiling all images using xelatex
-my $luatex = 0; # compiling all images using lualatex
-my $noprew = 0; # don't use preview packpage
-my $srcenv = 0; # create src code for environments
-my $subenv = 0; # create sub document for environments
-my @extr_env_tmp; # save extract environments
-my @skip_env_tmp; # save skip some environments
-my @verb_env_tmp; # save verbatim environments
-my @verw_env_tmp; # save verbatim write environments
-my @delt_env_tmp; # save delete environments in output file
-my @clean; # clean options
-my $pdf = 1; # create a PDF image file
-my $run = 1; # run mode compiler
-my $crop = 1; # croped pdf image files
-my $gray = 0; # create a gray scale images
-my $output; # set output name for outfile
-my $outfile = 0; # write output file
-my $outsrc = 0; # enable write src env files
-my $debug = 0; # debug
-my $PSTexa = 0; # extract PSTexample environment
-my $STDenv = 0; # extract standart environments
-my $verbose = 0; # verbose
+my $prefix = 'fig'; # defaul prefix for extract files
+my $skiptag = 'noltximg'; # internal tag for regex
+my $extrtag = 'ltximg'; # internal tag for regex
+my $imageDir = "images"; # dir for images
+my $verbcmd = "myverb"; # set \myverb command
+my $margins = "0"; # margins for pdfcrop
+my $DPI = "150"; # dpi for image formats
+my $zip = 0; # zip images dir
+my $tar = 0; # tar.gz images dir
+my $arara = 0; # use arara to compiler
+my $force = 0; # force capture \psset|\tikzset
+my $latex = 0; # compiling all images using latex
+my $dvips = 0; # compiling output using dvips>ps2pdf
+my $dvipdf = 0; # compiling all images using dvipdfmx
+my $xetex = 0; # compiling all images using xelatex
+my $luatex = 0; # compiling all images using lualatex
+my $noprew = 0; # don't use preview packpage
+my $srcenv = 0; # create src code for environments
+my $subenv = 0; # create sub document for environments
+my @extr_env_tmp; # save extract environments
+my @skip_env_tmp; # save skip some environments
+my @verb_env_tmp; # save verbatim environments
+my @verw_env_tmp; # save verbatim write environments
+my @delt_env_tmp; # save delete environments in output file
+my @clean; # clean options
+my $pdf = 1; # create a PDF image file
+my $run = 1; # run mode compiler
+my $crop = 1; # croped pdf image files
+my $gray = 0; # create a gray scale images
+my $output; # set output name for outfile
+my $outfile = 0; # write output file
+my $outsrc = 0; # enable write src env files
+my $debug = 0; # debug
+my $PSTexa = 0; # extract PSTexample environment
+my $STDenv = 0; # extract standart environments
+my $verbose = 0; # verbose
### Search Ghostscript
# The next code it's part of pdfcrop adapted from TexLive 2014
@@ -241,9 +245,7 @@ sub SearchRegistry () {
} # end GS search
### If windows
-if ($Win and $gscmd =~ /\s/) {
- $gscmd = "\"$gscmd\"";
-}
+if ($Win and $gscmd =~ /\s/) { $gscmd = "\"$gscmd\"";}
### Call GS
find_ghostscript();
@@ -283,8 +285,8 @@ ${title}** Description **
If used without [<compiler>] and [<options>] the extracted environments
are converted to pdf image format and saved in the "/images" directory
using "pdflatex" and "preview" package. Relative or absolute paths for
- directories and files is not supported, if the last option take a list
- separated by commas you need -- at the end.
+ directories and files is not supported. If the last option take a list
+ separated by commas, you need -- at the end.
** Default environments extract **
pspicture tikzpicture pgfpicture psgraph postscript PSTexample
@@ -309,6 +311,8 @@ ${title}** Description **
-m <integer>, --margin <integer>
Set margins for pdfcrop [0]
--imgdir <dirname> Set name of directory to save images [images]
+--zip Compress files generated in .zip format [off]
+--tar Compress files generated in .tar.gz format [off]
-o <filename>, --output <filename>
Create output file [off]
--verbose Verbose printing [off]
@@ -354,7 +358,7 @@ END_OF_USAGE
### Error in command line
sub errorUsage { die "@_ (try ltximg --help for more information)\n"; }
-### Getopt::Long configuration
+### Getopt::Long configuration for command line
my %opts_cmd;
my $result=GetOptions (
@@ -384,6 +388,8 @@ my $result=GetOptions (
'luatex' => \$luatex, # lualatex compiler
'dvips' => \$dvips, # dvips compiler
'dvipdf' => \$dvipdf, # dvipdfmx compiler
+ 'zip' => \$zip, # zip images dir
+ 'tar' => \$tar, # tar images dir
# string options from command line
'extrenv=s{1,9}' => \@extr_env_tmp, # extract environments
'skipenv=s{1,9}' => \@skip_env_tmp, # skip environment
@@ -418,37 +424,37 @@ s/^\s*(\=):?|\s*//mg foreach @delt_env_tmp;
@delt_env_tmp = split(/,/,join('',@delt_env_tmp));
### Validate input string options
-if ( grep( /(^\-|^\.).*?/, @extr_env_tmp ) ) {
- die errorUsage "Invalid option for --extrenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @extr_env_tmp )) {
+ die errorUsage "Invalid argument for --extrenv option";
}
-if ( grep( /(^\-|^\.).*?/, @skip_env_tmp ) ) {
- die errorUsage "Invalid option for --skipenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @skip_env_tmp )) {
+ die errorUsage "Invalid argument for --skipenv option";
}
-if ( grep( /(^\-|^\.).*?/, @verb_env_tmp ) ) {
- die errorUsage "Invalid option for --verbenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @verb_env_tmp )) {
+ die errorUsage "Invalid argument for --verbenv option";
}
-if ( grep( /(^\-|^\.).*?/, @verw_env_tmp ) ) {
- die errorUsage "Invalid option for --verwenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @verw_env_tmp )) {
+ die errorUsage "Invalid argument for --writenv option";
}
-if ( grep( /(^\-|^\.).*?/, @delt_env_tmp ) ) {
- die errorUsage "Invalid option for --deltenv, invalid environment name";
+if (grep( /(^\-|^\.).*?/, @delt_env_tmp )) {
+ die errorUsage "Invalid argument for --deltenv option";
}
### Help
-if (defined $opts_cmd{help}){
+if (defined $opts_cmd{help}) {
find_ghostscript();
print $usage;
exit(0);
}
### Version
-if (defined $opts_cmd{version}){
+if (defined $opts_cmd{version}) {
print $title;
exit(0);
}
### Licence
-if (defined $opts_cmd{license}){
+if (defined $opts_cmd{license}) {
print $licensetxt;
exit(0);
}
@@ -458,7 +464,7 @@ my $tmp = "$$";
### Check --srcenv and --subenv option from command line
if ($srcenv && $subenv) {
- die errorUsage "--srcenv and --subenv options are mutually exclusive";
+ die errorUsage "--srcenv and --subenv options are mutually exclusive";
}
### Check the input file from command line
@@ -472,10 +478,10 @@ $ext = '.tex' if not $ext;
### Read input file in memory (slurp), need :crlf for windows/linux
open my $INPUTfile, '<:crlf', "$name$ext";
-my $archivo;
+my $ltxfile;
{
local $/;
- $archivo = <$INPUTfile>;
+ $ltxfile = <$INPUTfile>;
}
close $INPUTfile;
@@ -492,134 +498,134 @@ sub array_minus(\@\@) {
}
### Funtion to create hash begin -> BEGIN, end -> END
-sub crearhash{
+sub crearhash {
my %cambios;
for my $aentra(@_){
- for my $initend (qw(begin end)) {
- $cambios{"\\$initend\{$aentra"} = "\\\U$initend\E\{$aentra";
+ for my $initend (qw(begin end)) {
+ $cambios{"\\$initend\{$aentra"} = "\\\U$initend\E\{$aentra";
}
}
return %cambios;
}
### Default environment to extract
-my @extr_tmp = qw (
- postscript tikzpicture pgfpicture pspicture psgraph
- );
+my @extr_tmp = qw (
+ postscript tikzpicture pgfpicture pspicture psgraph
+ );
-push(@extr_env_tmp,@extr_tmp);
+push (@extr_env_tmp, @extr_tmp);
### Default verbatim environment
-my @verb_tmp = qw (
- Example CenterExample SideBySideExample PCenterExample PSideBySideExample
- verbatim Verbatim BVerbatim LVerbatim SaveVerbatim PSTcode
- LTXexample tcblisting spverbatim minted listing lstlisting
- alltt comment chklisting verbatimtab listingcont boxedverbatim
- demo sourcecode xcomment pygmented pyglist program programl
- programL programs programf programsc programt
- );
+my @verb_tmp = qw (
+ Example CenterExample SideBySideExample PCenterExample PSideBySideExample
+ verbatim Verbatim BVerbatim LVerbatim SaveVerbatim PSTcode
+ LTXexample tcblisting spverbatim minted listing lstlisting
+ alltt comment chklisting verbatimtab listingcont boxedverbatim
+ demo sourcecode xcomment pygmented pyglist program programl
+ programL programs programf programsc programt
+ );
-push(@verb_env_tmp,@verb_tmp);
+push (@verb_env_tmp, @verb_tmp);
### Default verbatim write environment
my @verbw_tmp = qw (
- filecontents tcboutputlisting tcbexternal extcolorbox extikzpicture
- VerbatimOut verbatimwrite PSTexample filecontentsdef filecontentshere
- );
+ filecontents tcboutputlisting tcbexternal tcbwritetmp extcolorbox extikzpicture
+ VerbatimOut verbatimwrite PSTexample filecontentsdef filecontentshere
+ );
-push(@verw_env_tmp,@verbw_tmp);
+push (@verw_env_tmp, @verbw_tmp);
### Rules to capture in regex
-my $braces = qr/ (?:\{)(.+?)(?:\}) /msx;
-my $braquet = qr/ (?:\[)(.+?)(?:\]) /msx;
-my $no_corchete = qr/ (?:\[ .+? \])? /msx;
+my $braces = qr/ (?:\{)(.+?)(?:\}) /msx;
+my $braquet = qr/ (?:\[)(.+?)(?:\]) /msx;
+my $no_corchete = qr/ (?:\[ .*? \])? /msx;
### Capture new verbatim environments defined in input file
my @new_verb = qw (
- newtcblisting DeclareTCBListing ProvideTCBListing NewTCBListing
- lstnewenvironment NewListingEnvironment NewProgram specialcomment
- includecomment DefineVerbatimEnvironment newverbatim newtabverbatim
- );
+ newtcblisting DeclareTCBListing ProvideTCBListing NewTCBListing
+ lstnewenvironment NewListingEnvironment NewProgram specialcomment
+ includecomment DefineVerbatimEnvironment newverbatim newtabverbatim
+ );
### Regex to capture names for new verbatim environments from input file
my $newverbenv = join "|", map quotemeta, sort { length $a <=> length $b } @new_verb;
-$newverbenv = qr/\b(?:$newverbenv) $no_corchete $braces/msx;
+ $newverbenv = qr/\b(?:$newverbenv) $no_corchete $braces/msx;
### Capture new verbatim write environments defined in input file
my @new_verb_write = qw (
- renewtcbexternalizetcolorbox renewtcbexternalizeenvironment
- newtcbexternalizeenvironment newtcbexternalizetcolorbox
- );
+ renewtcbexternalizetcolorbox renewtcbexternalizeenvironment
+ newtcbexternalizeenvironment newtcbexternalizetcolorbox
+ );
### Regex to capture names for new verbatim write environments from input file
my $newverbwrt = join "|", map quotemeta, sort { length $a <=> length $b } @new_verb_write;
-$newverbwrt = qr/\b(?:$newverbwrt) $no_corchete $braces/msx;
+ $newverbwrt = qr/\b(?:$newverbwrt) $no_corchete $braces/msx;
### Regex to capture MINTED related environments
-my $mintdenv = qr/\\ newminted $braces (?:\{.+?\}) /x;
-my $mintcenv = qr/\\ newminted $braquet (?:\{.+?\}) /x;
-my $mintdshrt = qr/\\ newmint $braces (?:\{.+?\}) /x;
-my $mintcshrt = qr/\\ newmint $braquet (?:\{.+?\}) /x;
-my $mintdline = qr/\\ newmintinline $braces (?:\{.+?\}) /x;
-my $mintcline = qr/\\ newmintinline $braquet (?:\{.+?\}) /x;
+my $mintdenv = qr/\\ newminted $braces (?:\{.+?\}) /x;
+my $mintcenv = qr/\\ newminted $braquet (?:\{.+?\}) /x;
+my $mintdshrt = qr/\\ newmint $braces (?:\{.+?\}) /x;
+my $mintcshrt = qr/\\ newmint $braquet (?:\{.+?\}) /x;
+my $mintdline = qr/\\ newmintinline $braces (?:\{.+?\}) /x;
+my $mintcline = qr/\\ newmintinline $braquet (?:\{.+?\}) /x;
### Pass input file to @array and remove % and comments
-my @verbinput = $archivo;
-s/%.*\n//mg foreach @verbinput; # del comments
-s/^\s*|\s*//mg foreach @verbinput; # del white space
-my $verbinput = join '', @verbinput;
+my @filecheck = $ltxfile;
+s/%.*\n//mg foreach @filecheck; # del comments
+s/^\s*|\s*//mg foreach @filecheck; # del white space
+my $filecheck = join '', @filecheck;
### Capture \newverbatim write names in input file
-my @newv_write = $verbinput =~ m/$newverbwrt/xg;
+my @newv_write = $filecheck =~ m/$newverbwrt/xg;
### Add @newv_write defined in input file to @verw_env_tmp
-push(@verw_env_tmp,@newv_write);
+push (@verw_env_tmp, @newv_write);
### Capture \newminted{$mintdenv}{options} (for)
-my @mint_denv = $verbinput =~ m/$mintdenv/xg;
+my @mint_denv = $filecheck =~ m/$mintdenv/xg;
### Capture \newminted[$mintcenv]{lang} (for)
-my @mint_cenv = $verbinput =~ m/$mintcenv/xg;
+my @mint_cenv = $filecheck =~ m/$mintcenv/xg;
### Capture \newmint{$mintdshrt}{options} (while)
-my @mint_dshrt = $verbinput =~ m/$mintdshrt/xg;
+my @mint_dshrt = $filecheck =~ m/$mintdshrt/xg;
### Capture \newmint[$mintcshrt]{lang}{options} (while)
-my @mint_cshrt = $verbinput =~ m/$mintcshrt/xg;
+my @mint_cshrt = $filecheck =~ m/$mintcshrt/xg;
### Capture \newmintinline{$mintdline}{options} (while)
-my @mint_dline = $verbinput =~ m/$mintdline/xg;
+my @mint_dline = $filecheck =~ m/$mintdline/xg;
### Capture \newmintinline[$mintcline]{lang}{options} (while)
-my @mint_cline = $verbinput =~ m/$mintcline/xg;
+my @mint_cline = $filecheck =~ m/$mintcline/xg;
### Capture \newverbatim environments in input file (for)
-my @verb_input = $verbinput =~ m/$newverbenv/xg;
+my @verb_input = $filecheck =~ m/$newverbenv/xg;
### Add new verbatim environment defined in input file to @vrbenv
-push(@verb_env_tmp,@mint_denv,@mint_cenv,@verb_input);
+push (@verb_env_tmp,@mint_denv,@mint_cenv,@verb_input);
### Append "code" (minted)
-if (!@mint_denv == 0){
-$mintdenv = join "\n", map { qq/$_\Qcode\E/ } @mint_denv;
-@mint_denv = split /\n/, $mintdenv;
+if (!@mint_denv == 0) {
+ $mintdenv = join "\n", map { qq/$_\Qcode\E/ } @mint_denv;
+ @mint_denv = split /\n/, $mintdenv;
}
### Append "inline" (minted)
-if (!@mint_dline == 0){
-$mintdline = join "\n", map { qq/$_\Qinline\E/ } @mint_dline;
-@mint_dline = split /\n/, $mintdline;
+if (!@mint_dline == 0) {
+ $mintdline = join "\n", map { qq/$_\Qinline\E/ } @mint_dline;
+ @mint_dline = split /\n/, $mintdline;
}
### Join all minted inline/short and lstinline in @array
my @mintline;
-my @mint_tmp = qw ( mint mintinline lstinline);
-push(@mintline,@mint_dline,@mint_cline,@mint_dshrt,@mint_cshrt,@mint_tmp);
-@mintline = uniq(@mintline);
+my @mint_tmp = qw ( mint mintinline lstinline);
+push (@mintline,@mint_dline,@mint_cline,@mint_dshrt,@mint_cshrt,@mint_tmp);
+ @mintline = uniq(@mintline);
### Create a regex using @mintline
my $mintline = join "|", map quotemeta, sort { length $a <=> length $b } @mintline;
-$mintline = qr/\b(?:$mintline)/x;
+ $mintline = qr/\b(?:$mintline)/x;
### Options from input file
# % ltximg : extrenv : {extrenv1, extrenv2, ... , extrenvn}
@@ -629,8 +635,8 @@ $mintline = qr/\b(?:$mintline)/x;
# % ltximg : deltenv : {deltenv1, deltenv2, ... , deltenvn}
# % ltximg : options : {opt1=arg, opt2=arg, ... , bolean}
-### Regex to capture before preamble
-my $rx_myscrypt = qr/
+### Regex to capture before preamble $readoptfile, %opt_from_file;
+my $readoptfile = qr/
^ %+ \s* ltximg (?&SEPARADOR) (?<clave>(?&CLAVE)) (?&SEPARADOR) \{ (?<argumentos>(?&ARGUMENTOS)) \}
(?(DEFINE)
(?<CLAVE> \w+ )
@@ -639,35 +645,33 @@ my $rx_myscrypt = qr/
)
/mx;
-### Split input file, $optin contain % ltximg : <argument>
-my($optin, $documento) = $archivo =~ m/\A (\s* .*? \s*) (\\documentclass.*)\z/msx;
+### Split input file, $atbegindoc contain % ltximg : <argument>
+my ($atbegindoc, $document) = $ltxfile =~ m/\A (\s* .*? \s*) (\\documentclass.*)\z/msx;
### Process options from input file
my %opts_file;
-while ($optin =~ /$rx_myscrypt/g) {
- my($clave, $argumentos) = @+{qw(clave argumentos)};
- my @argumentos = split /\s*,\s*?/, $argumentos;
- for (@argumentos) {
- s/^ \s* | \s* $//gx;
- }
- if ($clave eq 'options') {
- for my $argumento (@argumentos) {
- if ($argumento =~ /(?<key>\S+) \s* = \s* (?<valor>\S+)/x) {
- $opts_file{$clave}{$+{'key'}} = $+{'valor'};
- } # close for
- else {
- $opts_file{$clave}{$argumento} = 1;
- }
+while ($atbegindoc =~ /$readoptfile/g) {
+ my ($clave, $argumentos) = @+{qw(clave argumentos)};
+ my @argumentos = split /\s*,\s*?/, $argumentos;
+ for (@argumentos) { s/^ \s* | \s* $//gx; }
+ if ($clave eq 'options') {
+ for my $argumento (@argumentos) {
+ if ($argumento =~ /(?<key>\S+) \s* = \s* (?<valor>\S+)/x) {
+ $opts_file{$clave}{$+{'key'}} = $+{'valor'};
+ } # close for
+ else {
+ $opts_file{$clave}{$argumento} = 1;
+ }
} # close for
- } # close if
- else {
- push @{ $opts_file{ $clave } }, @argumentos;
- }
+ } # close if
+ else {
+ push @{ $opts_file{ $clave } }, @argumentos;
+ }
} # close while
### Validate clean
-my %clean = map { $_ => 1 } @clean;
+my %clean = map { $_ => 1 } @clean;
### By default clean = doc
$clean{doc} = 1 ;
@@ -680,50 +684,44 @@ $clean{tkz} = 1 if ($opts_file{options}{clean} eq 'tkz');
$clean{all} = 1 if ($opts_file{options}{clean} eq 'all');
### Set clean options for script
-if ($clean{pst} or $clean{tikz}) {
- $clean{doc} = 1;
-}
-if ($clean{all}) {
- @clean{qw(pst doc tkz)} = (1) x 3;
-}
-if ($clean{off}) {
- undef %clean;
-}
+if ($clean{pst} or $clean{tikz}) { $clean{doc} = 1; }
+if ($clean{all}) { @clean{qw(pst doc tkz)} = (1) x 3; }
+if ($clean{off}) { undef %clean; }
### Add extract options from input file
-if (exists $opts_file{extract} ) {
+if (exists $opts_file{extract}) {
push @extr_env_tmp, @{ $opts_file{extract} };
}
### Add skipenv options from input file
-if (exists $opts_file{skipenv} ) {
+if (exists $opts_file{skipenv}) {
push @skip_env_tmp, @{ $opts_file{skipenv} };
}
### Add verbenv options from input file
-if (exists $opts_file{verbenv} ) {
+if (exists $opts_file{verbenv}) {
push @verb_env_tmp, @{ $opts_file{verbenv} };
}
### Add writenv options from input file
-if (exists $opts_file{writenv} ) {
+if (exists $opts_file{writenv}) {
push @verw_env_tmp, @{ $opts_file{writenv} };
}
### Add deltenv options from input file
-if (exists $opts_file{deltenv} ) {
+if (exists $opts_file{deltenv}) {
push @delt_env_tmp, @{ $opts_file{deltenv} };
}
### Set \myverb|<code>| options from input file
-if (exists $opts_file{options}{verbcmd}){
+if (exists $opts_file{options}{verbcmd}) {
$verbcmd = $opts_file{options}{verbcmd};
}
### Create @env_all_tmp contain all environments
my @env_all_tmp;
push(@env_all_tmp,@extr_env_tmp,@skip_env_tmp,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
-@env_all_tmp = uniq(@env_all_tmp);
+@env_all_tmp = uniq(@env_all_tmp);
### Create @no_env_all_tmp contain all No extracted environments
my @no_env_all_tmp;
@@ -732,21 +730,21 @@ push(@no_env_all_tmp,@skip_env_tmp,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
### The operation return @extract environment
my @extract = array_minus(@env_all_tmp,@no_env_all_tmp);
-@extract = uniq(@extract);
+ @extract = uniq(@extract);
### The operation return @no_extract
my @no_extract = array_minus(@env_all_tmp,@extract);
my @no_skip;
push(@no_skip,@verb_env_tmp,@verw_env_tmp,@delt_env_tmp);
my @skipped = array_minus(@no_extract,@no_skip);
-@skipped = uniq(@skipped);
+ @skipped = uniq(@skipped);
### The operation return @delte_env environment
my @no_ext_skip = array_minus(@no_extract,@skipped);
my @no_del;
push(@no_del,@verb_env_tmp,@verw_env_tmp);
my @delete_env = array_minus(@no_ext_skip,@no_del);
-@delete_env = uniq(@delete_env);
+ @delete_env = uniq(@delete_env);
### The operation return @verbatim environment
my @no_ext_skip_del = array_minus(@no_ext_skip,@delete_env);
@@ -764,47 +762,47 @@ push(@no_verw_env,@extract,@skipped,@delete_env,@verbatim);
### Reserved words in verbatim inline (while)
my %changes_in = (
# ltximg tags
- '%<*ltximg>' => '%<*LTXIMG>',
- '%</ltximg>' => '%</LTXIMG>',
- '%<*noltximg>' => '%<*NOLTXIMG>',
- '%</noltximg>' => '%</NOLTXIMG>',
- '%<*remove>' => '%<*REMOVE>',
- '%</remove>' => '%</REMOVE>',
- '%<*ltximgverw>' => '%<*LTXIMGVERW>',
- '%</ltximgverw>' => '%</LTXIMGVERW>',
+ '%<*ltximg>' => '%<*LTXIMG>',
+ '%</ltximg>' => '%</LTXIMG>',
+ '%<*noltximg>' => '%<*NOLTXIMG>',
+ '%</noltximg>' => '%</NOLTXIMG>',
+ '%<*remove>' => '%<*REMOVE>',
+ '%</remove>' => '%</REMOVE>',
+ '%<*ltximgverw>' => '%<*LTXIMGVERW>',
+ '%</ltximgverw>' => '%</LTXIMGVERW>',
# pst/tikz set
- '\psset' => '\PSSET',
- '\tikzset' => '\TIKZSET',
+ '\psset' => '\PSSET',
+ '\tikzset' => '\TIKZSET',
# pspicture
- '\pspicture' => '\TRICKS',
- '\endpspicture' => '\ENDTRICKS',
+ '\pspicture' => '\TRICKS',
+ '\endpspicture' => '\ENDTRICKS',
# pgfpicture
- '\pgfpicture' => '\PGFTRICKS',
- '\endpgfpicture' => '\ENDPGFTRICKS',
+ '\pgfpicture' => '\PGFTRICKS',
+ '\endpgfpicture' => '\ENDPGFTRICKS',
# tikzpicture
- '\tikzpicture' => '\TKZTRICKS',
- '\endtikzpicture' => '\ENDTKZTRICKS',
+ '\tikzpicture' => '\TKZTRICKS',
+ '\endtikzpicture' => '\ENDTKZTRICKS',
# psgraph
- '\psgraph' => '\PSGRAPHTRICKS',
- '\endpsgraph' => '\ENDPSGRAPHTRICKS',
+ '\psgraph' => '\PSGRAPHTRICKS',
+ '\endpsgraph' => '\ENDPSGRAPHTRICKS',
# some reserved
- '\usepackage' => '\USEPACKAGE',
- '{graphicx}' => '{GRAPHICX}',
- '\graphicspath{' => '\GRAPHICSPATH{',
+ '\usepackage' => '\USEPACKAGE',
+ '{graphicx}' => '{GRAPHICX}',
+ '\graphicspath{' => '\GRAPHICSPATH{',
);
-### Changues for \begin... \end inline verbatim
+### Changues \begin... \end in verbatim inline
my %init_end = (
# begin{ and end{
- '\begin{' => '\BEGIN{',
- '\end{' => '\END{',
+ '\begin{' => '\BEGIN{',
+ '\end{' => '\END{',
);
### Changues for \begin{document} ... \end{document}
my %document = (
# begin/end document for split
- '\begin{document}' => '\BEGIN{document}',
- '\end{document}' => '\END{document}',
+ '\begin{document}' => '\BEGIN{document}',
+ '\end{document}' => '\END{document}',
);
### Reverse for extract and output file
@@ -839,27 +837,27 @@ my %changes_out = (
### Reverse tags, need back in all file to extract
my %reverse_tag = (
# ltximg tags
- '%<*LTXIMG>' => '%<*ltximg>',
- '%</LTXIMG>' => '%</ltximg>',
- '%<*NOLTXIMG>' => '%<*noltximg>',
- '%</NOLTXIMG>' => '%</noltximg>',
- '%<*REMOVE>' => '%<*remove>',
- '%</REMOVE>' => '%</remove>',
- '%<*LTXIMGVERW>' => '%<*ltximgverw>',
- '%</LTXIMGVERW>' => '%</ltximgverw>',
+ '%<*LTXIMG>' => '%<*ltximg>',
+ '%</LTXIMG>' => '%</ltximg>',
+ '%<*NOLTXIMG>' => '%<*noltximg>',
+ '%</NOLTXIMG>' => '%</noltximg>',
+ '%<*REMOVE>' => '%<*remove>',
+ '%</REMOVE>' => '%</remove>',
+ '%<*LTXIMGVERW>' => '%<*ltximgverw>',
+ '%</LTXIMGVERW>' => '%</ltximgverw>',
);
### Creatate a hash for changues
-my %extract_env = crearhash(@extract);
-my %skiped_env = crearhash(@skipped);
-my %verb_env = crearhash(@verbatim);
-my %verbw_env = crearhash(@verbatim_w);
-my %delete_env = crearhash(@delete_env);
+my %extract_env = crearhash(@extract);
+my %skiped_env = crearhash(@skipped);
+my %verb_env = crearhash(@verbatim);
+my %verbw_env = crearhash(@verbatim_w);
+my %delete_env = crearhash(@delete_env);
my %change_verbw_env = crearhash(@no_verw_env);
my %change_verb_env = crearhash(@no_verb_env);
### Join changues in new hash
-my %cambios = (%changes_in,%init_end);
+my %cambios = (%changes_in, %init_end);
### Variables y constantes
my $no_del = "\0";
@@ -869,9 +867,9 @@ my $del = $no_del;
my $llaves = qr/\{ .+? \} /x;
my $no_llaves = qr/(?: $llaves )? /x;
my $corchetes = qr/\[ .+? \] /x;
-my $anidado = qr/(\{(?:[^\{\}]++|(?1))*\}) /x;
+my $nestedbr = qr/(\{(?:[^\{\}]++|(?1))*\}) /x;
my $delimitador = qr/\{ (?<del>.+?) \} /x;
-my $verb = qr/(?:((spv|(?:q|f)?v|V)erb|$verbcmd)[*]?) /ix;
+my $verb = qr/(?:((spv|(?:q|f)?v|V)erb|$verbcmd)[*]?) /ix;
my $lst = qr/(?:(lst|pyg)inline)(?!\*) $no_corchete /ix;
my $mint = qr/(?: $mintline |SaveVerb) (?!\*) $no_corchete $no_llaves $llaves /ix;
my $no_mint = qr/(?: $mintline) (?!\*) $no_corchete /ix;
@@ -880,16 +878,16 @@ my $comentario = qr/^ \s* \%+ .+? $
my $definedel = qr/\\ (?: DefineShortVerb | lstMakeShortInline| MakeSpecialShortVerb ) [*]? $no_corchete $delimitador /ix;
my $indefinedel = qr/\\ (?: (Undefine|Delete)ShortVerb | lstDeleteShortInline) $llaves /ix;
-### Changues in input file in memory
-while ($documento =~
- / $marca
- | $comentario
- | $definedel
- | $indefinedel
- | $del .+? $del
+### Changues in input file (in memory)
+while ($document =~
+ / $marca
+ | $comentario
+ | $definedel
+ | $indefinedel
+ | $del .+? $del
/pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
if ($encontrado =~ /$definedel/) {
$del = $+{del};
$del = "\Q$+{del}" if substr($del,0,1) ne '\\';
@@ -899,160 +897,160 @@ while ($documento =~
}
else {
while (my($busco, $cambio) = each %cambios) {
- $encontrado =~ s/\Q$busco\E/$cambio/g;
- }
- substr $documento, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
- pos($documento) = $pos_inicial + length $encontrado;
+ $encontrado =~ s/\Q$busco\E/$cambio/g;
+ } # close while
+ substr $document, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
+ pos ($document) = $pos_inicial + length $encontrado;
}
}
### Regex for verbatim inline whit braces {...}
-my $mintd_ani = qr/\\ (?:$mintline|pygment) (?!\*) $no_corchete $no_llaves /x;
-my $tcbxverb = qr/\\ (?: tcboxverb [*]?|$verbcmd [*]?|lstinline) $no_corchete /x;
-my $tcbxmint = qr/(?:$tcbxverb|$mintd_ani) (?:\s*)? $anidado /x;
-
-### Changue \verb*{code} inline
-while ($documento =~ /$tcbxmint/pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
+my $fvextra = qr /\\ (?: (Save|Esc)Verb [*]?) $no_corchete /x;
+my $mintedbr = qr /\\ (?:$mintline|pygment) (?!\*) $no_corchete $no_llaves /x;
+my $tcbxverb = qr /\\ (?: tcboxverb [*]?|$verbcmd [*]?|lstinline) $no_corchete /x;
+my $verb_brace = qr / (?:$tcbxverb|$mintedbr|$fvextra) (?:\s*)? $nestedbr /x;
+
+### Changue \verb*{code} for verbatim inline
+while ($document =~ /$verb_brace/pgmx) {
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
while (my($busco, $cambio) = each %cambios) {
- $encontrado =~ s/\Q$busco\E/$cambio/g;
- } # close while
- substr $documento, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
- pos($documento)= $pos_inicial + length $encontrado;
+ $encontrado =~ s/\Q$busco\E/$cambio/g;
+ } # close while
+ substr $document, $pos_inicial, $pos_final-$pos_inicial, $encontrado;
+ pos ($document) = $pos_inicial + length $encontrado;
} # close while
-### Changue <*TAGS> to <*tags> in file
-my $ltxtags = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %reverse_tag;
-$documento =~ s/^($ltxtags)/$reverse_tag{$1}/gmsx;
+### Changue <*TAGS> to <*tags>
+my $ltxtags = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %reverse_tag;
+ $document =~ s/^($ltxtags)/$reverse_tag{$1}/gmsx;
-### Defined environments Verbatim standart
+### Define environments Verbatim standart
my $verbatim = join "|", map quotemeta, sort { length $a <=> length $b } @verbatim;
-$verbatim = qr/$verbatim/x;
+ $verbatim = qr/$verbatim/x;
-### Defined environments Verbatim write
+### Define environments Verbatim write
my $verbatim_w = join "|", map quotemeta, sort { length $a <=> length $b } @verbatim_w;
-$verbatim_w = qr/$verbatim_w/x;
+ $verbatim_w = qr/$verbatim_w/x;
### Define environments to skip
my $skipenv = join "|", map quotemeta, sort { length $a <=> length $b } @skipped;
-$skipenv = qr/$skipenv/x;
+ $skipenv = qr/$skipenv/x;
### Define environments to extract
my $environ = join "|", map quotemeta, sort { length $a <=> length $b } @extract;
-$environ = qr/$environ/x;
+ $environ = qr/$environ/x;
### Define environments to delete
my $delenv = join "|", map quotemeta, sort { length $a <=> length $b } @delt_env_tmp;
-$delenv = qr/$delenv/x;
+ $delenv = qr/$delenv/x;
### Split file by lines
-my @lineas = split /\n/, $documento;
+my @lineas = split /\n/, $document;
### Hash and Regex for changues
my %replace = (%change_verb_env,%changes_in,%document);
-my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
### Change in $verbatim and $verbatim_w
my $DEL;
for (@lineas) {
if (/\\begin\{($verbatim\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
my %replace = (%change_verbw_env,%changes_in,%document);
- my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
- s/($find)/$replace{$1}/g;
- }
+ my $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $documento
-$documento = join("\n", @lineas);
+### Join lines in $document
+$document = join("\n", @lineas);
### Split input file
-my($cabeza,$cuerpo,$final) = $documento =~ m/\A (.+?) (\\begin\{document\} .+?)(\\end\{document\}.*)\z/msx;
+my ($preamble,$bodydoc,$enddoc) = $document =~ m/\A (.+?) (\\begin\{document\} .+?)(\\end\{document\}.*)\z/msx;
### Regex for delete environment
my $delt_env = qr /
- (
- (?:
- \\begin\{$delenv\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$delenv\*?\})
- (?!end\{$delenv\*?\})|
- (?-1)
- )*
- \\end\{$delenv\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$delenv\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$delenv\*?\})
+ (?!end\{$delenv\*?\})|
+ (?-1)
+ )*
+ \\end\{$delenv\*?\}
+ )
+ )
+ /x;
### Regex for verbatim write environment
my $verb_wrt = qr /
- (
- (?:
- \\begin\{$verbatim_w\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$verbatim_w\*?\})
- (?!end\{$verbatim_w\*?\})|
- (?-1)
- )*
- \\end\{$verbatim_w\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$verbatim_w\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$verbatim_w\*?\})
+ (?!end\{$verbatim_w\*?\})|
+ (?-1)
+ )*
+ \\end\{$verbatim_w\*?\}
+ )
+ )
+ /x;
### Pass $verb_wrt to %<*ltximgverw> ... %</ltximgverw>
-$cuerpo =~ s/($verb_wrt)/\%<\*ltximgverw>\n$1\n\%<\/ltximgverw>/gmsx;
+$bodydoc =~ s/($verb_wrt)/\%<\*ltximgverw>\n$1\n\%<\/ltximgverw>/gmsx;
### Regex for skip environment
my $skip_env = qr /
- (
- (?:
- \\begin\{$skipenv\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$skipenv\*?\})
- (?!end\{$skipenv\*?\})|
- (?-1)
- )*
- \\end\{$skipenv\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$skipenv\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$skipenv\*?\})
+ (?!end\{$skipenv\*?\})|
+ (?-1)
+ )*
+ \\end\{$skipenv\*?\}
+ )
+ )
+ /x;
### Pass %<*noltximg> ... %</noltximg> to \begin{nopreview} ... \end{nopreview}
-$cuerpo =~ s/^\%<\*$skiptag>(.+?)\%<\/$skiptag>/\\begin\{nopreview\}$1\\end\{nopreview\}/gmsx;
+$bodydoc =~ s/^\%<\*$skiptag>(.+?)\%<\/$skiptag>/\\begin\{nopreview\}$1\\end\{nopreview\}/gmsx;
### Pass $skip_env to \begin{nopreview} .+? \end{nopreview}
-$cuerpo =~ s/
- \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- ($skip_env)/\\begin\{nopreview\}\n$1\n\\end\{nopreview\}\n/gmsx;
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ ($skip_env)/\\begin\{nopreview\}\n$1\n\\end\{nopreview\}\n/gmsx;
### Regex to extract environments
my $extr_env = qr /
- (
- (?:
- \\begin\{$environ\*?\}
- (?:
- (?>[^\\]+)|
- \\
- (?!begin\{$environ\*?\})
- (?!end\{$environ\*?\})|
- (?-1)
- )*
- \\end\{$environ\*?\}
- )
- )
- /x;
+ (
+ (?:
+ \\begin\{$environ\*?\}
+ (?:
+ (?>[^\\]+)|
+ \\
+ (?!begin\{$environ\*?\})
+ (?!end\{$environ\*?\})|
+ (?-1)
+ )*
+ \\end\{$environ\*?\}
+ )
+ )
+ /x;
### Set bolean options from input file
+$zip = 1 if exists $opts_file{options}{zip};
+$tar = 1 if exists $opts_file{options}{tar};
$force = 1 if exists $opts_file{options}{force};
$run = 0 if exists $opts_file{options}{norun};
$pdf = 0 if exists $opts_file{options}{nopdf};
@@ -1069,174 +1067,156 @@ $srcenv = 1 if exists $opts_file{options}{srcenv};
$subenv = 1 if exists $opts_file{options}{subenv};
### Check plain TeX syntax
-my %special = map { $_ => 1 } @extract; # anon hash
+my %special = map { $_ => 1 } @extract; # anon hash
### Convert \pspicture to LaTeX syntax
-if(exists($special{pspicture})){
- $cuerpo =~ s/
+if (exists($special{pspicture})) {
+ $bodydoc =~ s/
\\pspicture(\*)?(.+?)\\endpspicture/\\begin{pspicture$1}$2\\end{pspicture$1}/gmsx;
}
### Convert \psgraph to LaTeX syntax
-if(exists($special{psgraph})){
- $cuerpo =~ s/
+if (exists($special{psgraph})) {
+ $bodydoc =~ s/
\\psgraph(\*)?(.+?)\\endpsgraph/\\begin{psgraph$1}$2\\end{psgraph$1}/gmsx;
}
### Convert \tikzpicture to LaTeX syntax
-if(exists($special{tikzpicture})){
- $cuerpo =~ s/
+if (exists($special{tikzpicture})) {
+ $bodydoc =~ s/
\\tikzpicture(.+?)\\endtikzpicture/\\begin{tikzpicture}$1\\end{tikzpicture}/gmsx;
}
### Convert \pgfpicture to LaTeX syntax
-if(exists($special{pgfpicture})){
- $cuerpo =~ s/
+if (exists($special{pgfpicture})) {
+ $bodydoc =~ s/
\\pgfpicture(.+?)\\endpgfpicture/\\begin{pgfpicture}$1\\end{pgfpicture}/gmsx;
}
### Pass %<*ltximg> (.+?) %</ltximg> to \begin{preview} (.+?) \end{preview}
-$cuerpo =~ s/^\%<\*$extrtag>(.+?)\%<\/$extrtag>/\\begin\{preview\}$1\\end\{preview\}/gmsx;
+$bodydoc =~ s/^\%<\*$extrtag>(.+?)\%<\/$extrtag>/\\begin\{preview\}$1\\end\{preview\}/gmsx;
### $force mode for pstricks/psgraph/tikzpiture
if ($force) {
-# pspicture or psgraph found
-if(exists($special{pspicture}) or exists($special{psgraph})){
-$cuerpo =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
- (?<code>
- (?:\\psset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
- \\begin\{(?<env> pspicture\*?| psgraph)\} .+? \\end\{\k<env>\}
- )
- /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
+if (exists($special{pspicture}) or exists($special{psgraph})) { # pspicture or psgraph found
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
+ (?<code>
+ (?:\\psset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
+ \\begin\{(?<env> pspicture\*?| psgraph)\} .+? \\end\{\k<env>\}
+ )
+ /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
} # close pspicture
-# tikzpicture found
-if(exists($special{tikzpicture})){
-$cuerpo =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
- (?<code>
- (?:\\tikzset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
- \\begin\{(?<env> tikzpicture)\} .+? \\end\{\k<env>\}
- )
- /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
+if (exists($special{tikzpicture})) {# tikzpicture found
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ \\begin\{postscript\}.+?\\end\{postscript\}(*SKIP)(*F)|
+ (?<code>
+ (?:\\tikzset\{(?:\{.*?\}|[^\{])*\}.+?)? # if exist ...save
+ \\begin\{(?<env> tikzpicture)\} .+? \\end\{\k<env>\}
+ )
+ /\\begin\{preview\}\n$+{code}\n\\end\{preview\}/gmsx;
} # close tikzpicture
-} # close force mode
+} # close $force mode
### Pass $extr_env to \begin{preview} .+? \end{preview}
-$cuerpo =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
- ($extr_env)/\\begin\{preview\}\n$1\n\\end\{preview\}/gmsx;
+$bodydoc =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \\begin\{preview\}.+?\\end\{preview\}(*SKIP)(*F)|
+ ($extr_env)/\\begin\{preview\}\n$1\n\\end\{preview\}/gmsx;
-### The extract environments need back word to original
+### The extract environments need back words to original
%replace = (%changes_out,%reverse_tag);
-$find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
+ $find = join "|", map {quotemeta} sort { length($a)<=>length($b) } keys %replace;
-### Split $cabeza by lines
-@lineas = split /\n/, $cabeza;
+### Split $preamble by lines
+@lineas = split /\n/, $preamble;
### Changues in verbatim write
for (@lineas) {
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $cabeza
-$cabeza = join("\n", @lineas);
+### Join lines in $preamble
+$preamble = join("\n", @lineas);
### Change back betwen \begin{preview} ... \end{preview}
-@lineas = split /\n/, $cuerpo;
+@lineas = split /\n/, $bodydoc;
for (@lineas) {
if (/\\begin\{(preview)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) { # range operator
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) {
- s/($find)/$replace{$1}/g;
- }
+ s/($find)/$replace{$1}/g; }
} # close for
-### Join lines in $cuerpo
-$cuerpo = join("\n", @lineas);
+### Join lines in $bodydoc
+$bodydoc = join("\n", @lineas);
-### If environment extract found, the run script
-my $BP = '\\\\begin\{preview\}';
-my $EP = '\\\\end\{preview\}';
+### preview environment for extract
+my $BP = '\\\\begin\{preview\}';
+my $EP = '\\\\end\{preview\}';
-my @env_extract = $cuerpo =~ m/(?<=$BP)(.+?)(?=$EP)/gms;
+my @env_extract = $bodydoc =~ m/(?<=$BP)(.+?)(?=$EP)/gms;
my $envNo = scalar @env_extract;
-### PSTexample suport
-my $BE = '\\\\begin\{PSTexample\}';
-my $EE = '\\\\end\{PSTexample\}';
+### PSTexample environment for extract
+my $BE = '\\\\begin\{PSTexample\}';
+my $EE = '\\\\end\{PSTexample\}';
-my @exa_extract = $cuerpo =~ m/(?<=$BE)(.+?)(?=$EE)/gms;
+my @exa_extract = $bodydoc =~ m/(?<=$BE)(.+?)(?=$EE)/gms;
my $exaNo = scalar @exa_extract;
-### Check if PSTexample environment found
-if($exaNo!= 0){
- $PSTexa=1;
-}
+### Check if PSTexample environment found, 1 = run script
+if ($exaNo!=0) { $PSTexa = 1; }
-### Check if standart environment found
-if($envNo!= 0){
- $STDenv=1;
-}
+### Check if standart environment found, , 1 = run script
+if ($envNo!=0) { $STDenv=1; }
### PSTexample environment suport
-### Append graphic= to \begin{PSTexample}[...]
-if($PSTexa){
-my $exaNo = 1;
-while ($cuerpo =~ /\\begin\{PSTexample\}(\[.+?\])?/gsm) {
+if ($PSTexa) { # append [graphic={[...]...}]
+$exaNo = 1;
+while ($bodydoc =~ /\\begin\{PSTexample\}(\[.+?\])?/gsm) {
my $swpl_grap = "graphic=\{\[scale=1\]$imageDir/$name-$prefix-exa";
my $corchetes = $1;
- my($pos_inicial, $pos_final) = ($-[1], $+[1]);
- if (not $corchetes) {
- $pos_inicial = $pos_final = $+[0];
- }
- if (not $corchetes or $corchetes =~ /\[\s*\]/) {
- $corchetes = "[$swpl_grap-$exaNo}]";
- }
- else {
- $corchetes =~ s/\]/,$swpl_grap-$exaNo}]/;
+ my ($pos_inicial, $pos_final) = ($-[1], $+[1]);
+ if (not $corchetes) { $pos_inicial = $pos_final = $+[0]; }
+ if (not $corchetes or $corchetes =~ /\[\s*\]/) {
+ $corchetes = "[$swpl_grap-$exaNo}]";
}
- substr($cuerpo, $pos_inicial, $pos_final - $pos_inicial) = $corchetes;
- pos($cuerpo) = $pos_inicial + length $corchetes;
+ else { $corchetes =~ s/\]/,$swpl_grap-$exaNo}]/; }
+ substr($bodydoc, $pos_inicial, $pos_final - $pos_inicial) = $corchetes;
+ pos($bodydoc) = $pos_inicial + length $corchetes;
} # close while
-continue {
- $exaNo++;
- }
-
-### Pass PSTexample to nopreview envirnment
-$cuerpo =~ s/\%<\*ltximgverw>\n
- (?<code>
- \\begin\{PSTexample\} .+? \\end\{PSTexample\}
- )
- \n\%<\/ltximgverw>
- /\\begin\{nopreview\}\n$+{code}\n\\end\{nopreview\}/gmsx;
+continue { $exaNo++; } # increment counter
+
+### Pass PSTexample to nopreview environment
+$bodydoc =~ s/\%<\*ltximgverw>\n
+ (?<code>
+ \\begin\{PSTexample\} .+? \\end\{PSTexample\}
+ )
+ \n\%<\/ltximgverw>
+ /\\begin\{nopreview\}\n$+{code}\n\\end\{nopreview\}/gmsx;
} # close PSTexa
### Command line script identification
print "$program $nv $copyright" ;
### Check if enviroment found in input file
-if ($envNo == 0 and $exaNo == 0){
+if ($envNo == 0 and $exaNo == 0) {
die errorUsage "ltximg can not find any environment to extract in file $name$ext";
- }
-elsif ($envNo!= 0 and $exaNo!= 0){
+ }
+elsif ($envNo!= 0 and $exaNo!= 0) {
say "The file $name$ext contain $envNo environment to extract and $exaNo PSTexample environment to extract";
- }
-elsif ($envNo == 0 and $exaNo!= 0){
+ }
+elsif ($envNo == 0 and $exaNo!= 0) {
say "The file $name$ext contain $exaNo PSTexample environment to extract";
- }
-else {
- say "The file $name$ext contain $envNo environment to extract";
- }
+ }
+else { say "The file $name$ext contain $envNo environment to extract"; }
### Set output file name from input file
if (exists $opts_file{options}{output}){
@@ -1246,57 +1226,43 @@ if (exists $opts_file{options}{output}){
### Validate output file name
if (defined $output) {
# Not contain - at begin
-if ($output =~ /(^\-|^\.).*?/){
+if ($output =~ /(^\-|^\.).*?/) {
die errorUsage "$output it is not a valid name for output file";
}
-
# The name of the output file must be different that $name
-if ($output eq "$name") { # $output = $input
- $output = "$name-out$ext";
-}
+if ($output eq "$name") { $output = "$name-out$ext"; }
+
# The name of the output file must be different that $name.ext
-if ($output eq "$name$ext") { # $output = $input.tex
- $output = "$name-out$ext";
-}
+if ($output eq "$name$ext") { $output = "$name-out$ext"; }
+
# Remove .ltx or .tex extension
-if ($output =~ /.*?$ext/){
- $output =~ s/(.+?)$ext/$1/gms;
- }
-} # close output string check
+if ($output =~ /.*?$ext/) { $output =~ s/(.+?)$ext/$1/gms;}
+} # close check
### If output name are ok, then $outfile = 1
-if(defined($output)){
- $outfile = 1;
-}
+if (defined($output)) { $outfile = 1; }
### If --srcenv or --subenv option are OK then execute script
-if($srcenv){
- $outsrc = 1;
- $subenv = 0;
-}
-
-if ($subenv){
- $outsrc = 1;
- $srcenv = 0;
-}
+if ($srcenv) { $outsrc = 1; $subenv = 0; }
+if ($subenv) { $outsrc = 1; $srcenv = 0; }
### Set imgdir name from input file
-if (exists $opts_file{options}{imgdir}){
+if (exists $opts_file{options}{imgdir}) {
$imageDir = $opts_file{options}{imgdir};
}
### Set prefix name from input file
-if (exists $opts_file{options}{prefix}){
+if (exists $opts_file{options}{prefix}) {
$prefix = $opts_file{options}{prefix};
}
### Set pdfcrop margins from input file
-if (exists $opts_file{options}{margins}){
+if (exists $opts_file{options}{margins}) {
$margins = $opts_file{options}{margins};
}
### Set DPI resolution for images from input file
-if (exists $opts_file{options}{dpi}){
+if (exists $opts_file{options}{dpi}) {
$DPI = $opts_file{options}{dpi};
}
@@ -1308,12 +1274,13 @@ my $opt_page = $crop ? "\n\\pagestyle\{empty\}\n\\begin\{document\}"
: "\n\\begin\{document\}"
;
-### Preamble options for subfiles
-my $sub_prea = "$optin$cabeza$opt_page";
+### Add options to preamble for subfiles
+my $sub_prea = "$atbegindoc$preamble$opt_page";
### Delete <*remove> ... </remove> in $sub_prea
-$sub_prea =~s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+$sub_prea =~ s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+### Options for preview packpage
my $opt_prew = $xetex ? 'xetex,'
: $latex ? ''
: 'pdftex,'
@@ -1333,98 +1300,84 @@ my $srcNo = 1;
### Source file whitout preamble for standart environment
if ($srcenv) {
-
-### Extract standart environment in single files
-if($STDenv){
-say "Creating $envNo files with source code for all environments";
-while ($cuerpo =~ m/$BP\s*(?<env_src>.+?)\s*$EP/gms) {
-open my $OUTsrc, '>', "$imageDir/$src_name$srcNo$ext";
- print $OUTsrc $+{env_src};
-close $OUTsrc;
- } # close while
-continue {
- $srcNo++;
- }
+if ($STDenv) { # extract standard environments in individual files
+ say "Creating $envNo files with source code for all environments";
+ while ($bodydoc =~ m/$BP\s*(?<env_src>.+?)\s*$EP/gms) {
+ open my $OUTsrc, '>', "$imageDir/$src_name$srcNo$ext";
+ print $OUTsrc $+{env_src};
+ close $OUTsrc;
+ } # close while
+ continue { $srcNo++; } # increment counter
} # close STDenv
-
-### Extract PSTexample in single files
-if($PSTexa){
-say "Creating $exaNo files with source code for all PSTexample environments";
-while ($cuerpo =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
-open my $OUTexa, '>', "$+{'pst_exa_name'}$ext";
- print $OUTexa $+{'exa_src'};
-close $OUTexa;
+if ($PSTexa) { # extract PSTexample environments in individual files
+ say "Creating $exaNo files with source code for all PSTexample environments";
+ while ($bodydoc =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
+ open my $OUTexa, '>', "$+{'pst_exa_name'}$ext";
+ print $OUTexa $+{'exa_src'};
+ close $OUTexa;
}
} # close PSTexa
} # close srcenv
### Subfile whit preamble
if ($subenv) {
-
-### Extract standart environments in subfiles
-if($STDenv){
+if ($STDenv) { # extract standard environments (with preamble) in individual files
say "Creating a $envNo files whit source code and preamble for all environments";
-while ($cuerpo =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms) { # search $cuerpo
+while ($bodydoc =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms) { # search $bodydoc
open my $OUTsub, '>', "$imageDir/$src_name$srcNo$ext";
print $OUTsub <<"EOC";
$sub_prea$+{'env_src'}\\end\{document\}
EOC
close $OUTsub;
} # close while
-continue {
- $srcNo++;
- }
+continue { $srcNo++; }
} # close STDenv
-
-### Extract PSTexample environments in subfiles
-if($PSTexa){
+if ($PSTexa) { # extract PSTexample environments (with preamble) in individual files
say "Creating a $exaNo files whit source code and preamble for all PSTexample environments";
-while ($cuerpo =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
-open my $OUTsub, '>', "$+{'pst_exa_name'}$ext";
-print $OUTsub "$sub_prea\n$+{'exa_src'}\n\\end\{document\}";
-close $OUTsub;
- } # close while
- } # close $PSTexa
+while ($bodydoc =~ m/$BE\[.+?(?<pst_exa_name>$imageDir\/.+?-\d+)\}\]\s*(?<exa_src>.+?)\s*$EE/gms) {
+ open my $OUTsub, '>', "$+{'pst_exa_name'}$ext";
+ print $OUTsub "$sub_prea\n$+{'exa_src'}\n\\end\{document\}";
+ close $OUTsub;
+ } # close while
+ } # close $PSTexa
} # close subenv
} # close $outsrc
-### Create a one file whit all PSTexample environments
-if($PSTexa){
+### Create a one file with "all" PSTexample environments extracted
+if ($PSTexa) {
say "Creating the temporary file $name-$prefix-exa-$tmp$ext whit $exaNo PSTexample environments extracted";
@exa_extract = undef;
-while ( $cuerpo =~ m/$BE\[.+? $imageDir\/.+?-\d+\}\](?<exa_src>.+?)$EE/gmsx ) { # search $cuerpo
-push @exa_extract, $+{exa_src}."\n\\newpage\n";
-open my $OUTfig, '>', "$name-$prefix-exa-$tmp$ext";
- print $OUTfig "$optin"."$cabeza"."$opt_page"."@exa_extract\n"."\\end\{document\}";
-close $OUTfig;
- }# close while
-
-### Move and rename tmp-exa-rand file to /image dir
-if(!$run){
+ while ( $bodydoc =~ m/$BE\[.+? $imageDir\/.+?-\d+\}\](?<exa_src>.+?)$EE/gmsx ) { # search $bodydoc
+ push @exa_extract, $+{exa_src}."\n\\newpage\n";
+ open my $OUTfig, '>', "$name-$prefix-exa-$tmp$ext";
+ print $OUTfig "$atbegindoc"."$preamble"."$opt_page"."@exa_extract\n"."\\end\{document\}";
+ close $OUTfig;
+ }# close while
+if (!$run) { # Move and rename tmp-exa-rand file to /image dir
say "Moving the file $name-$prefix-exa-$tmp$ext to /$imageDir/$name-$prefix-exa-all$ext";
move("$workdir/$name-$prefix-exa-$tmp$ext", "$imageDir/$name-$prefix-exa-all$ext");
}
}# close $PSTexa
-### Creating one file whit all environments extracted (noprew option)
-if($STDenv){
+### Create a one file whit "all" standard environments extracted
+if ($STDenv) {
open my $OUTfig, '>', "$name-$prefix-$tmp$ext";
-if ($noprew) {
-say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environments extracted";
-my @env_extract;
-while ( $cuerpo =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms ) { # search $cuerpo
- push @env_extract, $+{env_src}."\n\\newpage\n";
+ if ($noprew) { # $noprew option
+ say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environments extracted";
+ my @env_extract;
+ while ( $bodydoc =~ m/(?<=$BP)(?<env_src>.+?)(?=$EP)/gms ) { # search $bodydoc
+ push @env_extract, $+{env_src}."\n\\newpage\n";
} # close while
-print $OUTfig "$optin"."$cabeza"."$opt_page"."@env_extract\n"."\\end{document}";
- } # close noprew
-else {
-say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environment extracted using preview package";
-print $OUTfig $optin.$preview.$cabeza."\n".$cuerpo."\n\\end{document}";
- }
+ print $OUTfig "$atbegindoc"."$preamble"."$opt_page"."@env_extract\n"."\\end{document}";
+ } # close $noprew
+ else { # default
+ say "Creating the temporary file $name-$prefix-$tmp$ext whit $envNo environment extracted using preview package";
+ print $OUTfig $atbegindoc.$preview.$preamble."\n".$bodydoc."\n\\end{document}";
+ }
close $OUTfig;
### Move tmp-rand file to /image dir
-if(!$run){
+if (!$run) {
say "Moving the file $name-$prefix-$tmp$ext to /$imageDir/$name-$prefix-all$ext";
move("$workdir/$name-$prefix-$tmp$ext", "$imageDir/$name-$prefix-all$ext");
}
@@ -1445,94 +1398,92 @@ my $silence = $verbose ? ''
: ">$null"
;
-### Append -q to gs/poppler for system command line
-my $quiet = $verbose ? ''
- : '-q'
- ;
+### Append -q to gs and poppler for system command line
+my $quiet = $verbose ? ''
+ : '-q'
+ ;
### Compilers
-my $compiler = $xetex ? "xelatex $opt_compiler"
+my $compiler = $xetex ? "xelatex $opt_compiler"
: $luatex ? "lualatex $opt_compiler"
- : $latex ? "latex $opt_compiler"
- : $dvips ? "latex $opt_compiler"
+ : $latex ? "latex $opt_compiler"
+ : $dvips ? "latex $opt_compiler"
: $dvipdf ? "latex $opt_compiler"
- : $arara ? 'arara'
+ : $arara ? 'arara'
: "pdflatex $opt_compiler"
;
### Message in command line for compilers
-my $msg_compiler = $xetex ? 'xelatex'
+my $msg_compiler = $xetex ? 'xelatex'
: $luatex ? 'lualatex'
- : $latex ? 'latex>dvips>ps2pdf'
- : $dvips ? 'latex>dvips>ps2pdf'
+ : $latex ? 'latex>dvips>ps2pdf'
+ : $dvips ? 'latex>dvips>ps2pdf'
: $dvipdf ? 'latex>dvipdfmx'
- : $arara ? 'arara'
+ : $arara ? 'arara'
: 'pdflatex'
;
### Options for ghostscript in command line
my %opt_gs_dev = (
- pdf => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress",
- gray => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray",
- png => "$gscmd $quiet -dNOSAFER -sDEVICE=pngalpha -r$DPI",
- bmp => "$gscmd $quiet -dNOSAFER -sDEVICE=bmp32b -r$DPI",
- jpg => "$gscmd $quiet -dNOSAFER -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4",
- tif => "$gscmd $quiet -dNOSAFER -sDEVICE=tiff32nc -r$DPI",
- );
+ pdf => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress",
+ gray => "$gscmd $quiet -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray",
+ png => "$gscmd $quiet -dNOSAFER -sDEVICE=pngalpha -r$DPI",
+ bmp => "$gscmd $quiet -dNOSAFER -sDEVICE=bmp32b -r$DPI",
+ jpg => "$gscmd $quiet -dNOSAFER -sDEVICE=jpeg -r$DPI -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4",
+ tif => "$gscmd $quiet -dNOSAFER -sDEVICE=tiff32nc -r$DPI",
+ );
### Options for poppler-utils in command line
my %opt_poppler = (
- eps => "pdftops $quiet -eps",
- ppm => "pdftoppm $quiet -r $DPI",
- svg => "pdftocairo $quiet -svg",
- );
+ eps => "pdftops $quiet -eps",
+ ppm => "pdftoppm $quiet -r $DPI",
+ svg => "pdftocairo $quiet -svg",
+ );
### Option for pdfcrop in command line
-my $opt_crop = $xetex ? "--xetex --margins $margins"
+my $opt_crop = $xetex ? "--xetex --margins $margins"
: $luatex ? "--luatex --margins $margins"
- : $latex ? "--margins $margins"
+ : $latex ? "--margins $margins"
: "--pdftex --margins $margins"
;
### Compiler generate file whit all environment extracted
-if($run){
+if ($run) {
opendir(my $DIR, $workdir);
while (readdir $DIR) {
### Compiler generate file
-if (/(?<nombre>$name-$prefix(-exa)?)(?<type>-$tmp$ext)/) {
- system("$compiler $+{nombre}$+{type} $silence");
- say "Compiling the file $+{nombre}$+{type} using $msg_compiler";
+if (/(?<name>$name-$prefix(-exa)?)(?<type>-$tmp$ext)/) {
+ system("$compiler $+{name}$+{type} $silence");
+ say "Compiling the file $+{name}$+{type} using $msg_compiler";
### Compiling file using latex>dvips>ps2pdf
-if($dvips or $latex){
- system("dvips -q -Ppdf -o $+{nombre}-$tmp.ps $+{nombre}-$tmp.dvi");
- system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $+{nombre}-$tmp.ps $+{nombre}-$tmp.pdf");
+if ($dvips or $latex) {
+ system("dvips -q -Ppdf -o $+{name}-$tmp.ps $+{name}-$tmp.dvi");
+ system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $+{name}-$tmp.ps $+{name}-$tmp.pdf");
} # close latex
### Compiling file using latex>dvipdfmx
-if($dvipdf){
- system("dvipdfmx -q $+{nombre}-$tmp.dvi");
-} # close dvipdfmx
+if ($dvipdf) { system("dvipdfmx -q $+{name}-$tmp.dvi"); }
### If option gray
-if($gray){
-say "Moving the file $+{nombre}-$tmp.pdf to $tempDir/$+{nombre}-all.pdf (gray scale)";
-system("$opt_gs_dev{gray} -o $tempDir/$+{nombre}-all.pdf $workdir/$+{nombre}-$tmp.pdf");
- move("$workdir/$+{nombre}-$tmp.pdf","$tempDir/$+{nombre}-$tmp.pdf");
- }
-else{
- say "Moving the file $+{nombre}-$tmp.pdf to $tempDir/$+{nombre}-all.pdf";
- move("$workdir/$+{nombre}-$tmp.pdf", "$tempDir/$+{nombre}-all.pdf");
+if ($gray) {
+ say "Moving the file $+{name}-$tmp.pdf to $tempDir/$+{name}-all.pdf (gray scale)";
+ system("$opt_gs_dev{gray} -o $tempDir/$+{name}-all.pdf $workdir/$+{name}-$tmp.pdf");
+ move("$workdir/$+{name}-$tmp.pdf","$tempDir/$+{name}-$tmp.pdf");
+ }
+else {
+ say "Moving the file $+{name}-$tmp.pdf to $tempDir/$+{name}-all.pdf";
+ move("$workdir/$+{name}-$tmp.pdf", "$tempDir/$+{name}-all.pdf");
}
### Crop generate file
-if($crop){
-say "The file $+{nombre}-all.pdf need a crop, using pdfcrop $opt_crop";
-system("pdfcrop $opt_crop $tempDir/$+{nombre}-all.pdf $tempDir/$+{nombre}-all.pdf $silence");
+if ($crop) {
+ say "The file $+{name}-all.pdf need a crop, using pdfcrop $opt_crop";
+ system("pdfcrop $opt_crop $tempDir/$+{name}-all.pdf $tempDir/$+{name}-all.pdf $silence");
}
### Move tmp-rand.tex file whit all source code for environments to /images dir
-move("$workdir/$+{nombre}$+{type}", "$imageDir/$+{nombre}-all$ext");
+move("$workdir/$+{name}$+{type}", "$imageDir/$+{name}-all$ext");
} # close if m/.../
} # close while
closedir $DIR;
@@ -1553,42 +1504,42 @@ my %format = (%opts_cmd);
my $format = join " ",grep { defined $format{$_} } keys %format;
### Create image formats in separate files
-if($run){
+if ($run) {
opendir(my $DIR, $tempDir);
while (readdir $DIR) {
### PDF/PNG/JPG/BMP/TIFF format suported by ghostscript
-if (/(?<nombre>$name-$prefix(-exa)?)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix(-exa)?)(?<type>-all\.pdf)/) {
for my $var (qw(pdf png jpg bmp tif)) {
if (defined $opts_cmd{$var}) {
- my $ghostcmd = "$opt_gs_dev{$var} -o $workdir/$imageDir/$+{nombre}-%1d.$var $tempDir/$+{nombre}$+{type}";
+ my $ghostcmd = "$opt_gs_dev{$var} -o $workdir/$imageDir/$+{name}-%1d.$var $tempDir/$+{name}$+{type}";
system("$ghostcmd");
- print "Create a $var image format: runing command $opt_gs_dev{$var} in $+{nombre}$+{type}\r\n";
- } # close defined for ghostscript
+ print "Create a $var image format: runing command $opt_gs_dev{$var} in $+{name}$+{type}\r\n";
+ } # close defined for ghostscript
}# close for
} # close if m/.../
### EPS/PPM/SVG format suported by poppler-utils
-if (/(?<nombre>$name-$prefix)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix)(?<type>-all\.pdf)/) {
for my $var (qw(eps ppm svg)) {
if (defined $opts_cmd{$var}) {
for (my $epsNo = 1; $epsNo <= $envNo; $epsNo++) {
-my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{nombre}$+{type} $workdir/$imageDir/$+{nombre}-$epsNo.$var";
+my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{name}$+{type} $workdir/$imageDir/$+{name}-$epsNo.$var";
system("$poppler");
} # close for C style
-print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombre}$+{type}\r\n";
+print "Create a $var image format: runing command $opt_poppler{$var} in $+{name}$+{type}\r\n";
} # close defined
} # close for my $var
} # close if m/.../
### EPS/PPM/SVG for pst-exa package
-if (/(?<nombre>$name-$prefix-exa)(?<type>-all\.pdf)/) {
+if (/(?<name>$name-$prefix-exa)(?<type>-all\.pdf)/) {
for my $var (qw(eps ppm svg)) {
if (defined $opts_cmd{$var}) {
for (my $epsNo = 1; $epsNo <= $exaNo; $epsNo++) {
-my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{nombre}$+{type} $workdir/$imageDir/$+{nombre}-$epsNo.$var";
+my $poppler = "$opt_poppler{$var} -f $epsNo -l $epsNo $tempDir/$+{name}$+{type} $workdir/$imageDir/$+{name}-$epsNo.$var";
system("$poppler");
} # close for C style
-print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombre}$+{type}\r\n";
+print "Create a $var image format: runing command $opt_poppler{$var} in $+{name}$+{type}\r\n";
} # close defined
} # close for my $var
} # close if m/.../
@@ -1596,26 +1547,26 @@ print "Create a $var image format: runing command $opt_poppler{$var} in $+{nombr
closedir $DIR; #close dir
### Renaming PPM image files
-if(defined $opts_cmd{ppm}){
-opendir(my $DIR, $imageDir);
-while (readdir $DIR) {
- if (/(?<nombre>$name-fig(-exa)?-\d+\.ppm)(?<sep>-\d+)(?<ppm>\.ppm)/) {
- move("$imageDir/$+{nombre}$+{sep}$+{ppm}", "$imageDir/$+{nombre}");
- } # close if m/.../
+if (defined $opts_cmd{ppm}) {
+ opendir(my $DIR, $imageDir);
+ while (readdir $DIR) {
+ if (/(?<name>$name-fig(-exa)?-\d+\.ppm)(?<sep>-\d+)(?<ppm>\.ppm)/) {
+ move("$imageDir/$+{name}$+{sep}$+{ppm}", "$imageDir/$+{name}");
+ } # close if m/.../
} # close while
-closedir $DIR;
- } # close renaming PPM
+ closedir $DIR;
+ } # close renaming PPM
} # close run
### Create a output file
if ($outfile) {
-say "Creating the file $output$ext, changue extracted environments to \\includegraphics";
+say "Creating the file $output$ext, convert extracted environments to \\includegraphics";
### Convert extracted environments to \includegraphics
-my $grap="\\includegraphics[scale=1]{$name-$prefix-";
-my $close = '}';
-my $imgNo = 1;
-$cuerpo =~ s/$BP.+?$EP/$grap@{[$imgNo++]}$close/msg; # changes
+my $grap = "\\includegraphics[scale=1]{$name-$prefix-";
+my $close = '}';
+my $imgNo = 1;
+$bodydoc =~ s/$BP.+?$EP/$grap@{[$imgNo++]}$close/msg; # changes
### Constant
my $USEPACK = quotemeta('\usepackage');
@@ -1630,97 +1581,96 @@ my $FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
my $graphix = qr/(\\ usepackage \s*\[\s* .+? \s*\] \s*\{\s* graphicx \s*\} )/ix;
### Capture graphix package for future use
-my (@graphix) = $cabeza =~ m/$graphix/x;
+my (@graphix) = $preamble =~ m/$graphix/x;
### Remove graphix package
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
### Comment \graphicspath for order and future use
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ ($GRAPHICPATH) /%$1/msxg;
+$preamble =~s /\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ ($GRAPHICPATH) /%$1/msxg;
### Regex to capture [options] for pst-exa package
-my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x;
+my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x;
### Capture [option] for pst-exa package
-my (@pst_exa) = $cabeza =~ m/$pstexa/xg;
+my (@pst_exa) = $preamble =~ m/$pstexa/xg;
### Search [option] in pst-exa package
-my %pst_exa = map { $_ => 1 } @pst_exa;
+my %pst_exa = map { $_ => 1 } @pst_exa;
### Clean file (pst/tags)
-if($clean{pst}){
-$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add )? | psfrag |psgo |vaucanson-g| auto-pst-pdf )/x;
-$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
+if ($clean{pst}) {
+$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add )? | psfrag |psgo |vaucanson-g| auto-pst-pdf )/x;
+$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x;
-### Remove package lines
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
+### Remove pst packages lines
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg;
### Delete package words
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
(?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx;
### Delete \psset
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
### Delete \SpecialCoor
-$cabeza =~ s/ \%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
- \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/\%<\*ltximgverw> .+?\%<\/ltximgverw>(*SKIP)(*F)|
+ \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx;
} # close clean{pst}
### Delete empty package line \usepackage{}
-$cabeza =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx;
-### Append graphix to end of preamble
-if(!@graphix == 0){
-$cabeza .= <<"EXTRA";
+### Append graphicx to end of preamble
+if (!@graphix == 0) {
+$preamble .= <<"EXTRA";
@graphix
EXTRA
-}else{
-$cabeza .= <<"EXTRA";
-
+ } else {
+$preamble .= <<"EXTRA";
\\usepackage{graphicx}
EXTRA
}
### Regex to capture \graphicspath
-my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix;
+my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix;
### If preamble contain \graphicspath
-if($cabeza =~ m/($graphicspath)/m){
-while ($cabeza =~ /$graphicspath /pgmx) {
- my($pos_inicial, $pos_final) = ($-[0], $+[0]);
- my $encontrado = ${^MATCH};
- if ($encontrado =~ /$graphicspath/) {
- my $argumento = $1;
- if ($argumento !~ /\{$imageDir\\\}/) {
- $argumento .= "\{$imageDir/\}";
- my $cambio = "\\graphicspath{$argumento}";
- substr $cabeza, $pos_inicial, $pos_final-$pos_inicial, $cambio;
- pos($cabeza) = $pos_inicial + length $cambio;
+if ($preamble =~ m/($graphicspath)/m) {
+ while ($preamble =~ /$graphicspath /pgmx) {
+ my ($pos_inicial, $pos_final) = ($-[0], $+[0]);
+ my $encontrado = ${^MATCH};
+ if ($encontrado =~ /$graphicspath/) {
+ my $argumento = $1;
+ if ($argumento !~ /\{$imageDir\\\}/) {
+ $argumento .= "\{$imageDir/\}";
+ my $cambio = "\\graphicspath{$argumento}";
+ substr $preamble, $pos_inicial, $pos_final-$pos_inicial, $cambio;
+ pos($preamble) = $pos_inicial + length $cambio;
}
}
} #close while
### Regex to capture
-my ($GraphicsPath) = $cabeza =~ m/($graphicspath)/msx;
+my ($GraphicsPath) = $preamble =~ m/($graphicspath)/msx;
-### Append graphicspath to end of preamble
-$cabeza .= <<"EXTRA";
+### Append \graphicspath to end of preamble
+$preamble .= <<"EXTRA";
$GraphicsPath
\\usepackage{grfext}
\\PrependGraphicsExtensions*{.pdf}
EXTRA
- } # close if ($cabeza)
-else{
+ } # close if ($preamble)
+else {
### If preamble not contain graphicspath, append to premble
my $GraphicsPath = "\\graphicspath\{\{$imageDir/\}\}";
### Append graphicspath to end of preamble
-$cabeza .= <<"EXTRA";
+$preamble .= <<"EXTRA";
$GraphicsPath
\\usepackage{grfext}
\\PrependGraphicsExtensions*{.pdf}
@@ -1728,57 +1678,57 @@ EXTRA
} # close graphicspath
### Suport for \usepackage[swpl]{pst-exa}
-if(exists($pst_exa{swpl})){
-$cabeza .= <<'EXTRA';
+if (exists($pst_exa{swpl})) {
+$preamble .= <<'EXTRA';
\usepackage[swpl,pdf]{pst-exa}
EXTRA
}
### Suport for \usepackage[tcb]{pst-exa}
-if(exists($pst_exa{tcb})){
-$cabeza .= <<'EXTRA';
+if (exists($pst_exa{tcb})) {
+$preamble .= <<'EXTRA';
\usepackage[tcb,pdf]{pst-exa}
EXTRA
### Regex
-$cuerpo =~ s/(graphic=\{)\[(scale=\d*)\]($imageDir\/$name-$prefix-exa-\d*)\}/$1$2\}\{$3\}/gsmx;
+$bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imageDir\/$name-$prefix-exa-\d*)\}/$1$2\}\{$3\}/gsmx;
} # close if
### Options for out_file (add $end to outfile)
-my $out_file = $clean{doc} ? "$optin$cabeza$cuerpo\n\\end\{document\}"
- : "$optin$cabeza$cuerpo\n$final"
+my $out_file = $clean{doc} ? "$atbegindoc$preamble$bodydoc\n\\end\{document\}"
+ : "$atbegindoc$preamble$bodydoc\n$enddoc"
;
### Clean \psset content in output file
-if($clean{pst}){
-$out_file =~s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
- \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+if ($clean{pst}) {
+$out_file =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
+ \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
} # close clean
### Clean \tikzset content in output file
-if($clean{tkz}){
-$out_file =~s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
- \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
- \\tikzset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
+if ($clean{tkz}) {
+$out_file =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)|
+ \%<\*ltximgverw> .+? \%<\/ltximgverw>(*SKIP)(*F)|
+ \\tikzset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
} # close clean
-### Back changues in all words in outfile
-$out_file =~s/\\begin\{nopreview\}\s*(.+?)\s*\\end\{nopreview\}/$1/gmsx;
-$out_file =~s/\%<\*ltximgverw>\s*(.+?)\s*\%<\/ltximgverw>/$1/gmsx;
-$out_file =~s/\%<\*noltximg>\n(.+?)\n\%<\/noltximg>/$1/gmsx;
-$out_file =~s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))+//gmsx;
+### Revert changues in all words in outfile
+$out_file =~ s/\\begin\{nopreview\}\s*(.+?)\s*\\end\{nopreview\}/$1/gmsx;
+$out_file =~ s/\%<\*ltximgverw>\s*(.+?)\s*\%<\/ltximgverw>/$1/gmsx;
+$out_file =~ s/\%<\*noltximg>\n(.+?)\n\%<\/noltximg>/$1/gmsx;
+$out_file =~ s/^\%<\*remove>\s*(.+?)\s*\%<\/remove>(?:[\t ]*(?:\r?\n|\r))+//gmsx;
$out_file =~ s/($delt_env)(?:[\t ]*(?:\r?\n|\r))?+//gmsx;
-$out_file =~s/($find)/$replace{$1}/g;
+$out_file =~ s/($find)/$replace{$1}/g;
### Write output file
open my $OUTfile, '>', "$output$ext";
-print $OUTfile "$out_file";
+ print $OUTfile "$out_file";
close $OUTfile;
### Process the output file
-if($run){
+if ($run) {
### Set correct $compiler, if input use latex then output use pdflatex
-$compiler = "pdflatex $opt_compiler" if $latex;
+$compiler = "pdflatex $opt_compiler" if $latex;
$msg_compiler = "pdflatex" if $latex;
### Compiling output file using pdflatex or arara
@@ -1786,20 +1736,18 @@ say "Compiling file $output$ext using $msg_compiler";
system("$compiler $output$ext $silence");
### Compiling output file using latex>dvips>ps2pdf
-if($dvips){
+if ($dvips) {
system("dvips -q -Ppdf $output.dvi");
system("ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None $output.ps $output.pdf");
} # close dvips
### Compiling output file using latex>dvipdfmx
-if($dvipdf){
- system("dvipdfmx -q $output.dvi");
- } # close dvipdf
+if ($dvipdf) { system("dvipdfmx -q $output.dvi"); }
} # close run
} # close outfile file
-### Deleting temporary files
-if($run){
+### Remove temporary files
+if ($run) {
say "Deleting (most) temporary files created during the process";
my @protected = qw();
push (@protected,"$output$ext","$output.pdf") if defined $output;
@@ -1807,58 +1755,59 @@ push (@protected,"$output$ext","$output.pdf") if defined $output;
my $flsline = "OUTPUT";
my @flsfile;
-if ($PSTexa) {
-push @flsfile,"$name-$prefix-exa-$tmp.fls";
-}
-
-if ($STDenv) {
-push @flsfile,"$name-$prefix-$tmp.fls";
-}
-
-push(@flsfile,"$output.fls") if defined $output;
+if ($PSTexa) { push @flsfile,"$name-$prefix-exa-$tmp.fls"; }
+if ($STDenv) { push @flsfile,"$name-$prefix-$tmp.fls"; }
+push (@flsfile,"$output.fls") if defined $output;
my @tmpfiles;
for my $filename(@flsfile){
open my $RECtmp, '<', "$filename";
- push @tmpfiles, grep /^$flsline/,<$RECtmp>;
+ push @tmpfiles, grep /^$flsline/,<$RECtmp>;
close $RECtmp;
}
-foreach (@tmpfiles) {
- s/^$flsline\s+|\s+$//g;
-}
-
-if($latex or $dvips){
- push @tmpfiles,"$name-$prefix-$tmp.ps";
-}
-
-if(-e "$name-$prefix-$tmp.ps"){
- push @tmpfiles,"$name-$prefix-$tmp.ps";
-}
-
-if ($PSTexa) {
- push @tmpfiles,"$name-$prefix-exa-$tmp.ps";
-}
-
-if(-e "$output.ps"){
- push @tmpfiles,"$output.ps";
-}
+foreach (@tmpfiles) { s/^$flsline\s+|\s+$//g; }
+if ($latex or $dvips) { push @tmpfiles,"$name-$prefix-$tmp.ps"; }
+if (-e "$name-$prefix-$tmp.ps") { push @tmpfiles,"$name-$prefix-$tmp.ps"; }
+if ($PSTexa) { push @tmpfiles,"$name-$prefix-exa-$tmp.ps"; }
+if (-e "$output.ps") { push @tmpfiles,"$output.ps"; }
push @tmpfiles,@flsfile,"$name-$prefix-$tmp$ext","$name-$prefix-$tmp.pdf";
my @delfiles = array_minus(@tmpfiles, @protected);
+foreach my $tmpfile (@delfiles) { move("$tmpfile", "$tempDir"); }
+} # close clean tmp files
-foreach my $tmpfile (@delfiles){
- move("$tmpfile", "$tempDir");
+### Compress images dir whit generated files
+if ($zip or $tar) {
+my $stamp = strftime "%F", localtime;
+my $archivetar = "$imageDir-$stamp";
+
+my @savetozt;
+find(\&zip_tar, $imageDir);
+sub zip_tar{
+ my $filesto = $_;
+ if (-f $filesto && $filesto =~ m/$name-$prefix-.+?$/) { # buscamos
+ push @savetozt, $File::Find::name;
+ }
+}
+# Write compressed zip file
+if ($zip) {
+ say "Creating a file $workdir/$archivetar.zip";
+ zip \@savetozt => "$archivetar.zip";
}
-} # close clean tmp files
+
+# Write compressed tar.gz file
+if ($tar) {
+ say "Creating a file $workdir/$archivetar.tar.gz";
+ my $imgdirtar = Archive::Tar->new();
+ $imgdirtar->add_files( @savetozt );
+ $imgdirtar->write( "$archivetar.tar.gz" , 9 );
+ }
+} #close compress
### End of script process
-if($run){
- say "Finish, image formats: $format are in $workdir/$imageDir/";
- }
- else{
- say "Done";
-} # end run
+if ($run) { say "Finish, image formats: $format are in $workdir/$imageDir/"; }
+ else { say "Done"; }
__END__
diff --git a/Master/texmf-dist/source/support/ltximg/ltximg-doc.dtx b/Master/texmf-dist/source/support/ltximg/ltximg-doc.dtx
index 75e550b2baf..2b1944db673 100644
--- a/Master/texmf-dist/source/support/ltximg/ltximg-doc.dtx
+++ b/Master/texmf-dist/source/support/ltximg/ltximg-doc.dtx
@@ -1,8 +1,6 @@
-% arara: lualatex: {draft: yes}
-% arara: makeindex: {style: gind}
-% arara: lualatex: {draft: yes}
-% arara: lualatex
-% arara: clean: { files:[ltximg-doc.ilg, ltximg-doc.out, ltximg-doc.ind, ltximg-doc.aux, ltximg-doc.idx, ltximg-doc.log, ltximg-doc.toc] }
+% arara: xelatex
+% arara: xelatex
+% arara: clean: { extensions: [ aux, log, out, ilg, ind, idx, toc, hd ] }
% \iffalse meta-comment
%<*internal>
\iffalse
@@ -18,11 +16,11 @@ to image formats in individual files using `ghostscript` and `poppler-utils`. Ge
with only extracted environments and other with environments converted to `\includegraphics`.
## Syntax
-```
+```bash
$ ltximg [<compiler>] [<options>] [--] <input file>.<tex|ltx>
```
## Usage
-```
+```bash
$ ltximg --latex [<options>] <file.tex>
$ ltximg --arara [<options>] <file.tex>
$ ltximg [<options>] <file.tex>
@@ -30,19 +28,19 @@ $ ltximg <file.tex>
```
If used without `[<compiler>]` and `[<options>]` the extracted environments are converted to `pdf` image format
and saved in the `/images` directory using `pdflatex` and `preview` package. Relative or absolute `paths` for files
-and directories is not supported and if the last `[<options>]` take a list separated by commas you need `--` at the end.
+and directories is not supported. If the last `[<options>]` take a *list separated by commas*, you need `--` at the end.
## Default environments extract
-```
+```bash
pspicture tikzpicture pgfpicture psgraph postscript PSTexample
```
## Options
-```
+```bash
[default]
-h, --help Display command line help and exit [off]
-l, --license Display GPL license and exit [off]
--v, --version Display current version (v1.5) and exit [off]
+-v, --version Display current version (1.6) and exit [off]
-t, --tif Create .tif files using ghostscript [gs]
-b, --bmp Create .bmp files using ghostscript [gs]
-j, --jpg Create .jpg files using ghostscript [gs]
@@ -53,24 +51,26 @@ and directories is not supported and if the last `[<options>]` take a list separ
-g, --gray Gray scale for images using ghostscript [off]
-f, --force Capture "\psset" and "\tikzset" to extract [off]
-n, --noprew Create images files whitout "preview" package [off]
--d <integer>, --dpi <integer>
+-d <integer>, --dpi <integer>
Dots per inch resolution for images [150]
--m <integer>, --margin <integer>
+-m <integer>, --margin <integer>
Set margins for pdfcrop [0]
--imgdir <dirname> Set name of directory to save images [images]
--o <filename>, --output <filename>
+--zip Compress files generated in .zip format [off]
+--tar Compress files generated in .tar.gz format [off]
+-o <filename>, --output <filename>
Create output file [off]
--verbose Verbose printing [off]
--srcenv Create files whit only code environment [off]
--subenv Create files whit preamble and code [off]
---latex Using latex>dvips>ps2pdf for compiler input
+--latex Using latex>dvips>ps2pdf for compiler input
and pdflatex for compiler output [off]
---dvips Using latex>dvips>ps2pdf for compiler input
- and latex>dvips>ps2pdf for compiler output [off]
---arara Use arara for compiler input and output [off]
+--dvips Using latex>dvips>ps2pdf for compiler input
+ and latex>dvips>ps2pdf for compiler output [off]
+--arara Use arara for compiler input and output [off]
--xetex Using xelatex for compiler input and output [off]
--dvipdf Using dvipdfmx for compiler input and output [off]
---luatex Using lualatex for compiler input and output [off]
+--luatex Using lualatex for compiler input and output [off]
--prefix <string> Set prefix append to each image file [off]
--norun Run script, but no create images files [off]
--nopdf Don't create a ".pdf" image files [off]
@@ -85,23 +85,27 @@ and directories is not supported and if the last `[<options>]` take a list separ
--deltenv <env1,...> Delete environments in output file [empty]
```
## Example
-```
+```bash
$ ltximg --latex -e -p --srcenv --imgdir=mypics -o test-out test-in.ltx
```
-```
+```bash
$ ltximg --latex -ep --srcenv --imgdir mypics -o test-out test-in.ltx
```
Create a `/mypics` directory whit all extracted environments converted to
- image formats(`.pdf`, `.eps`, `.png`), individual files whit source code (`.tex`)
- for all extracted environments, a file `test-out.ltx` whit all environments converted to `\includegraphics`
- and file `test-in-fig-all.tex` with only the extracted environments using
- `latex>dvips>ps2pdf` and `preview` package for `<input file>` and `pdflatex`
+ image formats (`.pdf`, `.eps`, `.png`), individual files whit source code (`.tex`)
+ for all extracted environments, a file `test-out.ltx` whit all environments converted to `\includegraphics`
+ and file `test-in-fig-all.tex` with only the extracted environments using
+ `latex>dvips>ps2pdf` and `preview` package for `<input file>` and `pdflatex`
for `<output file>`.
## Documentation
For full documentation use:
+```bash
+$ texdoc ltximg
```
-$ texdoc ltximg
+ For recreation all documentation use:
+```bash
+$ arara ltximg-doc.dtx
```
## Licence
@@ -115,38 +119,47 @@ License for more details.
## Author
-Written by Pablo González L <pablgonz@yahoo.com>, last update 2018-04-12.
+Written by Pablo González L <pablgonz@yahoo.com>, last update 2019-07-13.
## Copyright
-Copyright 2013 - 2018 by Pablo González L
+Copyright 2013 - 2019 by Pablo González L
%</readme>
%<*changues>
## Changues
-```
- v1.5. (d) 2018-04-12 - Use GitHub to control version
- - Rewrite and optimize most part of code and options
- - Changue pdf2svg for pdftocairo
- - Complete support for pst-exa packpage
- - Clean take and optional
- v1.4. (d) 2016-11-29 - Remove and rewrite code for regex and system call
- - Append arara compiler, clean and comment code
- - Append dvips and dvipdfm for creation images
- - Append bmp, tif image format
- v1.3. (d) 2016-10-16 - All options its read from cmd line and input file
- - Rewrite some part of code (norun, nocrop, clean)
- - Suport minted and tcolorbox packpage for verbatim
- - Use /tmp dir for work process
- - Escape some characters in regex according to v5.2xx
- v1.2 (p) 2015-04-22 - Remove unused modules
- v1.1 (p) 2015-04-21 - Change mogrify to gs for image formats
- - Create output file
- - Rewrite source code and fix regex
- - Add more image format
- - Change date to iso format
- v1.0 (p) 2013-12-01 - First public release
-```
-Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
+### v1.6 (p) 2019-07-13
+- Add `tar` and `zip` options
+- Add suport for new `Verb` from `fvextra`
+- Update source code and documentation
+### v1.5 (p) 2018-04-12
+- Use GitHub to control version
+- Rewrite and optimize most part of code and options
+- Changue `pdf2svg` for `pdftocairo`
+- Complete support for `pst-exa` packpage
+- `clean` take a optional argument
+### v1.4 (d) 2016-11-29
+- Remove and rewrite code for regex and system call
+- Append `arara` compiler, clean and comment code
+- Append `dvips` and `dvipdfm(x)` for creation images
+- Append `bmp` and `tif` image format
+### v1.3. (d) 2016-10-16
+- All options it's read from command line and input file
+- Rewrite some part of code (`norun`, `nocrop`, `clean`)
+- Suport `minted` and `tcolorbox` packpage
+- Use `/tmp` dir for work process
+- Escape some characters in regex according to v5.2xx
+### v1.2 (p) 2015-04-22
+- Remove unused modules
+### v1.1 (p) 2015-04-21
+- Change `mogrify` to `gs` for image formats
+- Create `output` file
+- Rewrite source code and fix regex
+- Add more image format
+- Change date to iso format
+### v1.0 (p) 2013-12-01
+- First public release
+
+Copyright 2013 - 2019 by Pablo González L <pablgonz@yahoo.com>. $ID
%</changues>
%<*internal>
\fi
@@ -173,27 +186,61 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
%<*documentation>
\documentclass{ltxdoc}
\usepackage[top=0.5in, bottom=0.5in, left=2in, right=1in,footskip=0.2in,%
- headsep=10pt]{geometry} % page dimension
-\usepackage[totoc,columns=2]{idxlayout} % index
-\EnableCrossrefs
-\CodelineIndex
-\usepackage[mono=false]{libertine} % default roman/serif fonts
+ headsep=10pt]{geometry} % page dimension
+\usepackage{unicode-math}
+\setmathfont[Scale = 0.95]{Latin Modern Math}
+\setmainfont[
+ Numbers = OldStyle,
+ Ligatures = TeX,
+ Scale = 0.95,
+ UprightFont = *-Regular,
+ ItalicFont = *-Italic,
+ BoldFont = *-Bold,
+ BoldItalicFont = *-BoldItalic,
+ SmallCapsFeatures = {Letters=SmallCaps},
+ Extension =.otf]{LibertinusSerif}
+\setsansfont[
+ Numbers = OldStyle,
+ Ligatures = TeX,
+ Scale = 0.95,
+ UprightFont = *-Regular,
+ ItalicFont = *-Italic,
+ BoldFont = *-Bold,
+ SmallCapsFeatures = {Letters=SmallCaps},
+ Extension = .otf]{LibertinusSans}
\setmonofont[
- Ligatures = TeX ,
- Scale = 0.84,
- Extension = .otf,
- UprightFont = *-Regular ,
- ItalicFont = *-RegularIt,
- BoldFont = *-Medium ,
- BoldItalicFont = *-MediumIt
- ]{SourceCodePro} % srccode font
-\usepackage{microtype,fetamont,hologo} % LaTeX logo and LTXimg logo
-\usepackage{xspace,tocloft,enumitem,fancyhdr,lastpage} % custom
-\usepackage[svgnames]{xcolor} % colors :)
-\usepackage[sf,bf,compact,medium]{titlesec} % sections
+ Scale = 0.80,
+ Extension = .otf,
+ UprightFont = *-Regular ,
+ ItalicFont = *-RegularIt,
+ BoldFont = *-Medium ,
+ BoldItalicFont = *-MediumIt
+ ]{SourceCodePro} % source code font
+\newfontfamily\lmmitalic{lmmono10-italic.otf}[
+ Scale = 0.95,%
+ Extension = .otf,%
+ ItalicFont = lmmono10-italic,%
+ SmallCapsFont = lmmonocaps10-oblique,%
+ SlantedFont = lmmonoslant10-regular,
+ ]
+\newfontfamily\fetamono{ffmw10.otf}[
+ Scale = 0.95,%
+ RawFeature ={+latn,+rand,+kern,+size},%
+ ]
+\newfontfamily\libertinusinitials{LibertinusSerifInitials-Regular.otf}
+\usepackage{microtype,hologo} % LaTeX logo
+\usepackage{enumitem,lastpage,microtype,titletoc} % custom
+\usepackage[svgnames]{xcolor} %
+\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage{adjustbox,multicol,hyperref,xparse,listings,accsupp}
-\usepackage{interfaces,graphicx}
-
+\usepackage{hyperxmp,imakeidx}%
+\PageIndex
+\EnableCrossrefs
+\newcommand{\HP}[1]{\emph{\hyperpage{#1}}\normalsize}
+\def\SortIndex#1#2{\index{#1\actualchar#2|HP}}
+\indexsetup{level=\section,firstpagestyle=myheader}
+%\makeindex[name=mydoc,options=-s gind.ist,columnsep=15pt,title={Index of Documentation}]
+\makeindex[options=-s gind.ist,columnsep=15pt,title={Index of Documentation}]
% don't copy numbers in code example
\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}
@@ -203,293 +250,332 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
% Colors for options
\definecolor{optcolor}{rgb}{0.281,0.275,0.485}
-% Logo whit libertine font for title
+% Identification
+\def\myscript{ltximg}
+\def\fileversion{1.6}
+\def\filedate{2019-07-13}
+
+% Logo whit libertuns and fetamono font
\newsavebox{\logobox}
\savebox{\logobox}{%
\normalsize%
- {\libertineInitial%
+ {\libertinusinitials%
\textcolor{red}{L}\hspace{-3.0pt}%
\raisebox{-0.2em}{\small \textcolor{green}{T}}%
\hspace{-2.9pt}\textcolor{blue}{X}}%
- \hspace{-1pt}\textffmw{\textcolor{gray}{img}}%
-}% close box
-
-\makeatletter % changes the catcode of @ to 11
+ \hspace{-1pt}\fetamono{\textcolor{gray}{img}}%
+}%
+\makeatletter
\newcommand{\LTXimg}{%
\settoheight{\@tempdima}{L}%
\resizebox{!}{\@tempdima}{\usebox{\logobox}}%
}
-\makeatother % changes the catcode of @ back to 12
-
-% oldstyle for libertine, need after \LTXimg
-\useosf
+\makeatother
-% logo for body docuement
-\newcommand*{\ltximg}{%
- \normalsize\texttt{\bfseries
- \textcolor{NavyBlue}{ltximg}}\xspace%
-}% close ltximg
+% email https://tex.stackexchange.com/a/663
+\catcode`\_=11\relax%
+\newcommand\email[1]{\_email #1\q_nil}%
+\def\_email#1@#2\q_nil{%
+ \href{mailto:#1@#2}{{\emailfont #1\emailampersat #2}}%
+}%
+\newcommand\emailfont{\sffamily}%
+\newcommand\emailampersat{{\color{NavyBlue}\footnotesize@}}%
+\catcode`\_=8\relax% %
-% Identification
-\def\myscript{ltximg}
-\def\fileversion{1.5}
-\def\filedate{2018-04-12}
% Config hyperref
\hypersetup{
- linkcolor = blue!50,
- citecolor = red!50,%
- urlcolor = magenta,%
- colorlinks = true,%
- pdftitle ={.::ltximg v1.5 (2018-04-12) --- LaTeX environments to image formats::.},%
- pdfauthor= {Pablo Gonz\'{a}lez Luengo},% á fails
- pdfsubject={Documentation for version 1.5},%
- pdfstartview={FitH},%
- bookmarksopenlevel=2,%
+ linkcolor = blue!50,
+ citecolor = red!50,%
+ urlcolor = magenta,%
+ colorlinks = true,%
+ pdftitle = {.:: ltximg \fileversion{} (\filedate) --- LaTeX environments to image formats ::.},%
+ pdfauthor = {Pablo Gonz\'{a}lez Luengo},%
+ pdfsubject = {Documentation for version \fileversion},%
+ pdfcopyright = {\textcopyright 2019 by Pablo González Luengo},
+ pdfcontacturl = {https://github.com/pablgonz/ltximg},
+ pdfkeywords = {extract, conversion, images, tikz, pstricks},
+ pdfstartview = {FitH},%
+ bookmarksopenlevel = 2,%
}
-% Configuration fancyhdr
-\fancypagestyle{plain}{%
-\fancyhf{}%
-\fancyfoot[R]{\small\textsf{\thepage{} /\pageref{LastPage}}}
-\renewcommand{\headrulewidth}{0pt}%
-\renewcommand{\footrulewidth}{0pt}%
-}% close plain style
-
-\renewcommand{\sectionmark}[1]{
- \markboth{\textsf{\scshape\small\S\thesection. #1}}{}
- }%
-
-\fancypagestyle{myheader}{%
-\fancyhf{}%
-\fancyhead[L]{\raisebox{-0.75\baselineskip}[0pt][0pt]{%
-\textsf{\small \textcolor{gray}{Documentation for version \fileversion{} [\filedate]}}%
- }%
- }%
-\fancyhead[R]{\raisebox{-0.75\baselineskip}[0pt][0pt]{%
- \small\nouppercase{\leftmark}%
- }%
- }%
-\fancyfoot[R]{\small\textsf{\thepage{} /\pageref{LastPage}}}
-\fancyfoot[L]{%
- \small\sffamily%
- \LTXimg{}
- \textcolor{gray}{%
- \raisebox{-1pt}{\textcopyright}{}2013--2018 by Pablo González L%
- }%
-}%
-\renewcommand{\headrulewidth}{0.5pt}%
-\renewcommand{\footrulewidth}{0pt}%
-\renewcommand{\headrule}{%
- \hbox to\headwidth{%
- \color{NavyBlue}\leaders\hrule height \headrulewidth\hfill}%
- }%
-} % close myheader
-
-% add headheight
+% Configuration titleps
+\settitlemarks{section}
+\renewpagestyle{plain}[\color{gray}\small\sffamily]{
+\setfoot{}{}{\thepage/\pageref{LastPage}}}
+
+\newpagestyle{myheader}[\color{gray}\small\sffamily]{
+\renewcommand\makeheadrule{\color{gray}\rule[0.45\baselineskip]{\linewidth}{0.4pt}}
+\setfoot{\scalebox{0.85}{\LTXimg}\space\textcopyright\space 2019 by Pablo González L}
+ {}
+ {\thepage/\pageref{LastPage}}
+\sethead{\raisebox{0.75\baselineskip}{Documentation for version \fileversion\space[\filedate]}}
+ {}
+ {\raisebox{0.75\baselineskip}{\scshape\small\S.\thesection\space\sectiontitle}}
+}
\setlength{\headheight}{21pt}%
+% Table of contents
+\titlecontents{section}[0mm]{}%
+ {\bfseries\contentspush{\makebox[4mm][l]{\thecontentslabel\hfill}}}%
+ {\hspace*{-4mm}}% numberless
+ {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}%
+
+\titlecontents{subsection}[4mm]{}%
+ {\contentspush{\makebox[6mm][l]{\thecontentslabel\hfill}}}
+ {\hspace*{-10mm}}% numberless
+ {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}%
+
+\titlecontents{subsubsection}[10mm]{}%
+ {\contentspush{\makebox[8mm][l]{\thecontentslabel\hfill}}}
+ {\hspace*{-18mm}}% numberless
+ {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}%
+
+\makeatletter
+\renewcommand\tableofcontents{%
+\begingroup%
+\section*{\contentsname\quad{\color{gray}\leaders\hrule height 5pt depth -4.4pt\hfill}%
+ \@mkboth{%
+ \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
+\vspace*{-14pt}
+\setlength{\columnsep}{10pt}%
+ \begin{multicols}{2}%
+ \@starttoc{toc}%
+\end{multicols}%
+\vspace*{-3pt}{\color{gray}\hrule height 0.6pt}%
+\vspace*{5pt}
+\endgroup
+}
+\makeatother
+
% Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} for color
\ExplSyntaxOn
%^^A user level commands
\RenewDocumentCommand{\meta}{O{}m}
-{
- \ltximg_meta_generic:Nnn \ltximg_meta:n { #1 } { #2 }
-}
+ {
+ \ltximg_meta_generic:Nnn \ltximg_meta:n { #1 } { #2 }
+ }
\RenewDocumentCommand{\marg}{O{}m}
-{
- \ltximg_meta_generic:Nnn \ltximg_marg:n { #1 } { #2 }
-}
+ {
+ \ltximg_meta_generic:Nnn \ltximg_marg:n { #1 } { #2 }
+ }
\RenewDocumentCommand{\oarg}{O{}m}
-{
- \ltximg_meta_generic:Nnn \ltximg_oarg:n { #1 } { #2 }
-}
+ {
+ \ltximg_meta_generic:Nnn \ltximg_oarg:n { #1 } { #2 }
+ }
%^^A variables and keys
\tl_new:N \l_ltximg_meta_font_tl
\keys_define:nn { ltximg/meta }
-{
- type .choice:,
- type / tt .code:n = \tl_set:Nn \l_ltximg_meta_font_tl { \ttfamily },
- type / rm .code:n = \tl_set:Nn \l_ltximg_meta_font_tl { \rmfamily },
- type .initial:n = tt,
- cf .tl_set:N = \l_ltximg_meta_color_tl,
- cf .initial:n = black,
- ac .tl_set:N = \l_ltximg_meta_anglecolor_tl,
- ac .initial:n = black,
- sbc .tl_set:N = \l_ltximg_meta_brackcolor_tl,
- sbc .initial:n = black,
- cbc .tl_set:N = \l_ltximg_meta_bracecolor_tl,
- cbc .initial:n = black,
-}
+ {
+ type .choice:,
+ type / tt .code:n = \tl_set:Nn \l_ltximg_meta_font_tl { \ttfamily },
+ type / rm .code:n = \tl_set:Nn \l_ltximg_meta_font_tl { \rmfamily },
+ type .initial:n = tt,
+ cf .tl_set:N = \l_ltximg_meta_color_tl,
+ cf .initial:n = black,
+ ac .tl_set:N = \l_ltximg_meta_anglecolor_tl,
+ ac .initial:n = black,
+ sbc .tl_set:N = \l_ltximg_meta_brackcolor_tl,
+ sbc .initial:n = black,
+ cbc .tl_set:N = \l_ltximg_meta_bracecolor_tl,
+ cbc .initial:n = black,
+ }
%^^A internal commands
\cs_new_protected:Npn \ltximg_meta_generic:Nnn #1 #2 #3
-{
- \group_begin:
+ {
+ \group_begin:
\keys_set:nn { ltximg/meta } { #2 }
\color{ \l_ltximg_meta_color_tl }
\l_ltximg_meta_font_tl
#1 { #3 } % #1 is \ltximg_meta:n, \ltximg_marg:n or \ltximg_oarg:n
- \group_end:
-}
+ \group_end:
+ }
\cs_new_protected:Npn \ltximg_meta:n #1
-{
- \ltximg_meta_angle:n { \textlangle }
- \ltximg_meta_meta:n { #1 }
- \ltximg_meta_angle:n { \textrangle }
-}
+ {
+ \ltximg_meta_angle:n { \textlangle }
+ \ltximg_meta_meta:n { #1 }
+ \ltximg_meta_angle:n { \textrangle }
+ }
\cs_new_protected:Npn \ltximg_marg:n #1
-{
- \ltximg_meta_brace:n { \textbraceleft }
- \ltximg_meta:n { #1 }
- \ltximg_meta_brace:n { \textbraceright }
-}
+ {
+ \ltximg_meta_brace:n { \textbraceleft }
+ \ltximg_meta:n { #1 }
+ \ltximg_meta_brace:n { \textbraceright }
+ }
\cs_new_protected:Npn \ltximg_oarg:n #1
-{
- \ltximg_meta_brack:n { [ }
- \ltximg_meta:n { #1 }
- \ltximg_meta_brack:n { ] }
-}
+ {
+ \ltximg_meta_brack:n { [ }
+ \ltximg_meta:n { #1 }
+ \ltximg_meta_brack:n { ] }
+ }
\cs_new_protected:Npn \ltximg_meta_meta:n #1
-{
- \textnormal{\textit{#1}}
-}
+ {
+ \textnormal{\textit{#1}}
+ }
\cs_new_protected:Npn \ltximg_meta_angle:n #1
-{
- \group_begin:
+ {
+ \group_begin:
\fontfamily{cmr}\selectfont
\textcolor{\l_ltximg_meta_anglecolor_tl}{#1}
- \group_end:
-}
+ \group_end:
+ }
\cs_new_protected:Npn \ltximg_meta_brace:n #1
-{
- \group_begin:
+ {
+ \group_begin:
\color{\l_ltximg_meta_bracecolor_tl}
#1
- \group_end:
-}
+ \group_end:
+ }
\cs_new_protected:Npn \ltximg_meta_brack:n #1
-{
- \textcolor{\l_ltximg_meta_brackcolor_tl}{#1}
-}
-\ExplSyntaxOff
+ {
+ \textcolor{\l_ltximg_meta_brackcolor_tl}{#1}
+ }
+
+% \ltximg for body document
+\DeclareDocumentCommand{\ltximg}{}
+ {
+ \normalsize\texttt{\bfseries\textcolor{NavyBlue}{ltximg}}
+ }
% \prgname{sm} : #1 index compiler, #2 index programs:
-\DeclareDocumentCommand\prgname{sm}{%
+\DeclareDocumentCommand{\prgname}{sm}
+ {%
\IfBooleanTF{#1}
- {
- \textcolor{ForestGreen}{\ttfamily\bfseries{#2}}\xspace%
- \SortIndex{compiler}{Compiler>\small\textsf{#2}}%
- }
- {
- \textcolor{ForestGreen}{\ttfamily\bfseries{#2}}\xspace%
- \SortIndex{programs}{Programs>\small\textsf{#2}}%
- }
-}%
+ {
+ \textcolor{ForestGreen}{\ttfamily\bfseries{#2}}
+ \SortIndex{compiler}{Compiler>\small\texttt{#2}}
+ }
+ {
+ \textcolor{ForestGreen}{\ttfamily\bfseries{#2}}
+ \SortIndex{programs}{Programs>\small\texttt{#2}}
+ }
+ }%
% \prgopt{sm} : #1 compiler opt, #2 program opt:
-\DeclareDocumentCommand\prgopt{sm}{%
+\DeclareDocumentCommand{\prgopt}{sm}
+ {%
\IfBooleanTF{#1}
- {
- \textcolor{gray}{\ttfamily\bfseries{-{}#2}}%\xspace%
- \SortIndex{compiler options}{Compiler options>\small\texttt{-{}#2}}%
- }
- {
- \mbox{\texttt{-{}#2}}%
- \SortIndex{#2}{\texttt{-{}#2} (program option)}%
- }
-}
+ {
+ \textcolor{gray}{\ttfamily\bfseries{-{}#2}}
+ \SortIndex{compiler ~ options}{Compiler ~ options>\small\texttt{-{}#2}}%
+ }
+ {
+ \mbox{\texttt{-{}#2}}%
+ \SortIndex{#2}{\small\texttt{-{}#2} (program ~ option)}%
+ }
+ }
% \scriptname*{m}
-\DeclareDocumentCommand\scriptname{m}{%
- \textcolor{ForestGreen}{\ttfamily\bfseries{#1}}\xspace
- \SortIndex{scripts}{Scripts>\textsf{#1}}%
-}%
+\DeclareDocumentCommand{\scriptname}{m}
+ {
+ \textcolor{ForestGreen}{\ttfamily\bfseries{#1}}
+ \SortIndex{scripts}{Scripts>\small\texttt{#1}}%
+ }
% \scriptopt{m}
-\DeclareDocumentCommand\scriptopt{m}{%
- \mbox{\texttt{#1}}\xspace%
- \SortIndex{script option}{Script options>\small\textsf{#1}}%
-}
+\DeclareDocumentCommand{\scriptopt}{m}
+ {
+ \mbox{\texttt{#1}}
+ \SortIndex{script ~ option}{Script ~ options>\small\texttt{#1}}%
+ }
% \pkgname{m}
-\DeclareDocumentCommand\pkgname{m}{%
- \textsf{\textcolor{SlateBlue}{#1}}%
- \SortIndex{packages}{Packages>\textsf{#1}}%
- %\SortIndex{#1}{\textsf{#1} (package)}%
-}%
+\DeclareDocumentCommand{\pkgname}{ m }
+ {
+ \textsf{\textcolor{SlateBlue}{#1}}
+ \SortIndex{packages}{Packages>\small\texttt{#1}}
+ \SortIndex{#1}{\texttt{#1} (package)}
+ }%
% \pkgopt{m}
-\DeclareDocumentCommand\pkgopt{m}{%
- \textsf{\textcolor{Orange}{#1}}%
- \SortIndex{package options}{Package options>\textsf{#1}}%
- \SortIndex{#1}{\textsf{#1} (package option)}%
-}%
+\DeclareDocumentCommand{ \pkgopt}{ m }
+ {
+ \textsf{\textcolor{Orange}{#1}}
+ \SortIndex{package ~ options}{Package ~ options>\small\texttt{#1}}
+ \SortIndex{#1}{\texttt{#1} (package ~ option)}
+ }
% \env{sm}, #1 not used now
-\DeclareDocumentCommand\env{sm}{
- \textcolor{optcolor}{\sffamily{#2}}%
- \SortIndex{environment}{Environments>\small\textsf{#2}}%
-}
+\DeclareDocumentCommand{\env}{m}
+ {
+ \textcolor{optcolor}{\texttt{#1}}%
+ \SortIndex{environment}{Environments>\small\texttt{#1}}%
+ }
% \ics{sm}, #1 not used now
-\DeclareDocumentCommand\ics{sm}{
+\DeclareDocumentCommand{\ics}{sm}
+ {
\textcolor{optcolor}{\ttfamily{\textbackslash#2}}%
- \SortIndex{#2}{\textsf{\small\textbackslash#2}}
-}
+ \SortIndex{#2}{\texttt{\small\textbackslash#2}}
+ }
% file extention
-\DeclareDocumentCommand\fext{m}{%
- \mbox{\textcolor{optcolor}{\ttfamily\bfseries{.#1}}\xspace}%
- \SortIndex{files extention}{File extentions (input)>\small\textsf{.#1}}%
-}
+\DeclareDocumentCommand{\fext}{m}
+ {
+ \mbox{\textcolor{optcolor}{\ttfamily\bfseries{.#1}}}%
+ \SortIndex{files ~ extention}{File ~ extentions >\small\texttt{.#1}}%
+ }
% image format/extention
-\DeclareDocumentCommand\iext{m}{%
+\DeclareDocumentCommand{\iext}{m}
+ {%
\textcolor{optcolor}{\ttfamily\bfseries{#1}}%
- \SortIndex{Image format}{Image formats>\small\textsf{#1}}%
-}
-
-% \DescribeIF{m}, #1 image format
-\newsavebox{\marginIF}
-\NewDocumentCommand\DescribeIF{m}{%
-\begin{lrbox}{\marginIF}%
- \begin{minipage}[t]{\marginparwidth}%
- \raggedleft
- \iext{#1}
- \end{minipage}%
-\end{lrbox}%
- \leavevmode%
- \marginpar{\usebox{\marginIF}}%
- \ignorespaces%
-}%
+ \SortIndex{Image format}{Image formats>\small\texttt{#1}}%
+ }
% \sysydir{m}
-\DeclareDocumentCommand\sysdir{m}{%
+\DeclareDocumentCommand{\sysdir}{m}
+ {
\mbox{\textcolor{NavyBlue}{\ttfamily{/#1}}}%
-}
+ }
% \sysfile{m} ...only for color in some examples
-\DeclareDocumentCommand\sysfile{m}{%
- \mbox{\textcolor{gray}{\ttfamily{#1}}}\xspace%
-}
+\DeclareDocumentCommand{\sysfile}{m}
+ {
+ \mbox{\textcolor{gray}{\ttfamily{#1}}}
+ }
% \OSsystem{m} ...only for color in some examples
-\DeclareDocumentCommand\OSsystem{m}{%
+\DeclareDocumentCommand{\OSsystem}{m}
+ {
\mbox{\textcolor{NavyBlue}{\ttfamily\bfseries{#1}}}%
- \SortIndex{Operating system}{Operating system>\small\textsf{#1}}%
-}
+ \SortIndex{Operating ~ system}{Operating ~ system>\small\texttt{#1}}
+ }
% \cmdopt[short]{long}
-\NewDocumentCommand\cmdopt{om}{%
- \IfNoValueTF{#1}%
- {\textcolor{optcolor}{\ttfamily\bfseries{-\/-#2}}\xspace}%
- {\textcolor{optcolor}{\ttfamily\bfseries{-{}#1}}, \textcolor{optcolor}{\ttfamily\bfseries{-\/-#2}}\xspace}%
-\SortIndex{options}{\textsf{\myscript}\ options in command line>\small\texttt{-\/-#2}}%
-}
+\DeclareDocumentCommand{\cmdopt}{om}
+ {
+ \IfNoValueTF{#1}
+ {
+ \textcolor{optcolor}{\ttfamily\bfseries{-\/-#2}}
+ }
+ {
+ \textcolor{optcolor}{\ttfamily\bfseries{-{}#1}},
+ \textcolor{optcolor}{\ttfamily\bfseries{-\/-#2}}
+ }
+ \SortIndex{options}{\textsf{\myscript}\ options ~ in ~ command ~ line>\small\texttt{-\/-#2}}%
+ }
+
+\ExplSyntaxOff
+% \DescribeIF{m}, #1 image format
+\newsavebox{\marginIF}
+\NewDocumentCommand{\DescribeIF}{ m }
+ {%
+ \begin{lrbox}{\marginIF}%
+ \begin{minipage}[t]{\marginparwidth}%
+ \raggedleft
+ \iext{#1}
+ \end{minipage}%
+ \end{lrbox}%
+ \leavevmode%
+ \marginpar{\usebox{\marginIF}}%
+ \ignorespaces%
+ }%
% \myenv{environ}
-\DeclareDocumentCommand\myenv{m}{%
-\moveright 0.0pt \hbox{%
+\DeclareDocumentCommand\myenv{m}
+ {
+ \moveright 0.0pt \hbox{%
\begin{minipage}[t]{\marginparwidth}%
\raggedleft\ttfamily%\small%
{\textcolor{gray}{\textbackslash begin\{}}{\bfseries\textcolor{optcolor}{#1}}\textcolor{gray}{\}}\par%
@@ -497,8 +583,8 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
{\textcolor{gray}{\textbackslash end\{}}{\bfseries\textcolor{optcolor}{#1}}\textcolor{gray}{\}}%
\end{minipage}%
} % close hbox
-\SortIndex{Environment}{Environments suport by default>\small\textsf{#1}}%
-}%
+ \SortIndex{Environment}{Environments suport by default>\small\texttt{#1}}%
+ }
% \mytag{dtxtag}
\DeclareDocumentCommand\mytag{m}{%
@@ -510,7 +596,7 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
\textcolor{gray}{\%</}{\bfseries\textcolor{optcolor}{#1}}\textcolor{gray}{>}%
\end{minipage}%
} % close hbox
-\SortIndex{docstrip}{Docstrip tag>\textsf{#1}}%
+ \SortIndex{docstrip}{Docstrip tag>\small\texttt{#1}}%
}%
% \DescribeTE{sm}, #1 tag, #2 env
@@ -579,9 +665,9 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
stringstyle = {\color{red}},%
% comments
morecomment=[l]{\%},%
- commentstyle=\itshape\color{lightgray},%
+ commentstyle=\lmmitalic\color{lightgray},%
% Important words 1
- keywordstyle=[1]{\bfseries\color{NavyBlue}},%
+ keywordstyle=[1]{\color{NavyBlue}},%
keywords=[1]{AtBeginDocument,begin,end,documentclass,BEGIN,END},%
% Other words 2
keywordstyle=[2]{\color{blue!75}},%
@@ -593,7 +679,7 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
keywords=[3]{document,graphicx,preview,active,tightpage,article,grfext,description,filecontents,%
external,tikz,clean,pst,tkz,eps,pdf,xetex,latex,luatex,dvips,png,srcenv,noprew,imgdir,prefix,output},%
% Reserved words 4(inputfile options)
- keywordstyle=[4]{\bfseries\color{optcolor}},%
+ keywordstyle=[4]{\color{optcolor}},%
keywords=[4]{ltximg,noltximg,remove,options,pspicture,endpspicture,%
PSTexample,pgfpicture, endpgfpicture, tikzpicture, endtikzpicture, %
psgraph, endpsgraph,nopreview,postscript, arara,extrenv,deltenv,skipenv},%
@@ -602,7 +688,7 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
keywords=[5]{images,includegraphics,env,file-out,pics,doc},%
% Reserved in orange
keywordstyle=[6]{\color{red}},%
- keywords=[6]{verb},%
+ keywords=[6]{verb,myverb},%
}[keywords,tex,comments,strings]% end languaje
% \begin{examplecode}[optlst]...\end{examplecode}
@@ -612,26 +698,31 @@ Copyright 2013 - 2018 by Pablo González L <pablgonz@yahoo.com>.
stringstyle = {\color{red}},%
basicstyle=\ttfamily\small,%
numbersep=1em,%
- numberstyle=\tiny\color{lightgray}\noaccsupp,%
+ numberstyle=\tiny\color{gray}\noaccsupp,%
+ rulecolor=\color{gray!50},%
+ framesep=\fboxsep,%
+ framerule=\fboxrule,%
+ xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,%
+ xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,%
% literateee
-literate=*{\{}{{\bfseries\textcolor{gray}{\{}}}{1}
- {\}}{{\bfseries\textcolor{gray}{\}}}}{1}
- {[}{{\bfseries\textcolor{optcolor}{[}}}{1}
- {]}{{\bfseries\textcolor{optcolor}{]}}}{1}
- {*}{{\bfseries\textcolor{red}{*}}}{1}
- {:}{{\textcolor{red}{:}}}{1}
- {,}{{\textcolor{gray}{,}}}{1}
- {=}{{\textcolor{gray}{=}}}{1}
- {/}{{\textcolor{gray}{/}}}{1}
- {\%\ ltximg}{{\textcolor{gray}{\%}\space\bfseries\textcolor{optcolor}{ltximg}}}{8}
- {\%\ arara}{{\textcolor{gray}{\%}\space\bfseries\textcolor{optcolor}{arara}}}{7}
- {\{arara}{{\textcolor{gray}{\{arara}}}{6}
- {\%<*remove>}{{\bfseries\textcolor{gray}{\%<*remove>}}}{10}
- {\%</remove>}{{\bfseries\textcolor{gray}{\%</remove>}}}{10}
- {\%<*ltximg>}{{\bfseries\textcolor{gray}{\%<*ltximg>}}}{10}
- {\%</ltximg>}{{\bfseries\textcolor{gray}{\%</ltximg>}}}{10}
- {\%<*noltximg>}{{\bfseries\textcolor{gray}{\%<*noltximg>}}}{12}
- {\%</noltximg>}{{\bfseries\textcolor{gray}{\%</noltximg>}}}{12},%
+ literate=*{\{}{{\bfseries\textcolor{gray}{\{}}}{1}
+ {\}}{{\bfseries\textcolor{gray}{\}}}}{1}
+ {[}{{\bfseries\textcolor{optcolor}{[}}}{1}
+ {]}{{\bfseries\textcolor{optcolor}{]}}}{1}
+ {*}{{\bfseries\textcolor{red}{*}}}{1}
+ {:}{{\textcolor{red}{:}}}{1}
+ {,}{{\textcolor{gray}{,}}}{1}
+ {=}{{\textcolor{gray}{=}}}{1}
+ {/}{{\textcolor{gray}{/}}}{1}
+ {\%\ ltximg}{{\textcolor{gray}{\%}\space\bfseries\textcolor{optcolor}{ltximg}}}{8}
+ {\%\ arara}{{\textcolor{gray}{\%}\space\bfseries\textcolor{optcolor}{arara}}}{7}
+ {\{arara}{{\textcolor{gray}{\{arara}}}{6}
+ {\%<*remove>}{{\bfseries\textcolor{gray}{\%<*remove>}}}{10}
+ {\%</remove>}{{\bfseries\textcolor{gray}{\%</remove>}}}{10}
+ {\%<*ltximg>}{{\bfseries\textcolor{gray}{\%<*ltximg>}}}{10}
+ {\%</ltximg>}{{\bfseries\textcolor{gray}{\%</ltximg>}}}{10}
+ {\%<*noltximg>}{{\bfseries\textcolor{gray}{\%<*noltximg>}}}{12}
+ {\%</noltximg>}{{\bfseries\textcolor{gray}{\%</noltximg>}}}{12},%
#1,%
}% close lstset
}%
@@ -660,70 +751,44 @@ literate=*{\{}{{\bfseries\textcolor{gray}{\{}}}{1}
classoffset=5,%
keywordstyle=\color{blue},%
keywords={user,machine},%
-% literateee
-literate=*{[}{{\textcolor{darkgray}{[}}}{1}
- {]}{{\textcolor{darkgray}{]}}}{1}
- {@}{{\textcolor{blue}{@}}}{1}
- {\$}{{\textcolor{blue}{\$}}}{1}
- {:}{{\textcolor{blue}{:}}}{1}
- {§}{{\textcolor{red}{\$}}}{1}
- {"}{{\textcolor{red}{\textquotedbl}}}{1}
- {~}{{\textcolor{blue}{\bfseries\textasciitilde}}}{1}%
- }% close lstset {~}
+ literate=*{[}{{\textcolor{darkgray}{[}}}{1}
+ {]}{{\textcolor{darkgray}{]}}}{1}
+ {@}{{\textcolor{blue}{@}}}{1}
+ {\$}{{\textcolor{blue}{\$}}}{1}
+ {:}{{\textcolor{blue}{:}}}{1}
+ {§}{{\textcolor{red}{\$}}}{1}
+ {~}{{\textcolor{blue}{\bfseries\textasciitilde}}}{1}%
+ }% close lstset
}%
{}% close examplecmd
% \lstinline[style=inline]|...|
\lstdefinestyle{inline}
-{
- language=ltximg-doc,%
- basicstyle=\ttfamily\color{gray},%
-% literateee
-literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1}
-}
+ {
+ language=ltximg-doc,%
+ basicstyle=\ttfamily\color{gray},%
+ escapechar=`,%
+ upquote=true,%
+ literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1}
+ }
% set default style
\lstset{style=inline}
-% email https://tex.stackexchange.com/a/663
-\catcode`\_=11\relax%
-\newcommand\email[1]{\_email #1\q_nil}%
-\def\_email#1@#2\q_nil{%
- \href{mailto:#1@#2}{{\emailfont #1\emailampersat #2}}%
-}%
-\newcommand\emailfont{\sffamily}%
-\newcommand\emailampersat{{\color{NavyBlue}\footnotesize@}}%
-\catcode`\_=8\relax% %
-
-% Table of contents, need change font style
-\def\rulecolor{\color{NavyBlue}}
-\tocsetup{%
- title=Contents\quad{\rulecolor\leaders\vrule height3.4pt depth-3pt\hfill\null},
- title/after= \vspace{3pt},
- title/font= \sffamily\bfseries\Large,%
- title/top=10pt,%
- title/bottom=0pt,%
- twocolumns,
- section/skip=4pt plus2pt minus2pt,%
- subsection/skip=0pt plus2pt minus2pt,
- section/leaders,section/dotsep,%
- after=\vspace{-3pt}\noindent{\rulecolor\hrule height3.4pt depth-3pt\relax},
-}
\begin{document}
-
\title{%
- \textffm{latex environments}\\[3pt]%
+ {\fetamono latex environments }\\[3pt]%
\scalebox{3.4}{\LTXimg}\\[2pt]%
- \textls[150]{\textffm{to image format}}\\%
+ {\fetamono\addfontfeature{LetterSpace=12.0} to image format}\\%
\Large
v\fileversion{} --- \filedate\thanks{%
This file describes a documentation for version \fileversion, last revised \filedate.}\\[25pt]%
\author{%
\large%
- \raisebox{-1pt}{\textcopyright}{}2013--2018 by Pablo González L%
- \thanks{E-mail:<\email{pablgonz@yahoo.com}>}%
+ \raisebox{-1pt}{\textcopyright}{}2013--2019 by Pablo González L%
+ \thanks{E-mail: \texttt{\guillemotleft}\email{pablgonz@yahoo.com}\texttt{\guillemotright}}
}%
\small
\textsc{ctan}: \url{http://www.ctan.org/pkg/ltximg}\\
@@ -734,90 +799,108 @@ literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1}
\maketitle
\begin{abstract}
-\ltximg is a \prgname{perl} \emph{script} that automates the process of extracting and
-converting environments provided by \pkgname{tikz}, \pkgname{pstricks} and
-other packages from input file to image formats in individual files using \prgname{ghostscript}
-and \prgname{poppler-utils}. Generates a file with only extracted environments and another with environments
-converted to \ics{includegraphics}.
+\ltximg{} is a \prgname{perl} \emph{script} that automates the process of
+extracting and converting environments provided by \pkgname{tikz}, %
+\pkgname{pstricks} and other packages from \meta{input file} to image
+formats in individual files using \prgname{ghostscript} and %
+\prgname{poppler-utils}. Generates a file with only extracted environments
+and another with environments converted to \ics{includegraphics}.
\end{abstract}
\tableofcontents
\setlength{\parskip}{3pt}
\section{Motivation}
+
The original idea was to extend the functionality of the \scriptname{pst2pdf}
-script (only for \env{pspicture} and \env{postscript}) to work with \env{tikzpicture}
-and other environments.
+script (only for \env{pspicture} and \env{postscript}) to work with %
+\env{tikzpicture} and other environments.
+
+The \pkgname{tikz} package allows to externalize the environments, but, the
+idea was to be able to extend this to any type of environment covering three
+central points:
-The \pkgname{tikz} package allows to externalize the environments, but, the idea was to be
-able to extend this to any type of environment covering three central points:
+\begin{enumerate}[font=\small , noitemsep,leftmargin=*]
-\begin{enumerate}[font=\small, noitemsep,leftmargin=*]
\item Generate separate files for environments and converted into images.
+
\item Generate a file with only the extracted environments.
+
\item Generate a file replacing the environments by \ics{includegraphics}.
\end{enumerate}
From the side of \TeX{} there are some packages that cover several of these
-points such as the \pkgname{preview}, \pkgname{xcomment}, \pkgname{external} and \pkgname{cachepic} packages among others,
-but none covered all points.
+points such as the \pkgname{preview}, \pkgname{xcomment}, \pkgname{external}
+and \pkgname{cachepic} packages among others, but none covered all points.
In the network there are some solutions in \texttt{bash} that were able to
-extract and convert environments, but in general they presented problems when the document
-contained \emph{verbatim style} code or were only available for \OSsystem{Linux}.
+extract and convert environments, but in general they presented problems
+when the document contained \emph{verbatim style} code or were only
+available for \OSsystem{Linux}.
-Analysed the situation the best thing was to create a new \emph{script} that was able
-to cover the three points and was multi platform, the union of all these ideas is
-born \ltximg. Finding the correct \emph{regular expressions} and writing \emph{documentation}
-would be the great mission (which does not end yet).
+Analysed the situation the best thing was to create a new \emph{script} that
+was able to cover the three points and was multi platform, the union of all
+these ideas is born \ltximg. Finding the correct \emph{regular expressions}
+and writing \emph{documentation} would be the great mission (which does not
+end yet).
\thispagestyle{plain}
\newpage
\pagestyle{myheader}
\section{Required Software}\label{sec:software}
-For the complete operation of \ltximg{} you need to have a modern \hologo{TeX}
-distribution such as \hologo{TeX}Live 2017 or \hologo{MiKTeX} 2.9, have a version equal to or
-greater than \liningnums{5.22} of \prgname{perl}, a version equal to or greater than \liningnums{9.19} of
-\prgname{ghostscript} and have a version equal to or greater than \liningnums{0.52} of \prgname{poppler-utils}.
+For the complete operation of \ltximg{} you need to have a modern %
+\hologo{TeX} distribution such as \hologo{TeX}Live or \hologo{MiKTeX}, have
+a version equal to or greater than \liningnums{5.28} of \prgname{perl}, a
+version equal to or greater than \liningnums{9.24} of \prgname{ghostscript}
+and have a version equal to or greater than \liningnums{0.52} of %
+\prgname{poppler-utils}.
-The distribution of \hologo{TeX}Live 2017 for \OSsystem{Windows} includes \ltximg{} and all
-requirements, \hologo{MiKTeX} users must install the appropriate software for full operation.
+The distribution of \hologo{TeX}Live 2019 for \OSsystem{Windows} includes %
+\ltximg{} and all requirements, \hologo{MiKTeX} users must install the
+appropriate software for full operation.
-The script has been tested on \OSsystem{Windows} (version 10) and \OSsystem{Linux} (fedora 27) in x64 architecture using
-\prgname{ghostscript} \liningnums{v9.20}, \prgname{poppler-utils} \liningnums{v0.52} to \liningnums{v0.60} and
-\prgname{perl} from \liningnums{v5.22} to \liningnums{v5.26}.
+The script has been tested on \OSsystem{Windows} (version 10) and %
+\OSsystem{Linux} (fedora 30) in x64 architecture using \prgname{ghostscript} %
+\liningnums{v9.26}, \prgname{poppler-utils} \liningnums{v0.52} to %
+\liningnums{v0.73} and \prgname{perl} from \liningnums{v5.28} to %
+\liningnums{v5.30}.
-\section{How it works}\label{sec:howtowork}
+\section{How it works}
-It is important to have a general idea of how the \emph{extraction and conversion}
-process works and the requirements that must be fulfilled so that everything
-works correctly, for this we must be clear about some concepts related to how to
-work with the \meta{verbatim content}, the \meta{input file}, the \meta{output file} and the
-\meta{steps process}.
+\label{sec:howtowork}
-\subsection{The input file}\label{sec:inputfile}
+It is important to have a general idea of how the \emph{extraction and
+conversion} process works and the requirements that must be fulfilled so
+that everything works correctly, for this we must be clear about some
+concepts related to how to work with the \meta{verbatim content}, the %
+\meta{input file}, the \meta{output file} and the \meta{steps process}.
-The \meta{input file} must comply with certain characteristics in
-order to be processed, the content at the beginning and at the end of the \meta{input file}
-is treated in a special way, before \lstinline|\documentclass| can only be commented lines and
-after \lstinline|\end{document}| can go any type of content, internally
-will split the \meta{input file} at this points.
+\subsection{The input file}
-If the \meta{input file} contains files using \ics{input} or \ics{include} these
-will not be processed, from the side of the \emph{script} they only represent
-lines within the file, if you want them to be processed it is better to use the
-\scriptname{latexpand} first and then process the file.
+\label{sec:inputfile}
+
+The \meta{input file} must comply with certain characteristics in order to
+be processed, the content at the beginning and at the end of the \meta{input
+file} is treated in a special way, before \lstinline|\documentclass| can only be
+commented lines and after \lstinline|\end{document}| can go any type of content,
+internally will split the \meta{input file} at this points.
+
+If the \meta{input file} contains files using \ics{input} or \ics{include}
+these will not be processed, from the side of the \emph{script} they only
+represent lines within the file, if you want them to be processed it is
+better to use the \scriptname{latexpand} first and then process the file.
Like \ics{input} or \ics{include}, blank lines, vertical spaces and tab
-characters are treated literally, for the \emph{script} the \meta{input file} is just a set of
-characters, as if it was a simple text file. It is advisable to format the source code \meta{input file}
-using utilities such as lines such as \prgname{chktex} and \scriptname{latexindent}, especially if you want to
+characters are treated literally, for the \emph{script} the \meta{input file}
+is just a set of characters, as if it was a simple text file. It is
+advisable to format the source code \meta{input file} using utilities such
+as \prgname{chktex} and \scriptname{latexindent}, especially if you want to
extract the source code of the environments.
An example of the \meta{input file}:
-\begin{examplecode}
+\begin{examplecode}[numbers=left,frame=single]
% some commented lines at begin document
\documentclass{article}
\usepackage{tikz}
@@ -844,26 +927,30 @@ that \emph{verbatim style} content produces with the extraction of environments.
In order to skip the complications, the verbatim content is classified into
three types:
-\begin{itemize}
- \item Verbatim in line
- \item Verbatim standard
- \item Verbatim write
+\begin{itemize}[nosep]
+ \item Verbatim in line
+ \item Verbatim standard
+ \item Verbatim write
\end{itemize}
Each of these classifications works differently within the creation and
extraction process using different regular expressions for it.
+
\newpage
-\subsubsection{Verbatim in line}\label{sec:verbatim:inline}
+\subsubsection{Verbatim in line}
-The small pieces of code written in the same line using a verbatim command are
-considered \meta{verbatim in line}, such as \lstinline+\verb|<code>|+. Most verbatim commands
-provide by packages \pkgname{minted}, \pkgname{fancyvrb} and \pkgname{listings} have
-been tested and are fully supported. They are automatically detected the verbatim command generates
-by \ics{newmint} and \ics{newmintinline} and the following command list:
+\label{sec:verbatim:inline}
+
+The small pieces of code written in the same line using a verbatim command
+are considered \meta{verbatim in line}, such as \lstinline+\verb|<code>|+.
+Most verbatim commands provide by packages \pkgname{minted}, %
+\pkgname{fancyvrb} and \pkgname{listings} have been tested and are fully
+supported. They are automatically detected the verbatim command generates by
+\ics{newmint} and \ics{newmintinline} and the following command list:
\begin{multicols}{3}
-\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*]
+\begin{itemize}[font=\sffamily\small,partopsep=5pt,parsep=5pt,nosep,leftmargin=*]
\small
\item \ics{mint}
\item \ics{spverb}
@@ -879,33 +966,39 @@ by \ics{newmint} and \ics{newmintinline} and the following command list:
\end{itemize}
\end{multicols}
-Some packages define abbreviated versions for verbatim commands as \ics{DefineShortVerb}, \ics{lstMakeShortInline}
-and \ics{MakeSpecialShortVerb}, will be detected automatically if are declared explicitly in \meta{input file}.
+Some packages define abbreviated versions for verbatim commands as %
+\ics{DefineShortVerb}, \ics{lstMakeShortInline} and %
+\ics{MakeSpecialShortVerb}, will be detected automatically if are declared
+explicitly in \meta{input file}.
-The following consideration should be kept in mind for some packages that use
-abbreviations for verbatim commands, such as \pkgname{shortvrb} or \pkgname{doc}
-for example in which there is no explicit command in the document by means of
-which the abbreviated form can be detected, for automatic detection need to find
-\ics{DefineShortVerb} explicitly to process it correctly.
-The solution is quite simple, just add in \meta{input file}:
+The following consideration should be kept in mind for some packages that
+use abbreviations for verbatim commands, such as \pkgname{shortvrb} or %
+\pkgname{doc} for example in which there is no explicit command in the
+document by means of which the abbreviated form can be detected, for
+automatic detection need to find \ics{DefineShortVerb} explicitly to process
+it correctly. The solution is quite simple, just add in \meta{input file}:
\begin{examplecode}
\UndefineShortVerb{\|}
\DefineShortVerb{\|}
\end{examplecode}
-depending on the package you are using. If your verbatim command is not supported
-by default or can not detect, use the options described in \ref{sec:optline} and \ref{sec:optfile}.
+depending on the package you are using. If your verbatim command is not
+supported by default or can not detect, use the options described in \ref%
+{sec:optline} and \ref{sec:optfile}.
+
+\subsubsection{Verbatim standard}
-\subsubsection{Verbatim standard}\label{sec:verbatim:std}
+\label{sec:verbatim:std}
-These are the classic environments for writing code are considered \meta{verbatim standard},
-such as \env{verbatim} and \env{lstlisting} environments. The following list is considered
-as \meta{verbatim standard} environments:
+These are the classic environments for writing code are considered %
+\meta{verbatim standard}, such as \env{verbatim} and \env{lstlisting}
+environments. The following list is considered as \meta{verbatim standard}
+environments:
\begin{multicols}{4}
\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*]
-\sffamily\small
+\ttfamily\small
\item Example
\item CenterExample
\item SideBySideExample
@@ -965,21 +1058,26 @@ They are automatically detected \meta{verbatim standard} environments generates
\end{itemize}
\end{multicols}
-If any of the \meta{verbatim standard} environments is not supported by default or can
-not detected, you can use the options described in \ref{sec:optline} and \ref{sec:optfile}.
+If any of the \meta{verbatim standard} environments is not supported by
+default or can not detected, you can use the options described in \ref%
+{sec:optline} and \ref{sec:optfile}.
-\subsubsection{Verbatim write}\label{sec:verbatim:write}
+\subsubsection{Verbatim write}
-Some environments have the ability to write external files directly, these environments are considered
-\meta{verbatim write}, such as \env{filecontents} or \env{VerbatimOut} environments. The following list
-is considered as \meta{verbatim write} environments:
+\label{sec:verbatim:write}
+
+Some environments have the ability to write external files directly, these
+environments are considered \meta{verbatim write}, such as \env{filecontents}
+or \env{VerbatimOut} environments. The following list is considered as %
+\meta{verbatim write} environments:
\begin{multicols}{3}
\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*]
-\small
+\ttfamily\small
\item filecontents
\item tcboutputlisting
\item tcbexternal
+\item tcbwritetmp
\item extcolorbox
\item extikzpicture
\item VerbatimOut
@@ -989,7 +1087,8 @@ is considered as \meta{verbatim write} environments:
\end{itemize}
\end{multicols}
-They are automatically detected \meta{verbatim write} environments generates by commands:
+They are automatically detected \meta{verbatim write} environments generates
+by commands:
\begin{multicols}{2}
\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*]
@@ -1001,18 +1100,23 @@ They are automatically detected \meta{verbatim write} environments generates by
\end{itemize}
\end{multicols}
-If any of the \meta{verbatim write} environments is not supported by default or can
-not detected, you can use the options described in \ref{sec:optline} and \ref{sec:optfile}.
+If any of the \meta{verbatim write} environments is not supported by default
+or can not detected, you can use the options described in \ref{sec:optline}
+and \ref{sec:optfile}.
-\subsection{Steps process}\label{sec:steps:process}
+\subsection{Steps process}
-For creation of the image formats, extraction of code and creation of an
-output file, \ltximg{} need a various steps. Let's assume that the \meta{input file} is \sysfile{test.tex},
-\meta{output file} is \sysfile{test-out}, the working directory are \sysdir{workdir}, the directory
-for images are \sysdir{workdir/images} and the user's temporary directory is \sysdir{tmp} and we
-want to generate images in \iext{pdf} format together with the source codes of the environments.
+\label{sec:steps:process}
-\begin{description}[font=\sffamily\small, leftmargin=0em,style=nextline]
+For creation of the image formats, extraction of code and creation of an
+output file, \ltximg{} need a various steps. Let's assume that the %
+\meta{input file} is \sysfile{test.tex}, \meta{output file} is %
+\sysfile{test-out}, the working directory are \sysdir{workdir}, the
+directory for images are \sysdir{workdir/images} and the user's temporary
+directory is \sysdir{tmp} and we want to generate images in \iext{pdf}
+format together with the source codes of the environments.
+
+\begin{description}[font=\sffamily\small,leftmargin=0em,style=nextline]
\item[Comment and ignore]
The first step is read and validated \oarg[type=rm,cf=gray,sbc=optcolor,ac=gray]{options} from the command
line and \sysfile{test.tex}, verifying that \sysfile{test.tex}, \sysfile{test-out} and the
@@ -1071,7 +1175,7 @@ Note the options passed to \meta[type=tt,cf=ForestGreen,ac=ForestGreen]{compiler
In the fourth step the script creates the output file \sysfile{test-out.tex} converting all extracted code to
\ics{includegraphics} and adding the following lines at end of preamble:
-\begin{examplecode}
+\begin{examplecode}[numbers=left]
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{grfext}
@@ -1090,7 +1194,7 @@ temporary files generated in the process and then delete them together with the
An example for input and output file:
\begin{minipage}[c]{0.5\textwidth}
-\begin{examplecode}
+\begin{examplecode}[numbers=left]
\documentclass{article}
\usepackage{tikz}
\begin{document}
@@ -1112,7 +1216,7 @@ Some text
\end{flushleft}
\end{minipage}
\begin{minipage}[c]{0.5\textwidth}
-\begin{examplecode}
+\begin{examplecode}[numbers=left]
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
@@ -1133,9 +1237,9 @@ Some text
\sysfile{test-out.tex}
\end{flushleft}
\end{minipage}
-\newpage
-\section{Extract content}\label{sec:extract}
+\section{Extract content}
+\label{sec:extract}
The script provides two ways to extract content from \meta{input file}, using \meta[type=rm,cf=optcolor,ac=gray]{environments}
and \meta[type=rm,cf=optcolor,ac=gray]{docstrip tags}. Some environment (including a starred \texttt{\small\bfseries\textcolor{red}{*}} version)
are supported by default and if the environments are nested, the outermost will be extracted.
@@ -1190,13 +1294,15 @@ package with the [\pkgopt{swpl}] or [\pkgopt{tcb}] option and run the script
using \cmdopt{latex}{} or \cmdopt{xetex}.
If you need to extract more environments you can use one of the options described in \ref{sec:optline} or \ref{sec:optfile}.
+
\subsection{Extract whit docstrip tags}
+
\label{sec:extract:tag}
\DescribeTE*{ltximg}
All content included between \lstinline|%<*ltximg> ... %</ltximg>| is extracted.
The tags can not be nested and should be at the beginning of the line and in separate lines.
-\begin{examplecode}
+\begin{examplecode}[frame=single]
% no space before open tag %<*
%<*ltximg>
code to extract
@@ -1219,7 +1325,7 @@ Is better comment this package in preamble unless the option \cmdopt[n]{noprew}{
All content betwen \lstinline|%<*noltximg> ... %</noltximg>| are ignored and no
extract. The start and closing of the tag must be at the beginning of the line.
-\begin{examplecode}
+\begin{examplecode}[frame=single]
% no space before open tag %<*
%<*noltximg>
no extract this
@@ -1231,7 +1337,7 @@ no extract this
All content betwen \lstinline|%<*remove> ... %</remove>| are deleted in the \meta{output file}. The start and closing
of the tag must be at the beginning of the line.
-\begin{examplecode}
+\begin{examplecode}[frame=single]
% no space before open tag %<*
%<*remove>
lines removed in output file
@@ -1239,10 +1345,12 @@ lines removed in output file
% no space before close tag %</
\end{examplecode}
-If you want to remove specific environments automatically you can use one of the options described in \ref{sec:optline} or \ref{sec:optfile}.
+If you want to remove specific environments automatically you can use one of
+the options described in \ref{sec:optline} or \ref{sec:optfile}.
\section{Image Formats}\label{sec:image:format}
-The \meta{image formats} generated by the \ltximg{} using \prgname{ghostscript} and \textcolor{ForestGreen}{\ttfamily\bfseries poppler-utils}
+The \meta{image formats} generated by the \ltximg{} using \prgname{ghostscript}
+and \textcolor{ForestGreen}{\ttfamily\bfseries poppler-utils}
are the following command lines:
\DescribeIF{pdf}
@@ -1266,6 +1374,8 @@ The image format generated using \prgname{ghostscript}. The line executed by the
[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pngalpha -r 150
\end{examplecmd}
+\newpage
+
\DescribeIF{jpg}
The image format generated using \prgname{ghostscript}. The line executed by the system is:
\begin{examplecmd}
@@ -1300,7 +1410,6 @@ The image format generated using \prgname{ghostscript}. The line executed by the
\begin{examplecmd}
[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=bmp32b -r 150
\end{examplecmd}
-\newpage
\section{How to use}
\subsection{Syntax}
@@ -1315,7 +1424,8 @@ relative or absolute paths for files and directories is not supported. If used w
and \oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options} the extracted environments are converted to \iext{pdf}
image format and saved in the \sysdir{images} directory using \prgname*{pdflatex} and \pkgname{preview} package.
-\subsection{Options in command line}\label{sec:optline}
+\subsection{Options in command line}
+\label{sec:optline}
\ltximg{} provides a \emph{command line interface} with short and long option names.
They may be given before the name of the file. Also, the order of specifying the
@@ -1330,7 +1440,7 @@ Display a command line help text and exit.
Display a license text and exit.
\DescribeCmd[v]{version}{bolean}{off}
-Display the current version (1.5) and exit.
+Display the current version (\fileversion) and exit.
\DescribeCmd[d]{dpi}{int}{150}
Dots per inch for images files.
@@ -1370,7 +1480,6 @@ When using the \cmdopt{force} option the script will try to capture \lstinline|\
\lstinline|\tikzset{...}| and leave it inside the \env{preview} environment, any line that is between \lstinline|\psset{...}| and
\lstinline|\begin{pspicture}| or between \lstinline|\tikzset{...}| and \lstinline|\begin{tikzpicture}| will be captured.
-\newpage
\DescribeCmd[n]{noprew}{bolean}{off}
Create images files without \pkgname{preview} package. The \lstinline|\begin{preview}|\ldots \lstinline|\end{preview}|
lines are only used as delimiters for extracting the content \emph{without} using the package \pkgname{preview}.
@@ -1386,6 +1495,14 @@ The \meta{output file name} must not contain extension.
\DescribeCmd{imgdir}{string}{images}
The name of directory for save images and source code.
+\DescribeCmd{zip}{bolean}{off}
+Compress only the files generated by the script during the process in \sysdir{images} in \fext{zip} format.
+Does not include \meta{output file}.
+
+\DescribeCmd{tar}{bolean}{off}
+Compress only the files generated by the script during the process in \sysdir{images} in \fext{tar.gz} format.
+Does not include \meta{output file}.
+
\DescribeCmd{verbose}{bolean}{off}
Show verbose information in screen and change \prgopt*{interaction} for compiler.
@@ -1397,7 +1514,8 @@ Create sub files whit \emph{preamble} and code for all extracted environments, i
\DescribeCmd{arara}{bolean}{off}
Use \prgname*{arara} for compiler files, need to pass \prgopt*{recorder} option to \meta{input file}:\par
-\lstinline|% arara : <compiler> : {options: "-recorder"}|
+
+\lstinline|% arara : <compiler> : { options: [-recorder] }|
\DescribeCmd{xetex}{bolean}{off}
Using \prgname*{xelatex} compiler \meta{input file} and \meta{output file}.
@@ -1410,6 +1528,8 @@ compiler in \meta{input file} and \prgname*{pdflatex} for \meta{output file}.
Using \prgname*{latex}\texttt{\bfseries\guillemotright}\prgname*{dvips}\texttt{\bfseries\guillemotright}\scriptname{ps2pdf}
for compiler \meta{input file} and \meta{output file}.
+\newpage
+
\DescribeCmd{dvipdf}{bolean}{off}
Using \prgname*{latex}\texttt{\bfseries\guillemotright}\prgname*{dvipdfmx} for compiler \meta{input file} and \meta{output file}.
@@ -1432,7 +1552,7 @@ Don't run \scriptname{pdfcrop} in image files.
\DescribeCmd{clean}{doc\textbar pst\textbar tkz\textbar all\textbar off}{doc}
Removes specific content in \meta{output file}. Valid values for this option are:
-\begin{description}[font=\small\sffamily, nosep, noitemsep, leftmargin=*]
+\begin{description}[font=\ttfamily, nosep, noitemsep, leftmargin=*]
\item[doc] All content after \lstinline+\end{document}+ is removed.
\item[pst] All \lstinline|\psset{...}| and \pkgname{pstricks} package is removed.
\item[tkz] All \lstinline|\tikzset{...}| is removed.
@@ -1440,7 +1560,6 @@ Removes specific content in \meta{output file}. Valid values for this option are
\item[off] Deactivate all.
\end{description}
-\newpage
\DescribeCmd{verbcmd}{command name}{myverb}
Set custom verbatim command \lstinline+\myverb|<code>|+.
@@ -1500,15 +1619,18 @@ This line is to indicate to the script which environments are deleted.
If you are going to create an \meta{output file} and you do not want these lines to remain, it is better to
place them inside the \lstinline|%<*remove> ... %</remove>|. Like this:
-\begin{examplecode}
+\begin{examplecode}[numbers=left]
%<*remove>
% ltximg : options : {png,srcenv,xetex}
% ltximg : extrenv : {description}
%</remove>
\end{examplecode}
-\newpage
-\section{Examples} \label{sec:examples}
+
+\section{Examples}
+\label{sec:examples}
+
+\subsection{From command line}
\begin{examplecmd}
[user@machine ~:]§ ltximg --latex -s -o test-out test-in.ltx
\end{examplecmd}
@@ -1518,8 +1640,10 @@ converted to \ics{includegraphics} and a single file \sysfile{test-in-fig-all.lt
using \prgname*{latex}\texttt{\bfseries\guillemotright}\prgname*{dvips}\texttt{\bfseries\guillemotright}\scriptname{ps2pdf}
and \pkgname{preview} package for \meta{input file} and \prgname*{pdflatex} for \meta{output file}.
+\subsection{From input file}
Adding the following lines to the beginning of the file \sysfile{file-in.tex}:
-\begin{examplecode}
+
+\begin{examplecode}[numbers=left]
%<*remove>
% ltximg : options : {output = file-out, noprew, imgdir = pics, prefix = env, clean = doc}
% ltximg : skipenv : {tikzpicture}
@@ -1535,36 +1659,45 @@ formats (\iext{pdf}) in individual files, an \meta{output file} \sysfile{file-ou
converted to \ics{includegraphics} and environment \env{filecontents} removed, a single file \sysfile{test-in-env-all.ltx}
with only the extracted environments using \prgname*{pdflatex} and \pkgname{preview} package for \meta{input file} and \meta{output file}.
+\newpage
+
\section{Change history}\label{sec:change:history}
Some of the notable changes in the history of the \ltximg{} along with the
versions, both development (devp) and public (ctan).
\setlist[itemize, 1]{label=\textendash, wide=0.5em, nosep, noitemsep, leftmargin=10pt}
+
% length for change history
\newlength\descrwidth
\settowidth{\descrwidth}{\textsf{v1.4.5, (ctan), 2013-01-23}}
\begin{description}[font=\small\sffamily, wide=0pt, style=multiline, leftmargin=\descrwidth, nosep, noitemsep]
-\item [v1.5 (ctan), 2017-04-12]
+\item [v\fileversion{} (ctan), \filedate]
+ \begin{itemize}
+ \item Add \texttt{zip} and \texttt{tar} options
+ \item Add new \texttt{Verb} from \texttt{fvextra}
+ \item Fix and update source code and documentation
+ \end{itemize}
+\item [v1.5 (ctan), 2018-04-12]
\begin{itemize}
\item Use \texttt{GitHub} to control version
- \item Rewrite and optimize most part of code and options
+ \item Rewrite and optimize most part of source code and options
\item Change \texttt{pdf2svg} for \texttt{pdftocairo}
\item Complete support for \texttt{pst-exa} package
- \item Escape characters in regex according to v5.4x.x
+ \item Escape characters in regex according to \texttt{perl} v5.4x.x
\end{itemize}
\item [v1.4 (devp), 2016-11-29]
\begin{itemize}
\item Remove and rewrite code for regex and system call
- \item Append \texttt{arara} compiler, clean and comment code
- \item Append \texttt{dvips} and \texttt{dvipdfm(x)} for creation images
- \item Append \texttt{bmp}, \texttt{tiff} image format
+ \item Add \texttt{arara} compiler, clean and comment code
+ \item Add \texttt{dvips} and \texttt{dvipdfm(x)} for creation images
+ \item Add \texttt{bmp}, \texttt{tiff} image format
\end{itemize}
\item [v1.3 (devp), 2016-08-14]
\begin{itemize}
\item Rewrite some part of code (norun, nocrop, clean)
- \item Suport \texttt{minted} and \texttt{tcolorbox} package for verbatim
- \item Escape some characters in regex according to v5.2x.x
+ \item Suport \texttt{minted} and \texttt{tcolorbox} package
+ \item Escape some characters in regex according to \texttt{perl} v5.2x.x
\item All options read from command line and input file
\item Use \texttt{/tmp} dir for work process
\end{itemize}
@@ -1588,7 +1721,12 @@ versions, both development (devp) and public (ctan).
\end{description}
\newpage
-\clearpage
-\PrintIndex
+
+\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
+\cleardoublepage
+\phantomsection
+%\printindex[mydoc]
+%\PrintIndex
+\printindex
\end{document}
%</documentation>