From 6a10b4335e0035a4466860173ced955e14b514d4 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 24 Aug 2020 20:55:24 +0000 Subject: pst2pdf (24aug20) git-svn-id: svn://tug.org/texlive/trunk@56172 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/pst2pdf/pst2pdf.pl | 282 +++-- Master/texmf-dist/doc/latex/pst2pdf/Changes | 37 - Master/texmf-dist/doc/latex/pst2pdf/README.md | 93 -- .../texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib | 149 --- .../texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf | Bin 154083 -> 0 bytes .../texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex | 1244 -------------------- Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf | Bin 136593 -> 0 bytes Master/texmf-dist/doc/latex/pst2pdf/test1.tex | 69 -- Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf | Bin 108349 -> 0 bytes Master/texmf-dist/doc/latex/pst2pdf/test2.tex | 66 -- Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf | Bin 62819 -> 0 bytes Master/texmf-dist/doc/latex/pst2pdf/test3.tex | 27 - Master/texmf-dist/doc/latex/pst2pdf/tux.jpg | Bin 51709 -> 0 bytes Master/texmf-dist/doc/support/pst2pdf/Changes | 40 + Master/texmf-dist/doc/support/pst2pdf/Makefile.doc | 47 + Master/texmf-dist/doc/support/pst2pdf/README.md | 93 ++ .../texmf-dist/doc/support/pst2pdf/pst2pdf-doc.bib | 149 +++ .../texmf-dist/doc/support/pst2pdf/pst2pdf-doc.pdf | Bin 0 -> 132936 bytes .../texmf-dist/doc/support/pst2pdf/pst2pdf-doc.tex | 1242 +++++++++++++++++++ .../texmf-dist/doc/support/pst2pdf/test1-pdf.pdf | Bin 0 -> 136602 bytes Master/texmf-dist/doc/support/pst2pdf/test1.tex | 69 ++ .../texmf-dist/doc/support/pst2pdf/test2-pdf.pdf | Bin 0 -> 108348 bytes Master/texmf-dist/doc/support/pst2pdf/test2.tex | 66 ++ .../texmf-dist/doc/support/pst2pdf/test3-pdf.pdf | Bin 0 -> 62821 bytes Master/texmf-dist/doc/support/pst2pdf/test3.tex | 27 + Master/texmf-dist/doc/support/pst2pdf/tux.jpg | Bin 0 -> 51709 bytes Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl | 282 +++-- Master/tlpkg/libexec/ctan2tds | 4 +- 28 files changed, 2040 insertions(+), 1946 deletions(-) delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/Changes delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/README.md delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test1.tex delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test2.tex delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/test3.tex delete mode 100644 Master/texmf-dist/doc/latex/pst2pdf/tux.jpg create mode 100644 Master/texmf-dist/doc/support/pst2pdf/Changes create mode 100644 Master/texmf-dist/doc/support/pst2pdf/Makefile.doc create mode 100644 Master/texmf-dist/doc/support/pst2pdf/README.md create mode 100644 Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.bib create mode 100644 Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.pdf create mode 100644 Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.tex create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test1-pdf.pdf create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test1.tex create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test2-pdf.pdf create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test2.tex create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test3-pdf.pdf create mode 100644 Master/texmf-dist/doc/support/pst2pdf/test3.tex create mode 100644 Master/texmf-dist/doc/support/pst2pdf/tux.jpg diff --git a/Build/source/texk/texlive/linked_scripts/pst2pdf/pst2pdf.pl b/Build/source/texk/texlive/linked_scripts/pst2pdf/pst2pdf.pl index 3b33bdbf91c..a0cf34c638c 100755 --- a/Build/source/texk/texlive/linked_scripts/pst2pdf/pst2pdf.pl +++ b/Build/source/texk/texlive/linked_scripts/pst2pdf/pst2pdf.pl @@ -2,8 +2,7 @@ use v5.26; ############################# LICENCE ################################## -# $Id: pst2pdf.pl 119 2014-09-24 12:04:09Z herbert $ # -# v0.19 2020-08-16 simplify the use of PSTricks with pdf # +# v0.20 2020-08-24 simplify the use of PSTricks with pdf # # (c) Herbert Voss # # Pablo González L # # # @@ -51,7 +50,6 @@ my $norun = 0; # 1->no create images my $noprew = 0; # 1->create images in nopreview mode my $runbibtex = 0; # 1->runs bibtex my $runbiber = 0; # 1->runs biber and sets $runbibtex=0 -my $all = 0; # 1->create all images and files for type my $xetex = 0; # 1->Using (Xe)LaTeX for compilation. my $luatex = 0; # 1->Using dvilualatex for compilation. my $latexmk = 0; # 1->Using latexmk for compiler output file. @@ -81,9 +79,9 @@ my %opts_cmd; # hash to store options for Getopt::Long and log ### Script identification my $scriptname = 'pst2pdf'; -my $nv = 'v0.19'; -my $date = '2020-08-17'; -my $ident = '$Id: pst2pdf.pl 119 2020-08-16 12:04:09Z herbert $'; +my $nv = 'v0.20'; +my $date = '2020-08-22'; +my $ident = '$Id: pst2pdf.pl 119 2020-08-22 12:04:09Z herbert $'; ### Log vars my $LogFile = "$scriptname.log"; @@ -347,7 +345,7 @@ my $result=GetOptions ( 'imgdir=s' => \$imgdir, # string 'myverb=s' => \$myverb, # string 'ignore=s' => \$tmpverbenv, # string - 'c|clear' => \$clear, # flag + 'c|clear' => \$clear, # flag (unused) 'ni|norun|noimages' => \$norun, # flag 'np|noprew|single' => \$noprew, # flag 'bibtex' => \$runbibtex,# flag @@ -368,7 +366,6 @@ my $result=GetOptions ( 's|svg' => \$opts_cmd{image}{svg}, # pdftocairo 'e|eps' => \$opts_cmd{image}{eps}, # pdftops 'P|ppm' => \$opts_cmd{image}{ppm}, # pdftoppm - 'a|all' => \$all, # flag 'x|xetex' => \$xetex, # flag 'luatex' => \$luatex, # flag 'ns|nosource' => \$nosource, # flag @@ -1153,14 +1150,15 @@ if (@env_preview) { ### Pass verbatim write environments to dtxtag Log("Pass verbatim write environments to %<*$dtxverb> ... %"); -$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| - ($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| + ($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$atbegindoc =~ s/($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; ### Pass verbatim environments to dtxtag Log("Pass verbatim environments to %<*$dtxverb> ... %"); -$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| - \%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - ($verb_std)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| + \%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ($verb_std)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; ### Pass %CleanPST to dtxtag Log("Pass %CleanPST ... %CleanPST to %<*remove$tmp> ... %"); @@ -1409,9 +1407,7 @@ if (!$norun) { } ### Set -q for system command line (gs, poppler-utils, dvips) -my $quiet = $verbose ? q{} - : '-q' - ; +my $quiet = $verbose ? q{} : '-q'; ### Set options for ghostscript my %opt_gs_dev = ( @@ -1590,6 +1586,7 @@ $preamout =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; ### Remove %<*$dtxverb> ... % in tmpbodydoc and preamout $tmpbodydoc =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; $preamout =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; +$atbeginout =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; ### Adjust nopreview environments $tmpbodydoc =~ s/\\begin\{nopreview\}\%$tmp @@ -1848,45 +1845,6 @@ if (!$norun) { ### Constant my $findgraphicx = 'true'; -### Suport for pst-exa package -my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x; -my @pst_exa; -my %pst_exa; - -### Possible packages that load graphicx -my @pkgcandidates = qw ( - rotating epsfig lyluatex xunicode parsa xepersian-hm gregoriotex teixmlslides - teixml fotex hvfloat pgfplots grfpaste gmbase hep-paper postage schulealt - schule utfsym cachepic abc doclicense rotating epsfig semtrans mgltex - graphviz revquantum mpostinl cmpj cmpj2 cmpj3 chemschemex register papercdcase - flipbook wallpaper asyprocess draftwatermark rutitlepage dccpaper-base - nbwp-manual mandi fmp toptesi isorot pinlabel cmll graphicx-psmin ptmxcomp - countriesofeurope iodhbwm-templates fgruler combinedgraphics pax pdfpagediff - psfragx epsdice perfectcut upmethodology-fmt ftc-notebook tabvar vtable - teubner pas-cv gcard table-fct pdfpages keyfloat pdfscreen showexpl simplecd - ifmslide grffile reflectgraphics markdown bclogo tikz-page pst-uml realboxes - musikui csbulobalka lwarp mathtools sympytex mpgraphics miniplot.sty:77 - dottex pdftricks2 feupphdteses tex4ebook axodraw2 hagenberg-thesis dlfltxb - hu-berlin-bundle draftfigure quicktype endofproofwd euflag othelloboard - pdftricks unswcover breqn pdfswitch latex-make figlatex repltext etsvthor - cyber xcookybooky xfrac mercatormap chs-physics-report tikzscale ditaa - pst-poker gmp CJKvert asypictureb hletter tikz-network powerdot-fuberlin - skeyval gnuplottex plantslabels fancytooltips ieeepes pst-vectorian - phfnote overpic xtuformat stubs graphbox ucs pdfwin metalogo mwe - inline-images asymptote UNAMThesis authorarchive amscdx pst-pdf adjustbox - trimclip fixmetodonotes incgraph scanpages pst-layout alertmessage - svg quiz2socrative realhats autopdf egplot decorule figsize tikzexternal - pgfcore frontespizio textglos graphicx tikz tcolorbox pst-exa - ); - -my $pkgcandidates = join q{|}, map { quotemeta } sort { length $a <=> length $b } @pkgcandidates; -$pkgcandidates = qr/$pkgcandidates/x; -my @graphicxpkg; - -### \graphicspath -my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix; -my @graphicspath; - ### Replacing the extracted environments with \includegraphics Log("Convert pstricks extracted environments to \\includegraphics for $name-pdf$ext"); my $grap = "\\includegraphics[scale=1]{$name-fig-"; @@ -1900,49 +1858,84 @@ $preamble = "$atbegindoc$preamble"; ### Remove content in preamble my @tag_remove_preamble = $preamble =~ m/(?:^\%<\*remove$tmp>.+?\%<\/remove$tmp>)/gmsx; if (@tag_remove_preamble) { - Log("Removing the content between <*remove> ... tags in preamble for $name-pdf$ext"); + Log("Removing the content between %CleanPST ... %CleanPST in preamble for $name-pdf$ext"); $preamble =~ s/^\%<\*remove$tmp>\s*(.+?)\s*\%<\/remove$tmp>(?:[\t ]*(?:\r?\n|\r))?+//gmsx; } -### To be sure that the package is in the main document and not in a -### verbatim write environment we make the changes using the hash and -### range operator in a copy -my %tmpreplace = ( - 'graphicx' => 'TMPGRAPHICXTMP', - 'pst-exa' => 'TMPPSTEXATMP', - 'graphicspath' => 'TMPGRAPHICSPATHTMP', -); - -my $findtmp = join q{|}, map { quotemeta } sort { length $a <=> length $b } keys %tmpreplace; -my $preambletmp = $preamble; -my @lineas = split /\n/, $preambletmp; +### Suport for pst-exa package +my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x; +my @pst_exa; +my %pst_exa; -### We remove the commented lines -s/\%.*(?:[\t ]*(?:\r?\n|\r))?+//msg foreach @lineas; +### Search pst-exa package +@pst_exa = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$pstexa/gmsx; +%pst_exa = map { $_ => 1 } @pst_exa; -### We make the changes in the environments verbatim write -my $DEL; -for (@lineas) { - if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) { - s/($findtmp)/$tmpreplace{$1}/g; +### If found comment and adjust path for graphic files +if (@pst_exa) { + Log("Comment pst-exa package in preamble for $name-pdf$ext"); + $findgraphicx = 'false'; + $preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + (\\usepackage\[)\s*(swpl|tcb)\s*(\]\{pst-exa\})/\%$1$2,pdf$3/msxg; + # Change for [tcb] option (path for graphic files) + if (exists $pst_exa{tcb}) { + Log("Suport for \\usepackage[tcb,pdf]\{pst-exa\} for $name-pdf$ext"); + $bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imgdir\/$name-fig-exa-\d*)\}/$1$2\}\{$3\}/gsmx; } } -### Join lines in $preambletmp -$preambletmp = join "\n", @lineas; +### Regex for remove (pst-?) packages in preamble +$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add | -pdf )? | psfrag |psgo |vaucanson-g| auto-pst-pdf(?: -lua )? )/x; +$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x; + +Log("Remove pstricks packages in preamble for $name-pdf$ext [no pst-exa]"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg; +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + (?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx; + +### Uncomment pst-exa package +if (@pst_exa) { + Log("Uncomment pst-exa package in preamble for $name-pdf$ext"); + $preamble =~ s/(?:\%)(\\usepackage\[\s*)(swpl|tcb)(,pdf\s*\]\{pst-exa\})/$1$2$3/msxg; +} + +Log("Remove \\psset\{...\} in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx; + +Log("Remove \\SpecialCoor in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx; -### We removed the blank lines -$preambletmp =~ s/^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; +Log("Remove empty lines in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; -### Now we're trying to capture -@graphicxpkg = $preambletmp =~ m/($pkgcandidates)/gmsx; -if (@graphicxpkg) { - Log("Found graphicx package in preamble for $name-pdf$ext"); - $findgraphicx = 'false'; +### To be sure that the package graphicx and \graphicspath is in the main +### document and not in a verbatim write environment we make the changes +my %tmpreplace = ( + 'graphicx' => 'TMPGRAPHICXTMP', + 'graphicspath' => 'TMPGRAPHICSPATHTMP', +); +my $findtmp = join q{|}, map { quotemeta } sort { length $a <=> length $b } keys %tmpreplace; + +### We go line by line and make the changes [need /p for ${^MATCH}] +while ($preamble =~ /\%<\*$dtxverb>(.+?)\%<\/$dtxverb> | $tmpcomment /pgmsx) { + my ($pos_inicial, $pos_final) = ($-[0], $+[0]); + my $encontrado = ${^MATCH}; + $encontrado =~ s/($findtmp)/$tmpreplace{$1}/g; + substr $preamble, $pos_inicial, $pos_final-$pos_inicial, $encontrado; + pos ($preamble) = $pos_inicial + length $encontrado; } -### Search graphicspath -@graphicspath = $preambletmp =~ m/graphicspath/msx; +### Now we're trying to capture \graphicspath{...} +my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix; +my @graphicspath; +@graphicspath = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|($graphicspath)/gmsx; + if (@graphicspath) { Log("Found \\graphicspath in preamble for $name-pdf$ext"); $findgraphicx = 'false'; @@ -1961,19 +1954,53 @@ if (@graphicspath) { } } -### Search pst-exa -@pst_exa = $preambletmp =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$pstexa/xg; -%pst_exa = map { $_ => 1 } @pst_exa; -if (@pst_exa) { - Log("Comment pst-exa package in preamble for $name-pdf$ext"); +### Possible packages that load graphicx +my @pkgcandidates = qw ( + rotating epsfig lyluatex xunicode parsa xepersian-hm gregoriotex teixmlslides + teixml fotex hvfloat pgfplots grfpaste gmbase hep-paper postage schulealt + schule utfsym cachepic abc doclicense rotating epsfig semtrans mgltex + graphviz revquantum mpostinl cmpj cmpj2 cmpj3 chemschemex register papercdcase + flipbook wallpaper asyprocess draftwatermark rutitlepage dccpaper-base + nbwp-manual mandi fmp toptesi isorot pinlabel cmll graphicx-psmin ptmxcomp + countriesofeurope iodhbwm-templates fgruler combinedgraphics pax pdfpagediff + psfragx epsdice perfectcut upmethodology-fmt ftc-notebook tabvar vtable + teubner pas-cv gcard table-fct pdfpages keyfloat pdfscreen showexpl simplecd + ifmslide grffile reflectgraphics markdown bclogo tikz-page pst-uml realboxes + musikui csbulobalka lwarp mathtools sympytex mpgraphics miniplot.sty:77 + dottex pdftricks2 feupphdteses tex4ebook axodraw2 hagenberg-thesis dlfltxb + hu-berlin-bundle draftfigure quicktype endofproofwd euflag othelloboard + pdftricks unswcover breqn pdfswitch latex-make figlatex repltext etsvthor + cyber xcookybooky xfrac mercatormap chs-physics-report tikzscale ditaa + pst-poker gmp CJKvert asypictureb hletter tikz-network powerdot-fuberlin + skeyval gnuplottex plantslabels fancytooltips ieeepes pst-vectorian + phfnote overpic xtuformat stubs graphbox ucs pdfwin metalogo mwe + inline-images asymptote UNAMThesis authorarchive amscdx adjustbox + trimclip fixmetodonotes incgraph scanpages alertmessage + svg quiz2socrative realhats autopdf egplot decorule figsize tikzexternal + pgfcore frontespizio textglos graphicx tikz tcolorbox + ); + +my $pkgcandidates = join q{|}, map { quotemeta } sort { length $a <=> length $b } @pkgcandidates; +$pkgcandidates = qr/$pkgcandidates/x; +my @graphicxpkg; + +### Now we're trying to capture graphicx package +@graphicxpkg = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|($pkgcandidates)/gmsx; + +if (@graphicxpkg and $findgraphicx ne 'false') { + Log("Found graphicx package in preamble for $name-pdf$ext"); $findgraphicx = 'false'; - $preamble =~ s/(\\usepackage\[)\s*(swpl|tcb)\s*(\]\{pst-exa\})/\%$1$2,pdf$3/msxg; -} -if (exists $pst_exa{tcb}) { - Log("Suport for \\usepackage[tcb,pdf]\{pst-exa\} for $name-pdf$ext"); - $bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imgdir\/$name-fig-exa-\d*)\}/$1$2\}\{$3\}/gsmx; } +### Revert changes in preamble for temp +my %tmpoutreplace = ( + 'TMPGRAPHICXTMP' => 'graphicx', + 'TMPGRAPHICSPATHTMP' => 'graphicspath', +); + +%replace = (%changes_out,%tmpoutreplace); +$find = join q{|}, map {quotemeta} sort { length $a <=> length $b } keys %replace; + ### Try to capture arara:compiler in preamble of my @arara_engines = qw (latex pdflatex lualatex xelatex luahbtex); my $arara_engines = join q{|}, map { quotemeta} sort { length $a <=> length $b } @arara_engines; @@ -1981,28 +2008,36 @@ $arara_engines = qr/\b(?:$arara_engines)/x; my $arara_rule = qr /^(?:\%\s{1}arara[:]\s{1}) ($arara_engines) /msx; ### Capture graphicx.sty in .log of LaTeX file -if ($findgraphicx eq 'true') { +if ($findgraphicx ne 'false') { Log("Couldn't capture the graphicx package for $name-pdf$ext in preamble"); my $ltxlog; my @graphicx; my $null = devnull(); + # Copy preamble and revert changes + my $preambletmp = $preamble; + $preambletmp =~ s/($find)/$replace{$1}/g; + $preambletmp =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; Log("Creating $name-fig-$tmp$ext [only preamble]"); if ($verbose) { say "Creating [$name-fig-$tmp$ext] with only preamble"; } open my $OUTfile, '>', "$name-fig-$tmp$ext"; - print {$OUTfile} "$preamble\n\\stop"; + print {$OUTfile} "$preambletmp\n\\stop"; close $OUTfile; - # Set compiler + # Set compiler for arara if ($opts_cmd{compiler}{arara}) { - my @engine = $preamble =~ m/$arara_rule/msx; + my @engine = $atbegindoc =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$arara_rule/msx; my %engine = map { $_ => 1 } @engine; if (%engine) { for my $var (@arara_engines) { if (defined $engine{$var}) { + Log("Found engine [$var] for arara"); $compiler = $var; } } } - else { $compiler = 'pdflatex'; } + else { + Log("Not detected engine for arara, use default [pdflatex]"); + $compiler = 'pdflatex'; + } } if ($compiler eq 'latex') { $compiler = 'pdflatex'; } if ($compiler eq 'dvilualatex') { $compiler = 'lualatex'; } @@ -2025,48 +2060,28 @@ if ($findgraphicx eq 'true') { else { Log("Not found graphicx package in $name-fig-$tmp.log"); Log("Add \\usepackage\{graphicx\} to preamble of $name-pdf$ext"); - $preamble= "$preamble\n\\usepackage\{graphicx\}"; + $preamble= "$preamble\\usepackage\{graphicx\}\n"; } } -### Regex for clean (pst-?) in preamble -$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add | -pdf )? | psfrag |psgo |vaucanson-g| auto-pst-pdf(?: -lua )? )/x; -$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x; - -Log("Remove pstricks packages in preamble for $name-pdf$ext"); -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - (?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx; -$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; - -if (@pst_exa) { - Log("Uncomment pst-exa package in preamble for $name-pdf$ext"); - $preamble =~ s/(?:\%)(\\usepackage\[\s*)(swpl|tcb)(,pdf\s*\]\{pst-exa\})/$1$2$3/msxg; -} - ### Add last lines if (!@graphicspath) { Log("Not found \\graphicspath in preamble for $name-pdf$ext"); Log("Add \\graphicspath\{\{$imgdir/\}\} to preamble for $name-pdf$ext"); - $preamble= "$preamble\n\\graphicspath\{\{$imgdir/\}\}"; + $preamble= "$preamble\\graphicspath\{\{$imgdir/\}\}\n"; } + Log("Add \\usepackage\{grfext\} to preamble for $name-pdf$ext"); -$preamble = "$preamble\n\\usepackage\{grfext\}"; +$preamble = "$preamble\\usepackage\{grfext\}\n"; Log("Add \\PrependGraphicsExtensions\*\{\.pdf\} to preamble for $name-pdf$ext"); -$preamble = "$preamble\n\\PrependGraphicsExtensions\*\{\.pdf\}"; +$preamble = "$preamble\\PrependGraphicsExtensions\*\{\.pdf\}"; $preamble =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; -$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; -$preamble =~ s/^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; ### Create a my $out_file = "$preamble\n$bodydoc\n$enddoc"; -### Clean \psset content in output file +### Clean \psset{...} content in +Log("Remove \\psset\{...\} in body for $name-pdf$ext"); $out_file =~ s/\\begin\{nopreview\}\%$tmp.+?\\end\{nopreview\}\%$tmp(*SKIP)(*F)| \%<\*$dtxverb> .+? \%<\/$dtxverb>(*SKIP)(*F)| \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx; @@ -2087,7 +2102,7 @@ $out_file =~ s/\\begin\{nopreview\}%$tmp ### Remove internal mark for verbatim and verbatim write environments $out_file =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; -%replace = (%changes_out); +%replace = (%changes_out,%tmpoutreplace); $find = join q{|}, map {quotemeta} sort { length $a <=> length $b } keys %replace; $out_file =~ s/($find)/$replace{$1}/g; @@ -2115,13 +2130,20 @@ my $ltxmkopt = $xetex ? "-pdfxe -silent -xelatex=\"xelatex $write18 -recorder % : $luatex ? "-pdflua -silent -lualatex=\"lualatex $write18 -recorder %O %S\"" : "-pdf -silent -pdflatex=\"pdflatex $write18 -recorder %O %S\"" ; + ### Set options for compiler $opt_compiler = $arara ? '--log' : $latexmk ? "$ltxmkopt" : "$write18 -interaction=nonstopmode -recorder" ; -### Set compiler name for arara and latexmk +### Set message in terminal +$msg_compiler = $xetex ? 'xelatex' + : $luatex ? 'lualatex' + : 'pdflatex' + ; + +### Set compiler message and compiler for arara and latexmk if ($arara) { $compiler = $msg_compiler = 'arara'; } if ($latexmk) { $compiler = $msg_compiler = 'latexmk'; } diff --git a/Master/texmf-dist/doc/latex/pst2pdf/Changes b/Master/texmf-dist/doc/latex/pst2pdf/Changes deleted file mode 100644 index ad609922784..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/Changes +++ /dev/null @@ -1,37 +0,0 @@ -pst2pdf.pl -------- -0.19 2020-08-08 - Add new options to CLI - - Remove deprecate code - - Rewrite documentation - - Remove unused options -0.18 2017-10-04 - Fix typos in the code comments -0.17 2017-09-11 - Fix escape character in regex -0.16 2014-09-14 - Using gs for split pdf (no more pdftk) - - Support package pst-exa for examples - - Adding svg image support - - Ignore inline verbatim -0.15 2013-06-16 - Adding short options for command line - - Create png and jpg files in Linux and Windows - - Pass options to ps2pdf -0.14 2013-02-27 - Suport xelatex and -help from command line -0.13 2011-12-12 - Some more improvements to the code -0.12 2011-01-19 - New optional arguments for running - bibtex or biber -0.11 2010-10-03 - Use graphicspath instead of $imageDir to - allow working with Windows - - Test for pst-exa to write \psset in the - pdf file -0.10 2010-01-04 - Allow using the package pst-exa -0.09 2009-10-01 - Allow pspicture* -0.08 2009-08-28 - Test for png files (only for Linux) -0.07 2009-07-24 - Fix bug with \begin{postscript} and following - pspicture environment - - Add some more documentation -0.06 2007-08-28 - Fix bug with \begin{pspicture} and \pspicture -0.05 2007-07-05 - Allow different extensions for the source file - e.g. tex, ltx - - Ignore verbatim environment - - Better log file support -0.04 2007-07-04 - Allow all \begin ..\end sequences anywhere - in a line, see testcase -0.03 2007-06-21 - Fix nested environments -0.02 2007-06-20 - First (public) version diff --git a/Master/texmf-dist/doc/latex/pst2pdf/README.md b/Master/texmf-dist/doc/latex/pst2pdf/README.md deleted file mode 100644 index 3ef4a697f47..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# pst2pdf – Running a PSTricks document with pdflatex - -Release v0.19 \[2020-08-17\] - -## Description - -`pst2pdf` is a Perl _script_ which isolates all `PostScript` or `PSTricks` related -parts of the TeX document, read all `postscript`, `pspicture`, `psgraph` and `PSTexample` -environments, extract source code in standalone files and converting them into image -format \(default `pdf`\). Create new file with all extracted environments converted to `\includegraphics` -and runs \(pdf/xe/lua\)latex. - -## Usage - -``` -pst2pdf.pl [] [.tex|.ltx] -``` - -or - -``` -pst2pdf.pl [.tex|.ltx] [] -``` - -Relative or absolute `paths` for directories and files is not supported. Options that accept -a _value_ require either a blank space or `=` between the option and the _value_. Some short -options can be bundling. - -If used without `[]` the extracted environments are converted to `pdf` image format -and saved in the `./images` directory using `latex>dvips>ps2pdf` and `preview` package to -process `` and `pdflatex` to process the output file ``. - -## Restrictions - -The `pspicture` environment can be nested, the `postscript` one **NOT!** `pspicture` can be -inside of a `postscript` environment, but not vice versa. - -```latex -\begin{postscript} - ... - \begin{pspicture} - .... - \end{pspicture} - ... -\end{postscript} -``` - -The `postscript` environment should be used for all other PostScript related commands, which -are not part of a `pspicture` environment, e.g. nodes inside normal text or `\psset{...}` -outside of environment. - -## Installation - -The script `pst2pdf` is present in `TeXLive` and `MiKTeX`, use the package manager to install. - -For manual installation, download [pst2pdf.zip](http://mirrors.ctan.org/graphics/pstricks/scripts/pst2pdf.zip) and unzip it -and move all files to appropriate locations: - -``` - pst2pdf-doc.pdf -> TDS:doc/support/pst2pdf/pst2pdf-doc.pdf - pst2pdf-doc.tex -> TDS:doc/support/pst2pdf/pst2pdf-doc.tex - pst2pdf-doc.bib -> TDS:doc/support/pst2pdf/pst2pdf-doc.bib - test1.tex -> TDS:doc/support/pst2pdf/test1.tex - test2.tex -> TDS:doc/support/pst2pdf/test2.tex - test3.tex -> TDS:doc/support/pst2pdf/test3.tex - test1-pdf.tex -> TDS:doc/support/pst2pdf/test1-pdf.pdf - test2-pdf.tex -> TDS:doc/support/pst2pdf/test2-pdf.pdf - test3-pdf.tex -> TDS:doc/support/pst2pdf/test3-pdf.pdf - tux.jpg -> TDS:doc/support/pst2pdf/tux.jpg - README.md -> TDS:doc/support/pst2pdf/README.md - Changes -> TDS:doc/support/pst2pdf/Changes - pst2pdf.pl -> TDS:scripts/pst2pdf/pst2pdf.pl -``` - -## Documentation - -For more documentation use: - -``` -$ pst2pdf --help -``` - -or - -``` -$ texdoc pst2pdf -``` - -To reproduce the documentation run `xelatex pst2pdf-doc.tex`. - -## Copyright - -Copyright 2013 - 2020 by Herbert Voss `` and Pablo González L ``. diff --git a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib deleted file mode 100644 index 49d7274d357..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib +++ /dev/null @@ -1,149 +0,0 @@ -@STRING{tugboat = {TUGboat} } -@STRING{beiprogramm = {{\TeX}-Beiprogramm} } -@STRING{bretter = {Bretter, die die Welt bedeuten} } -@STRING{dtk = {{D}ie {\TeX}nische {K}om{\"o}die} } -@STRING{editorial = {Editorial} } -@STRING{fremdebuehne = {Von fremden B{\"u}hnen} } -@STRING{fundus = {Aus dem Fundus} } -@STRING{hinterbuehne = {Hinter der B{\"u}hne} } -@STRING{leserbrief = {Leserbrief(e)} } -@STRING{magazin = {Magazin} } -@STRING{rezension = {Rezensionen} } -@STRING{schonimmer = {Was Sie schon immer {\"u}ber {\TeX} wissen wollten \dots} } -@STRING{theaterkasse = {Von der Theaterkasse} } -@STRING{theatertage = {{\TeX}-Theatertage} } - -@Book{tlgc2, - author = {Michel Goosens and Frank Mittelbach and Sebastian Rahtz and Denis Roegel and Herbert Vo{\ss}}, - title = {The {\LaTeX} {G}raphics {C}ompanion}, - publisher = {{Addison-Wesley Publishing Company}}, - edition = 2, - year = {2007}, - address = {Reading, Mass.} -} - - -@Article{girou:01:, - author = {Denis Girou}, - title = {Pr\'esentation de {PST}ricks}, - journal = {Cahier {GUT}enberg}, - year = 1994, - volume = {16}, - month = apr, - pages = {21-70} -} - -@Article{girou:02:, - author = {{Timothy van} Zandt and Denis Girou}, - title = {Inside {PST}ricks}, - journal = TUGboat, - year = 1994, - volume = {15}, - month = sep, - pages = {239-246} -} - -@Manual{pstricks, - Title = {PSTricks - {\PS} macros for generic {\TeX}}, - Author = {{Timothy van} Zandt}, - Address = {\url{http://www.tug.org/application/PSTricks}}, - year = 1993 -} - -@Book{PSTricks2, - author = {Herbert Vo\ss}, - title = {\texttt{PSTricks} -- {G}rafik f\"ur \TeX{} und \LaTeX}, - edition = {7}, - publisher = {DANTE -- Lehmanns}, - year = {2010}, - address = {Heidelberg/Berlin} -} - -@Book{PSTricks2-UIT, - author = {Herbert Vo\ss}, - title = {PSTricks -- Graphics for \TeX\ and \LaTeX}, - publisher = {UIT}, - year = {2011}, - address = {Cambridge} -} - -@Book{LaTeXRef-UIT, - author = {Herbert Vo\ss}, - title = {{\LaTeX} quick reference}, - publisher = {UIT}, - year = {2012}, - address = {Cambridge} -} - -@Manual{pst-tools, - author = {Herbert Voß}, - title = {\texttt{pst-tools} -- Helper functions}, - publisher = {CTAN}, - year = {2012}, - address = {\url{CTAN:/graphics/pstricks/contrib/pst-tools}} -} - -@Manual{preview, - author = {David Kastrup}, - title = {The \texttt{preview} package for \hologo{LaTeX}}, - publisher = {CTAN}, - year = {2017}, - address = {\url{https://www.ctan.org/pkg/preview}} -} - -@Manual{pst-pdf, - author = {Rolf Niepraschk}, - title = {The \texttt{pst-pdf} package}, - publisher = {CTAN}, - year = {2019}, - address = {\url{https://www.ctan.org/pkg/pst-pdf}} -} - -@Manual{auto-pst-pdf, - author = {Will Robertson}, - title = {The \texttt{auto-pst-pdf} package}, - publisher = {CTAN}, - year = {2009}, - address = {\url{https://www.ctan.org/pkg/auto-pst-pdf}} -} - -@Manual{auto-pst-pdf-lua, - author = {Herbert Voß}, - title = {The \texttt{auto-pst-pdf-lua} package - Using \hologo{LuaLaTeX} with \texttt{PSTricks}}, - publisher = {CTAN}, - year = {2018}, - address = {\url{https://www.ctan.org/pkg/auto-pst-pdf-lua}} -} - -@Manual{pst-exa, - author = {Herbert Voß}, - title = {\texttt{pst-exa} - Typeset \texttt{PSTricks} examples, with \hologo{pdfTeX}}, - publisher = {CTAN}, - year = {2017}, - address = {\url{https://www.ctan.org/pkg/pst-exa}} -} - -@Manual{graphicx, - author = {The \hologo{LaTeX3} Project}, - title = {\texttt{graphics} - Enhanced support for graphics}, - publisher = {CTAN}, - year = {2017}, - address = {\url{https://www.ctan.org/pkg/graphicx}} -} - -@Manual{grfext, - author = {Heiko Oberdiek}, - title = {The \texttt{grfext} package}, - publisher = {CTAN}, - year = {2017}, - address = {\url{https://www.ctan.org/pkg/grfext}} -} - -@Manual{pst-plot, - author = {{Timothy van} Zandt and Herbert Voß}, - title = {\texttt{pst-plot} - Plot data using \texttt{PSTricks}}, - publisher = {CTAN}, - year = {2019}, - address = {\url{https://www.ctan.org/pkg/pst-plot}} -} - diff --git a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf deleted file mode 100644 index ea2ceb21c42..00000000000 Binary files a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex deleted file mode 100644 index ab85cde8963..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex +++ /dev/null @@ -1,1244 +0,0 @@ -\documentclass[11pt,english, - BCOR=10mm,DIV=10,% <- changed - bibliography=totoc,parskip=half*,<- changed - headings=small,% <- changed - headinclude=false,% <- changed - footinclude=false,oneside,mpinclude=false]{pst-doc} -\AfterCalculatingTypearea{% - \newgeometry{top=0.5in, bottom=0.3in,left=1.4in,right=0.7in,% - marginparwidth=1.3in,marginparsep=0.1in,footskip=0.2in,% - headheight=1cm,headsep=0.27cm,reversemarginpar}% - \KOMAoptions{headwidth=text,headsepline=:text,footwidth=text}% <- added -} -\recalctypearea -\RedeclareSectionCommand[ - %runin=false, - afterindent=false, - beforeskip=\baselineskip, - afterskip=.5\baselineskip]{section} -\RedeclareSectionCommand[ - %runin=false, - afterindent=false, - beforeskip=.75\baselineskip, - afterskip=.5\baselineskip]{subsection} -\RedeclareSectionCommand[ - %runin=false, - afterindent=false, - beforeskip=.5\baselineskip, - afterskip=.25\baselineskip]{subsubsection} -\listfiles -\let\Lfile\LFile -\usepackage{biblatex} -\addbibresource{\jobname.bib} -%\lstset{language=PSTricks,basicstyle=\footnotesize\ttfamily} -\def\DVI{\textsc{DVI}} -\def\PDF{\textsc{PDF}} -\def\gs{\textsc{Ghostscript}} -\usepackage{multicol,enumitem,hologo,accsupp,csquotes} - -% Identification -\def\myscript{pst2pdf} -\def\fileversion{0.19} -\def\filedate{2020-08-17} - -% Config hyperref -\hypersetup{ - linktoc = all, - pdftitle = {.:: pst2pdf v\fileversion{} [\filedate] --- Running a PSTricks document with (pdf/xe/lua)latex ::.},% - pdfauthor = {Herbert Vo\ss, Pablo Gonz\'{a}lez Luengo},% - pdfsubject = {Documentation for version \fileversion},% - pdfkeywords = {extract, conversion, images, pstricks, standalone files}, - pdfstartview = {FitH},% - bookmarksopenlevel = 2,% -} - -% Some font for verbatim examples -\newfontfamily\lmmitalic{lmmono10-italic.otf}[ - Scale = 0.95,% - Extension = .otf,% - ItalicFont = lmmono10-italic,% - SmallCapsFont = lmmonocaps10-oblique,% - SlantedFont = lmmonoslant10-regular, - ] -% The character of visible space is now taken from Latin Modern Mono -% to prevent fonts in T1. The original definition for xetex/luatex is -% \def\verbvisiblespace{\usefont{OT1}{cmtt}{m}{n}\asciispace} -\def\verbvisiblespace{{\fontfamily{lmtt}\selectfont\char"2423}} -% Add some colors -\definecolor{optcolor}{rgb}{0.281,0.275,0.485} -\definecolor{pkgcolor}{rgb}{0,0.5,0.5} -\definecolor{araracolor}{rgb}{0, 0.72, 0.28} -\definecolor{linkcolor}{rgb}{0.04,0.38,0.04} -\definecolor{rulecolor}{rgb}{0.96,0.96,0.96} - -% new macros -\makeatletter -\def\Lscript#1{\texttt{#1}\index{#1@\texttt{#1}}\index{Script!#1@\texttt{#1}}} -\def\Losystem#1{\texttt{#1}\index{#1@\texttt{#1}}\index{Operating system!#1@\texttt{#1}}} -\def\Loptcmd#1{\index{Options in command line!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} -\def\Limgform#1{\texttt{#1}\index{Image format!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} -\def\Loptprg#1{\index{Compiler options!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} -\def\Venv#1{\texttt{#1}\index{Environment Verbatim!#1@\texttt{#1}}} -\def\Wenv#1{\texttt{#1}\index{Environment Verbatim Write!#1@\texttt{#1}}} - -% Only index a starred version -\RenewDocumentCommand{\LFile}{sm} - { - \IfBooleanTF{#1}% - {% - \LFile{#2} - - }% - {% - \texttt{#2}% - }% - }% - -% \prgopt{sm} : #1 compiler opt, #2 program opt: -\NewDocumentCommand{\prgopt}{sm} - { - \IfBooleanTF{#1}% - {% - \mbox{\textcolor{gray}{\texttt{-{}#2}}}% - \Loptprg{-{}#2}% - }% - {% - \mbox{\textcolor{gray}{\texttt{-{}#2}}}% - \index{#2@\texttt{-{}#2}}\index{Program options!#1@\texttt{-{}#2}}% - }% - }% - -% \DescribeIF{m}, #1 image format -\newsavebox{\marginIF} -\NewDocumentCommand{\DescribeIF}{ m } - {% - \begin{lrbox}{\marginIF}% - \begin{minipage}[t]{\marginparwidth}% - \raggedleft\ttfamily\bfseries% - \textcolor{optcolor}{#1}\hfill - \end{minipage}% - \end{lrbox}% - \index{Image format!#1@\texttt{#1}}% - \leavevmode% - \marginpar{\usebox{\marginIF}}% - \ignorespaces% - }% - -% \myenv{environ} for margin -\NewDocumentCommand{\myenv}{m} - { - \begin{minipage}[t]{\marginparwidth}% - \raggedleft\ttfamily\small% - {\textcolor{gray}{\textbackslash begin\{}}{\bfseries\textcolor{pkgcolor}{#1}}\textcolor{gray}{\}}\par% - \meta[ac=lightgray,cf=gray]{env content}\par% - {\textcolor{gray}{\textbackslash end\{}}{\bfseries\textcolor{pkgcolor}{#1}}\textcolor{gray}{\}}% - \end{minipage}% - \index{Environment suport by default!#1@\texttt{#1}} - } -% CleanPST for margin -\NewDocumentCommand{\mytag}{m} - {% - \begin{minipage}[t]{\marginparwidth}% - \raggedleft\ttfamily\small% - \textcolor{gray}{\%}{\bfseries\textcolor{pkgcolor}{#1}}\par% - \meta[ac=lightgray,cf=gray]{code}\par% - \textcolor{gray}{\%}{\bfseries\textcolor{pkgcolor}{#1}}% - \end{minipage}% - \index{Remove PST code!#1@\texttt{#1}} - }% - -% \DescribeTE{sm}, #1 tag, #2 env -\newsavebox{\marginenvtag} -\NewDocumentCommand{\DescribeTE}{sm}{% -\begin{lrbox}{\marginenvtag}% - \begin{minipage}[t]{\marginparwidth}% - \raggedleft - \IfBooleanTF{#1}{\mytag{#2}}{\myenv{#2}} - \end{minipage}% -\end{lrbox}% - \leavevmode% - \marginpar{\usebox{\marginenvtag}}% - \ignorespaces% -}% -\makeatother - -\ExplSyntaxOn -% \cmdopt[short]{long} -\NewDocumentCommand{\cmdopt}{om} - { - \IfNoValueTF{#1} - { - \textcolor{optcolor}{\texttt{-\/-#2}} - } - { - \textcolor{optcolor}{\texttt{-{}#1}}, - \textcolor{optcolor}{\texttt{-\/-#2}} - } - \Loptcmd{-\/-#2} - } - -% Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} for color -\NewDocumentCommand{\meta}{O{}m} - { - \myscript_meta_generic:Nnn \myscript_meta:n { #1 } { #2 } - } -\NewDocumentCommand{\marg}{O{}m} - { - \myscript_meta_generic:Nnn \myscript_marg:n { #1 } { #2 } - } -\NewDocumentCommand{\oarg}{O{}m} - { - \myscript_meta_generic:Nnn \myscript_oarg:n { #1 } { #2 } - } -% Variables and keys -\tl_new:N \l_myscript_meta_font_tl - -\keys_define:nn { myscript/meta } - { - type .choice:, - type / tt .code:n = \tl_set:Nn \l_myscript_meta_font_tl { \ttfamily }, - type / rm .code:n = \tl_set:Nn \l_myscript_meta_font_tl { \rmfamily }, - type .initial:n = rm, - cf .tl_set:N = \l_myscript_meta_color_tl, - cf .initial:n = black,% - ac .tl_set:N = \l_myscript_meta_anglecolor_tl, - ac .initial:n = lightgray, - sbc .tl_set:N = \l_myscript_meta_brackcolor_tl, - sbc .initial:n = gray, - cbc .tl_set:N = \l_myscript_meta_bracecolor_tl, - cbc .initial:n = gray, - } -% Internal commands -\cs_new_protected:Npn \myscript_meta_generic:Nnn #1 #2 #3 - { - \group_begin: - \keys_set:nn { myscript/meta } { #2 } - \color{ \l_myscript_meta_color_tl } - \l_myscript_meta_font_tl - #1 { #3 } % #1 is \myscript_meta:n, \myscript_marg:n or \myscript_oarg:n - \group_end: - } -\cs_new_protected:Npn \myscript_meta:n #1 - { - \myscript_meta_angle:n { \textlangle } - \myscript_meta_meta:n { #1 } - \myscript_meta_angle:n { \textrangle } - } -\cs_new_protected:Npn \myscript_marg:n #1 - { - \myscript_meta_brace:n { \textbraceleft } - \myscript_meta:n { #1 } - \myscript_meta_brace:n { \textbraceright } - } -\cs_new_protected:Npn \myscript_oarg:n #1 - { - \myscript_meta_brack:n { [ } - \myscript_meta:n { #1 } - \myscript_meta_brack:n { ] } - } -\cs_new_protected:Npn \myscript_meta_meta:n #1 - { - \textnormal{\textit{#1}} - } -\cs_new_protected:Npn \myscript_meta_angle:n #1 - { - \group_begin: - \fontfamily{lmr}\selectfont - \textcolor{\l_myscript_meta_anglecolor_tl}{#1} - \group_end: - } -\cs_new_protected:Npn \myscript_meta_brace:n #1 - { - \group_begin: - \color{\l_myscript_meta_bracecolor_tl} - #1 - \group_end: - } -\cs_new_protected:Npn \myscript_meta_brack:n #1 - { - \textcolor{\l_myscript_meta_brackcolor_tl}{#1} - } - -% \DescribeCmd[...]{...}{...}{...} -\newsavebox{\optcmdline} -\NewDocumentCommand{\DescribeCmd}{ o m m m } - { - \group_begin: - \begin{lrbox}{\optcmdline}% - \begin{minipage}[t]{\marginparwidth}% - \ttfamily\raggedleft% - \IfNoValueTF{#1} - {\textcolor{optcolor}{-\/-#2}} - {\textcolor{optcolor}{-{#1}}\textcolor{gray}{,} \textcolor{optcolor}{-\/-#2}}% - \end{minipage}% - \Loptcmd{-\/-#2} - \end{lrbox}% - \leavevmode% - \marginpar{\usebox{\optcmdline}}% - \meta[ac=lightgray,cf=gray]{#3} - \raggedleft\hfill\textcolor{gray}{\textsf{(default: ~ {#4})}}\ignorespaces\par% - %\vspace*{2pt}\par% - \group_end: -} - -\ExplSyntaxOff -% Don't copy numbers in code example for listings -\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}} - -% Create a language for documentation -\lstdefinelanguage{myscript-doc}{ - texcsstyle=*,% - escapechar=`,% - showstringspaces=false,% - extendedchars=true, % - stringstyle = {\color{red}},% - alsoletter={\-,.},% -% comments - morecomment=[l]{\%},% - commentstyle=\lmmitalic\color{lightgray},% -% Important words 1 - keywordstyle=[1]{\color{NavyBlue}},% - keywords=[1]{PassOptionsToPackage,AtBeginDocument,documentclass,usepackage,section},% -% Important words 2 (macros) - keywordstyle=[2]{\color{blue!75}},% - keywords=[2]{graphicspath,RequirePackage,renewcommand,includegraphics,coordinate,draw,approx,% - PreviewBbAdjust,setlength,parindent,usetikzlibrary,tikzexternalize,psset,tikzset,PrependGraphicsExtensions,% - DefineShortVerb,lstMakeShortInline,MakeSpecialShortVerb,UndefineShortVerb,verb,myverb,macro,put,line},% -% Important words 3, options in input file - keywordstyle=[3]{\color{optcolor!85}},% - keywords=[3]{arara,extensions,luatex,env,norun,% - clean,pst,tkz,eps,pdf,xetex,latex,luatex,dvips,png,latexmk,svg,srcenv,noprew,imgdir},% -% Important words 4, environments and tags - keywordstyle=[4]{\color{pkgcolor}},% - keywords=[4]{pspicture,endpspicture,description,filecontents,PSTexample,% - psgraph, endpsgraph,CleanPST,postscript},% -% Important words 5, directory - keywordstyle=[5]{\color{OrangeRed}},% - keywords=[5]{images},% ,pics -% Important words 6, begin, end and other - keywordstyle=[6]{\color{gray}},% replace this color - keywords=[6]{begin,end,-recorder,doc,active,inactive,tightpage,BEGIN,END,% - -shell-escape,osf,--output-format,dvi},% -% Important words 7, reserved for arara - keywordstyle=[7]{\color{araracolor}},% - keywords=[7]{lualatex,halt,xelatex},% -% Important words 8, pkg and others load in examples - keywordstyle=[8]{\color{SlateBlue}},% - keywords=[8]{graphicx,grfext,article,document,preview,libertinus,pst-pdf},% -% Important words 9, files used in examples - keywordstyle=[10]{\color{OrangeRed}},% - keywords=[10]{test-fig-all.pdf,test-fig-1981.tex,test-fig-1981.pdf, test-fig-1,test-fig-2,test-out,test-in.ltx,% - test-fig-1981.tex,test-out.tex,file-in.tex,file-out,test.tex,test-fig-all.dvi,test-fig-1.svg,test-fig-all.tex},% -}[keywords,tex,comments,strings]% end languaje - -% \begin{examplecode}[opts]...\end{examplecode} -\lstnewenvironment{examplecode}[1][]{% -\lstset{ - language=myscript-doc,% - stringstyle = {\color{red}},% - basicstyle=\ttfamily\small,% - numbersep=1em,% - 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} - {[}{{\textcolor{gray}{[}}}{1} - {]}{{\textcolor{gray}{]}}}{1} - {\*}{{\bfseries\textcolor{MediumOrchid}{*}}}{1} - {:}{{\textcolor{gray}{:}}}{1} - {,}{{\textcolor{gray}{,}}}{1} - {=}{{\textcolor{gray}{=}}}{1} - {/}{{\textcolor{OrangeRed}{/}}}{1} - {scale=1}{{\textcolor{gray}{scale=1}}}{7} - {\%CleanPST}{{\textcolor{gray}{\%}\textcolor{pkgcolor}{CleanPST}}}{9},% - #1,% - }% close lstset -}% -{}% close examplecode - -% \begin{examplecmd}...\end{examplecmd} -\lstnewenvironment{examplecmd}{% -\lstset{ - language=myscript-doc,% - basicstyle=\ttfamily\small,% - frame=single,% - alsoletter={\-,.,\-\-},% - rulecolor=\color{gray!50},% - framesep=\fboxsep,% - framerule=\fboxrule,% - xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,% - xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,% - keywordstyle=[20]{\color{gray}},% replace this color - keywords=[20]{--margins, -recorder,-shell-escape,-s,-o,-e,-p,-j,--imgdir,% - --luatex,--latexmk,--svg,--png,--nopdf,pics,-no-shell-escape,-interaction,nonstopmode},% -% Reserved words (cmd line options) - deletekeywords=[4]{pst2pdf},% - classoffset=7,% - keywordstyle=\bfseries\color{ForestGreen},% - morekeywords={pst2pdf},% -% % Reserved words (cmd line options) - classoffset=8,% - keywordstyle={\color{ForestGreen}},% - morekeywords={gs,pdftoppm,pdftocairo,pdftops,cd,perl,pdfcrop},% -% Only for command line options - classoffset=5,% - keywordstyle=\color{blue},% - keywords={user,machine},% - literate=*{[}{{\textcolor{darkgray}{[}}}{1} - {]}{{\textcolor{darkgray}{]}}}{1} - {=}{{\textcolor{gray}{=}}}{1} - {@}{{\textcolor{blue}{@}}}{1} - {\$}{{\textcolor{blue}{\$}}}{1} - {:}{{\textcolor{blue}{:}}}{1} - {§}{{\textcolor{red}{\$\space}}}{2} - {~}{{\textcolor{blue}{\bfseries\textasciitilde}}}{1}% - }% close lstset -}% -{}% close examplecmd - -% \lstinline[style=inline]|...| -\lstdefinestyle{inline} - { - language=myscript-doc,% - basicstyle=\ttfamily\color{gray},% - escapechar=`,% - upquote=true,% - deletekeywords=[8]{preview},% - morekeywords =[4]{preview},% - literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1} - {\*}{{\bfseries\textcolor{MediumOrchid}{*}}}{1} - } - -% set default style -\lstset{style=inline} - -\begin{document} - -\title{\texttt{pst2pdf}} -\subtitle{Running a PSTricks document with (pdf/xe/lua)latex;\\ v\fileversion{} --- \filedate\thanks{% - This file describes a documentation for version \fileversion, last revised \filedate.}} -\author{Herbert Voß \\ Pablo Gonz\'{a}lez L} -\date{} - -\maketitle - -\begin{abstract} - -\texttt{pst2pdf} is a \texttt{Perl} \emph{script} which isolates all \texttt{PostScript} or \texttt{PSTricks} related -parts of the \TeX{} document, read all \texttt{postscript}, \texttt{pspicture}, \texttt{psgraph} -and \texttt{PSTexample} environments and, extract source code in \emph{standalone} files and -converting them into image format \texttt{pdf, eps, jpg, svg} or \texttt{png} (default \texttt{pdf}). -Create new file with all extracted environments converted to \Lcs{includegraphics} and runs \texttt{(pdf/Xe/lua)latex}. -\end{abstract} - -\tableofcontents - -\clearpage -\newpage - -\section{Introduction} - -\PST\ as \PS\ related package uses the programming language \PS\ for internal -calculations. This is an important advantage, because floating point arithmetic is no -problem. Nearly all mathematical calculation can be done when running the \DVI-file -with \gs. However, creating a \PDF\ file in a direct way with \Lprog{pdflatex} is -not possible. \Lprog{pdflatex} cannot understand the \PS\ related stuff. - -Instead of running \Lprog{pdflatex} one can use the \emph{script} \Lscript{pst2pdf}, it extracts -all \PST\ related code into single documents with the same preamble as the original -main document. - -The \Lscript{pst2pdf} \emph{script} runs document, extract source code for all \PST\ as \PS\ related parts, clips all whitespace around the -image and creates a \Lext{pdf} images of the \PST\ related code. - -In a last run which is the \Lprog{pdflatex} the \PST\ code in the -main document is replaced by the created images. - -\section{License} - -This program is free software; you can redistribute it and/or modify -it under the terms of the \href{https://www.gnu.org/licenses/gpl-3.0.html}{GNU General Public License} as published by -the \href{https://www.fsf.org/}{Free Software Foundation}; either version 3 of the License, or -(at your option) any later version. - - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \href{https://www.gnu.org/licenses/gpl-3.0.html}{GNU General Public License} -for more details. - -\section{Requirements for operation} - -For the complete operation of \Lscript{pst2pdf}{} you need to have a modern % -\hologo{TeX} distribution such as \hologo{TeX} Live or \hologo{MiKTeX}, the packages \LPack{preview}\cite{preview}, -\LPack{pst-pdf}\cite{pst-pdf}, \LPack{graphicx}\cite{graphicx} and \LPack{grfext}\cite{grfext}, have -a version equal to or greater than \liningnums{5.28} of \Lprog{perl}, a -version equal to or greater than \liningnums{9.24} of \Lprog{Ghostscript}, a -version equal to or greater than \liningnums{1.40} of \Lscript{pdfcrop} -and have a version equal to or greater than \liningnums{0.52} of % -\Lprog{poppler-utils}. - -The distribution of \hologo{TeX} Live 2020 for \Losystem{Windows} includes % -\Lscript{pst2pdf} and all requirements, \hologo{MiKTeX} users must install the -appropriate software for full operation. - -The script auto detects the \Lprog{Ghostscript}, but not \Lprog{poppler-utils}. -You should keep this in mind if you are using the script directly and not -the version provided in your \hologo{TeX} distribution. - -The script has been tested on \Losystem{Windows} (v10) and % -\Losystem{Linux} (fedora 32) using \Lprog{Ghostscript} % -\liningnums{v9.52}, \Lprog{poppler-utils} \liningnums{v0.84}, \Lprog{perl} \liningnums{v5.30} -and the standard classes offers by \hologo{LaTeX}: \LClass{book}, -\LClass{report}, \LClass{article} and \LClass{letter}. - -\section{How it works} -\label{sec:howtowork} - -It is important to have a general idea of how the \emph{\enquote{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{input file}, the \meta{verbatim content} -and the \meta{steps process}. - -\subsection{The input file} -\label{sec:inputfile} - -The \meta{input file} must comply with \emph{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| and after -\lstinline|\end{document}| can go any type of content, internally the script will -\emph{\enquote{split}} the \meta{input file} at this points. - -If the \meta{input file} contains files using \Lcs{input}\marg[type=tt]{file} or -\Lcs{include}\marg[type=tt]{file} 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 \Lscript{latexpand}\footnote{\url{https://www.ctan.org/pkg/latexpand}} -first and then process the file. - -Like \Lcs{input}\marg[type=tt]{file} or \Lcs{include}\marg[type=tt]{file}, 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 \Lprog{chktex}\footnote{\url{https://www.ctan.org/pkg/chktex}} and -\Lscript{latexindent}\footnote{\url{https://www.ctan.org/pkg/latexindent}}, especially if you want to -extract the source code of the environments. - -Both \Lcs{thispagestyle}\marg[type=tt]{style} and \Lcs{pagestyle}\marg[type=tt]{style} -are treated in a special way by the script, if they do not appear in the -preamble then \Lcs{pagestyle}\marg[type=tt]{empty} will be added and if they are present -and \marg[type=tt]{style} is different from \marg[type=tt]{empty} this -will be replaced by \marg[type=tt]{empty}. - -This is necessary for the image creation process, it does not affect the \meta{output file}, but -it does affect the \emph{standalone} files. For the script the process of dividing the \meta{input file} into four -parts and then processing them: - -\begin{examplecode}[numbers=left,frame=single] -% Part One: Everything before \documentclass -\documentclass{article} -% Part two: Everything between \documentclass and \begin{document} -\begin{document} -% Part three: : Everything between \begin{document} and \end{document} -\end{document} -% Part Four: Everything after \end{document} -\end{examplecode} - -If for some reason you have an environment \Lenv{filecontens} before \lstinline|\documentclass| or -in the preamble of the \meta{input file} that contains a \emph{sub-document} or \emph{environment} -you want to extract, the script will ignore them. - -\subsection{Verbatim contents} -\label{sec:verbatim} - -One of the greatest capabilities of this script is to \emph{\enquote{skip}} -the complications that \meta{verbatim content} produces with the extraction -of environments using tools outside the \enquote{\hologo{TeX} world}. -In order to \emph{\enquote{skip}} the complications, the \meta{verbatim content} is classified into -three types: - -\begin{itemize}[nosep] - \item Verbatim in line. - \item Verbatim standard. - \item Verbatim write. -\end{itemize} - -\subsubsection{Verbatim in line} -\label{sec:verbatim:inline} - -The small pieces of code written using a \emph{\enquote{verbatim macro}} -are considered \meta{verbatim in line}, such as \lstinline+\verb|+\meta{code}\lstinline+|+ -or \lstinline+\verb*|+\meta{code}\lstinline+|+ or \lstinline+\macro+\marg[type=tt]{code} or -\lstinline+\macro+\oarg[type=tt]{opts}\marg[type=tt]{code}. - -Most \emph{\enquote{verbatim macro}} provide by packages \LPack{minted}, % -\LPack{fancyvrb} and \LPack{listings} have been tested and are fully -supported. They are automatically detected the \emph{verbatim macro} (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) generates by -\Lcs{newmint} and \Lcs{newmintinline} and the following list: - -\vspace*{-10pt} -\begin{multicols}{3} -\begin{itemize}[font=\sffamily\small,partopsep=5pt,parsep=5pt,nosep,leftmargin=*] -\small -\item \Lcs{mint} -\item \Lcs{spverb} -\item \Lcs{qverb} -\item \Lcs{fverb} -\item \Lcs{verb} -\item \Lcs{Verb} -\item \Lcs{lstinline} -\item \Lcs{pyginline} -\item \Lcs{pygment} -\item \Lcs{Scontents} -\item \Lcs{tcboxverb} -\item \Lcs{mintinline} -\end{itemize} -\end{multicols} - -Some packages define abbreviated versions for \emph{\enquote{verbatim macro}} as % -\Lcs{DefineShortVerb}, \Lcs{lstMakeShortInline} and % -\Lcs{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 macros, such as \LPack{shortvrb} or % -\LPack{doc} for example in which there is no explicit \lstinline+\macro+ in the -document by means of which the abbreviated form can be detected, for -automatic detection need to find \Lcs{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 \emph{\enquote{verbatim macro}} is not -supported by default or can not detect, use the options described in \ref% -{sec:optline}. - -\subsubsection{Verbatim standard} -\label{sec:verbatim:std} - -These are the \emph{\enquote{classic}} environments for \emph{\enquote{writing code}} are considered % -\meta{verbatim standard}, such as \Venv{verbatim} and \Venv{lstlisting} -environments. The following list (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) -is considered as \meta{verbatim standard} environments: - -\begin{multicols}{4} -\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] -\small -\item \Venv{Example} -\item \Venv{CenterExample} -\item \Venv{SideBySideExample} -\item \Venv{PCenterExample} -\item \Venv{PSideBySideExample} -\item \Venv{verbatim} -\item \Venv{Verbatim} -\item \Venv{BVerbatim} -\item \Venv{LVerbatim} -\item \Venv{SaveVerbatim} -\item \Venv{PSTcode} -\item \Venv{LTXexample} -\item \Venv{tcblisting} -\item \Venv{spverbatim} -\item \Venv{minted} -\item \Venv{listing} -\item \Venv{lstlisting} -\item \Venv{alltt} -\item \Venv{comment} -\item \Venv{chklisting} -\item \Venv{verbatimtab} -\item \Venv{listingcont} -\item \Venv{boxedverbatim} -\item \Venv{demo} -\item \Venv{sourcecode} -\item \Venv{xcomment} -\item \Venv{pygmented} -\item \Venv{pyglist} -\item \Venv{program} -\item \Venv{programl} -\item \Venv{programL} -\item \Venv{programs} -\item \Venv{programf} -\item \Venv{programsc} -\item \Venv{programt} -\end{itemize} -\end{multicols} - -They are automatically detected \meta{verbatim standard} environments -(including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) -generates by commands: - -\begin{multicols}{2} -\begin{itemize}[font=\sffamily\small,noitemsep,leftmargin=*] -\small -\item \Lcs{DefineVerbatimEnvironment} -\item \Lcs{NewListingEnvironment} -\item \Lcs{DeclareTCBListing} -\item \Lcs{ProvideTCBListing} -\item \Lcs{lstnewenvironment} -\item \Lcs{newtabverbatim} -\item \Lcs{specialcomment} -\item \Lcs{includecomment} -\item \Lcs{newtcblisting} -\item \Lcs{NewTCBListing} -\item \Lcs{newverbatim} -\item \Lcs{NewProgram} -\item \Lcs{newminted} -\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}. - -\subsubsection{Verbatim write} -\label{sec:verbatim:write} - -Some environments have the ability to write \emph{\enquote{external files}} -or \emph{\enquote{store content}} in memory, these environments are -considered \meta{verbatim write}, such as \Wenv{scontents}, \Wenv{filecontents} -or \Lenv{VerbatimOut} environments. The following list is considered (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) as % -\meta{verbatim write} environments: - -\begin{multicols}{4} -\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] -\ttfamily\small -\item \Wenv{scontents} -\item \Wenv{filecontents} -\item \Wenv{tcboutputlisting} -\item \Wenv{tcbexternal} -\item \Wenv{tcbwritetmp} -\item \Wenv{extcolorbox} -\item \Wenv{extikzpicture} -\item \Wenv{VerbatimOut} -\item \Wenv{verbatimwrite} -\item \Wenv{filecontentsdef} -\item \Wenv{filecontentshere} -\item \Wenv{filecontentsdefmacro} -\item \Wenv{filecontentsdefstarred} -\item \Wenv{filecontentsgdef} -\item \Wenv{filecontentsdefmacro} -\item \Wenv{filecontentsgdefmacro} -\end{itemize} -\end{multicols} - -They are automatically detected \meta{verbatim write} -(including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) environments generates -by commands: - -\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] -\small -\item \Lcs{renewtcbexternalizetcolorbox} -\item \Lcs{renewtcbexternalizeenvironment} -\item \Lcs{newtcbexternalizeenvironment} -\item \Lcs{newtcbexternalizetcolorbox} -\item \Lcs{newenvsc} -\end{itemize} - -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}. - -\subsection{Steps process} -\label{sec:steps:process} - -For creation of the image formats, extraction of source code of environments and creation of an -\meta{output file}, \Lscript{pst2pdf} need a various steps. Let's assume that the % -\meta{input file} is \LFile{test.tex}, \meta{output file} is % -\LFile{test-pdf.tex}, the working directory are \enquote{\texttt{./}}, the -directory for images are \texttt{./images}, the temporary -directory is \texttt{/tmp} and we want to generate images in \Limgform{pdf} -format and \meta{standalone} files for all environments extracted. - -We will use the following code as \LFile{test.tex}: - -\begin{examplecode}[numbers=left,frame=single] -% Some commented lines at begin file -\documentclass{article} -\usepackage{pstricks} -\begin{document} -Some text -\begin{pspicture} - Some code -\end{pspicture} -Always use \verb|\begin{pspicture}| and \verb|\end{pspicture}| to open -and close environment -\begin{pspicture} - Some code -\end{pspicture} -Some text -\begin{verbatim} -\begin{pspicture} - Some code -\end{pspicture} -\end{verbatim} -Some text -\end{document} -Some lines that will be ignored by the script -\end{examplecode} - -\subsubsection{Validating Options} - -The first step is read and validated \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} from the command -line, verifying that \LFile{test.tex} contains \emph{some} environment to extract, -check the directory \texttt{./images} if it doesn't exist create it and create a temporary directory \texttt{/tmp/hG45uVklv9}. - -The entire \LFile{test.tex} file is loaded into memory and \emph{\enquote{split}} to start the extraction process. - -\subsubsection{Comment and ignore} -In the second step, once the file \LFile{test.tex} is loaded and divided in memory, -proceeds (in general terms) as follows: - -\begin{quotation} -Search the words \lstinline|\begin{| and \lstinline|\end{| in verbatim standard, verbatim write, verbatim in line and -commented lines, if it finds them, converts to \lstinline|\BEGIN{| and \lstinline|\END{|, then places all code to -extract inside the \lstinline|\begin{preview}| \ldots \lstinline|\end{preview}|. -\end{quotation} - -At this point \emph{\enquote{all}} the code you want to extract is inside \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}|. - -\subsubsection{Creating standalone files and extracting} - -In the third step, the script generate \meta{standalone} files: \LFile{test-fig-1.tex}, -\LFile{test-fig-2.tex}, \dots{} and saved in \texttt{./images} then proceed in two ways -according to the \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} -passed to generate a temporary file with a random number (1981 for example): - -\begin{enumerate}[leftmargin=*] -\item If script is call \emph{without} \cmdopt{noprew} options, the following lines -will be added at the beginning of the \LFile{test.tex} (in memory): - -\begin{examplecode} -\PassOptionsToPackage{inactive}{pst-pdf}% -\AtBeginDocument{% -\RequirePackage[inactive]{pst-pdf}% -\RequirePackage[active,tightpage]{preview}% -\renewcommand\PreviewBbAdjust{-60pt -60pt 60pt 60pt}}% -% rest of input file -\end{examplecode} - -The different parts of the file read in memory are joined and save in a temporary -file \LFile{test-fig-1981.tex} in \texttt{./}. This file will contain all the environments -for extraction between \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}| along with the rest of the document. -If the document contains images, these must be in the formats supported by the \emph{engine} selected to process the \meta{input file}. - -\item If script is call \emph{with} \cmdopt{noprew} options, the \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}| -lines are only used as delimiters for extracting the content \emph{without} using the package \LPack{preview}, the following lines -will be added at the beginning of the \LFile{test.tex} (in memory): - -\begin{examplecode} -\PassOptionsToPackage{inactive}{pst-pdf}% -\AtBeginDocument{% -\RequirePackage[inactive]{pst-pdf}}% -% only environments extracted -\end{examplecode} - -Then it is joined with all extracted environments separated by \Lcs{newpage} and saved -in a temporary file \LFile{test-fig-1981.tex} in \enquote{\texttt{./}}. - -\end{enumerate} - -If \cmdopt{norun} is passed, the temporary file \LFile{test-fig-1981.tex} -is renamed to \LFile{test-fig-all.tex} and moved to \texttt{./images}. - -\subsubsection{Generate image formats} - -In the fourth step, the script generating the file \LFile{test-fig-1981.pdf} with all code extracted and croping, running: -\begin{examplecmd} -[user@machine ~:]§ `\small\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler}` -no-shell-escape -interaction=nonstopmode -recorder test-fig-1981.tex -[user@machine ~:]§ pdfcrop --margins `\small\textcolor{gray}{0}` test-fig-1981.pdf test-fig-1981.pdf -\end{examplecmd} - -Now move \LFile{test-fig-1981.pdf} to \texttt{/tmp/hG45uVklv9} and rename to \LFile{test-fig-all.pdf}, generate image files \LFile{test-fig-1.pdf} -and \LFile{test-fig-2.pdf} and copy to \texttt{./images}, if the image files exist, they will be rewritten each time you run the script. The file \LFile{test-fig-1981.tex} is -moved to the \texttt{./images} and rename to \LFile{test-fig-all.tex}. - - - - -Note the options passed to \meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} always use \prgopt*{no-shell-escape} -and \prgopt*{recorder}, to generate the \Lext{fls} file which is used to delete temporary files and directories after -the process is completed and. The \cmdopt{shell} option activates \prgopt*{shell-escape} for compatibility with packages -such as \LPack{minted} or others. - -\subsubsection{Create output file} - -In the fifth step, the script creates the output file \LFile{test-pdf.tex} converting all extracted code to -\Lcs{includegraphics}, remove all \PST{} packages and content betwen \lstinline|%CleanPST ... %CleanPST|, then -adding the following lines at end of preamble: - -\begin{examplecode}[numbers=left] -\usepackage{graphicx} -\graphicspath{{images/}} -\usepackage{grfext} -\PrependGraphicsExtensions*{.pdf} -\end{examplecode} - -The script will try to detect whether the \LPack{graphicx} package and -the \Lcs{graphicspath} command are in the preamble of the \meta[cf=optcolor]{output file}. -If it is not possible to find it, it will read the \Lext{log} file generated by the temporary file. -Once the detection is complete, the package \LPack{grfext} and \Lcs{PrependGraphicsExtensions*} -will be added at the end of the preamble, then proceed to run: - -\begin{examplecmd} -[user@machine ~:]§ `\small\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler}` -recorder -shell-escape test-pdf.tex -\end{examplecmd} -generating the file \LFile{test-pdf.pdf}. - -\subsubsection{Clean temporary files and dirs} - -In the sixth step, the script read the files \LFile{test-fig-1981.fls} -and \LFile{test-out.fls}, extract the information from the -temporary files and dirs generated in the process in \enquote{\texttt{./}} and then -delete them together with the directory \texttt{/tmp/hG45uVklv9}. - -Finally the output file \texttt{test-pdf.tex} looks like this: - -\begin{examplecode}[numbers=left] -% some commented lines at begin document -\documentclass{article} -\usepackage{graphicx} -\graphicspath{{images/}} -\usepackage{grfext} -\PrependGraphicsExtensions*{.pdf} -\begin{document} -Some text -\includegraphics[scale=1]{test-fig-1} -Always use \verb|\begin{pspicture}| and \verb|\end{pspicture}| to open -and close environment -\includegraphics[scale=1]{test-fig-2} -Some text -\begin{verbatim} -\begin{pspicture} - Some code -\end{pspicture} -\end{verbatim} -Some text -\end{document} -\end{examplecode} - -\section{Default extracted environments} -\label{sec:extract:env} - -\nxLprog{pst2pdf} support fourth environments for extraction. Internally -the script converts all environments to extract in \Lenv{preview} environments. -Is better comment this package in preamble unless the option \cmdopt{noprew} is used. - -\DescribeTE{postscript} -Environment provide by \LPack{pst-pdf}\cite{pst-pdf}, \LPack{auto-pst-pdf}\cite{auto-pst-pdf} -and \LPack{auto-pst-pdf-lua}\cite{auto-pst-pdf-lua} packages. Since the \LPack{pst-pdf}, \LPack{auto-pst-pdf} -and \LPack{auto-pst-pdf-lua} packages internally use the \LPack{preview} package, is better comment this in preamble. -Only the \emph{content} of this environment is extracted and \emph{\enquote{not}} the environment itself when using the -\cmdopt{srcenv} option. The \Lenv{postscript} environment should always be used, when there is some code before a \Lenv{pspicture} -environment or for some code which is not inside of a \Lenv{pspicture} environment. - -\DescribeTE{pspicture} -Environment provide by \LPack{pstricks}\cite{girou:02:} package. The plain \hologo{TeX} -syntax \lstinline|\pspicture ... \endpspicture| its converted to \hologo{LaTeX} syntax -\lstinline|\begin{pspicture} ... \end{pspicture}| if not within the \Lenv{PSTexample} or \Lenv{postscript} environments. - -\DescribeTE{psgraph} -Environment provide by \LPack{pst-plot}\cite{pst-plot} package. The plain \hologo{TeX} syntax \lstinline|\psgraph ... \endpsgraph| -its converted to \hologo{LaTeX} syntax \lstinline|\begin{psgraph} ... \end{psgraph}| if -not within the \Lenv{PSTexample} or \Lenv{postscript} environments. - -\DescribeTE{PSTexample} -Environment provide by \LPack{pst-exa}\cite{pst-exa} package. The script automatically detects the -\lstinline|\begin{PSTexample}| \lstinline|...\end{PSTexample}| -environments and processes them as separately compiled files. The user should have loaded the -package with [\Loption{swpl}] or [\Loption{tcb}] option. - -\section{Remove \PST\ code} - -By design, the script remove all \PST{} packages in preamble of \meta{output file}, if you need delete other \PST\ code in preamble use: - -\DescribeTE*{CleanPST} -All content betwen \lstinline|%CleanPST ... %CleanPST| are deleted in preamble of the \meta[cf=optcolor]{output file}. -This lines can \emph{not} be nested and should be at the beginning of the line and in separate lines. - -\section{Supported image formats} -\label{sec:image:format} - -The \Larga{image formats} generated by the \Lscript{pst2pdf} using \Lprog{Ghostscript} -and \Lprog{poppler-utils} are the following command lines: - -\DescribeIF{pdf} -The image format generated using \Lprog{Ghostscript}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -\end{examplecmd} - -\DescribeIF{eps} -The image format generated using \Lprog{pdftoeps}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ pdftops -q -eps -\end{examplecmd} - -\DescribeIF{png} -The image format generated using \Lprog{Ghostscript}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pngalpha -r150 -\end{examplecmd} - -\DescribeIF{jpg} -The image format generated using \Lprog{Ghostscript}. The line executed by the system is: -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=jpeg -r150 -dJPEGQ=100 \ - -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -\end{examplecmd} - -\DescribeIF{ppm} -The image format generated using \Lprog{pdftoppm}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ pdftoppm -q -r 150 -\end{examplecmd} - -\DescribeIF{tiff} -The image format generated using \Lprog{Ghostscript}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=tiff32nc -r150 -\end{examplecmd} - -\DescribeIF{svg} -The image format generated using \Lprog{pdftocairo}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ pdftocairo -q -r 150 -\end{examplecmd} - -\DescribeIF{bmp} -The image format generated using \Lprog{Ghostscript}. The line executed by the system is: - -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=bmp32b -r150 -\end{examplecmd} - -\section{How to use} - -\subsection{Syntax} - -The syntax for \myscript\ is simple, if your use the version provided in your \hologo{TeX} distribution: - -\begin{examplecmd} -[user@machine ~:]§ pst2pdf `\small\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} \meta[cf=optcolor]{input file}` -\end{examplecmd} -or -\begin{examplecmd} -[user@machine ~:]§ pst2pdf `\small\meta[cf=optcolor]{input file} \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options}` -\end{examplecmd} -If the development version is used: -\begin{examplecmd} -[user@machine ~:]§ perl pst2pdf `\small\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} \meta[cf=optcolor]{input file}` -\end{examplecmd} - -The extension valid for \meta[cf=optcolor]{input file} are \Lext{tex} or \Lext{ltx}, -relative or absolute paths for files and directories is not supported. If used without -\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} the extracted environments are converted to \Limgform{pdf} -image format and saved in the \texttt{./images} directory using \Lprog{latex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} -and \LPack{preview} package for process \meta[cf=optcolor]{input file} and \Lprog{pdflatex} for compiler \meta[cf=optcolor]{output file}. - -\subsection{Command line interface} -\label{sec:optline} - -The script provides a \emph{command line interface} with short \textcolor{optcolor}{\bfseries\texttt{-}} -and long \textcolor{optcolor}{\bfseries\texttt{--}} option, they may be given before -the name of the \meta[cf=optcolor]{input file}, the order of specifying the options is not significant. -Options that accept a \meta{value} require either a blank space \verb*| | or \textcolor{optcolor}{\bfseries\texttt{=}} -between the option and the \meta{value}. Some short options can be bundling. - -\DescribeCmd[h]{help}{bolean}{off} -Display a command line help and exit. - -\DescribeCmd[l]{log}{bolean}{off} -Write a \LFile{pst2pdf.log} file with all process information. - -\DescribeCmd[v]{version}{bolean}{off} -Display the current version (\fileversion) and exit. - -\DescribeCmd[V]{verbose}{bolean}{off} -Show verbose information of process in terminal. - -\DescribeCmd[d]{dpi}{integer}{150} -Dots per inch for images files. Values are positive integers less than or equal to 2500. - -\DescribeCmd[t]{tif}{bolean}{off} -Create a \Lext{tif} images files using \Lprog{Ghostscript}. - -\DescribeCmd[b]{bmp}{bolean}{off} -Create a \Lext{bmp} images files using \Lprog{Ghostscript}. - -\DescribeCmd[j]{jpg}{bolean}{off} -Create a \Lext{jpg} images files using \Lprog{Ghostscript}. - -\DescribeCmd[p]{png}{bolean}{off} -Create a \Lext{png} transparent image files using \Lprog{Ghostscript}. - -\DescribeCmd[e]{eps}{bolean}{off} -Create a \Lext{eps} image files using \Lprog{pdftops}. - -\DescribeCmd[s]{svg}{bolean}{off} -Create a \Lext{svg} image files using \Lprog{pdftocairo}. - -\DescribeCmd[P]{ppm}{bolean}{off} -Create a \Lext{ppm} image files using \Lprog{pdftoppm}. - -\DescribeCmd[g]{gray}{bolean}{off} -Create a gray scale for all images using \Lprog{Ghostscript}. The line behind this options is: - -\begin{examplecmd} -[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress \ - -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -\end{examplecmd} - -\DescribeCmd[f]{force}{bolean}{off} -Try to capture \lstinline|\psset|\marg[type=tt]{code} to extract. -When using the \cmdopt{force} option the script will try to capture \lstinline|\psset|\marg[type=tt]{code} and -leave it inside the \Lenv{preview} environment, any line that is between \lstinline|\psset|\marg[type=tt]{code} and -\lstinline|\begin{pspicture}| will be captured. - -\DescribeCmd[np]{noprew}{bolean}{off} -Create images files without \LPack{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 \LPack{preview}. -Using this option \emph{\enquote{only}} the extracted environments are processed and not the whole \meta[cf=optcolor]{input file}, sometimes -it is better to use it together with \cmdopt{force}. Alternative name \cmdopt{single}. - -\DescribeCmd[m]{margins}{integer}{0} -Set margins in bp for \Lscript{pdfcrop}. - -\DescribeCmd[r]{runs}{\textnormal{\ttfamily 1\textbar 2\textbar 3}}{1} -Set the number of times the \meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} will run -on the \meta[cf=optcolor]{input file} for environment extraction. - -\DescribeCmd{myverb}{macro name}{myverb} -Set custom verbatim command \lstinline+\myverb+. Just pass the \meta{macro name}{} -\emph{without} \enquote{\textcolor{optcolor}{\texttt{\bfseries\textbackslash}}}. - -\DescribeCmd{ignore}{environment name}{empty} -Add a verbatim environment to internal list. - -\DescribeCmd{imgdir}{string}{images} -Set the name of directory for save generated files. Only the \meta{name} of directory -must be passed \emph{without} relative or absolute paths. - -\DescribeCmd{srcenv}{bolean}{off} -Create separate files with \emph{\enquote{only code}} for all extracted -environments. - -\DescribeCmd{shell}{bolean}{off} -Enable \Lcs{write18}\meta{shell command}. - -\DescribeCmd[ni]{norun}{bolean}{off} -Execute the script, but do not create image files. This option is designed to -to generate standalone files or used in conjunction with \cmdopt{srcenv} and to -debug the \meta[cf=optcolor]{output file}. Alternative name \cmdopt{noimages}. - -\DescribeCmd{nopdf}{bolean}{off} -Don't create a \Lext{pdf} image files. - -\DescribeCmd{nocrop}{bolean}{off} -Don't run \Lscript{pdfcrop} in image files. - -\DescribeCmd[ns]{nosource}{bolean}{off} -Don't create standalone files. - -\DescribeCmd[x]{xetex}{bolean}{off} -Using \Lprog{xelatex} compiler \meta[cf=optcolor]{input file} and \meta[cf=optcolor]{output file}. - -\DescribeCmd{luatex}{bolean}{off} -Using \Lprog{dvilualatex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} -for compiler \meta[cf=optcolor]{input file} and \Lprog{lualatex} for \meta[cf=optcolor]{output file}. - -\DescribeCmd{arara}{bolean}{off} -Use \Lprog{arara}\footnote{\url{https://ctan.org/pkg/arara}} tool for compiler \meta[cf=optcolor]{output file}. -This option is designed to full process \meta[cf=optcolor]{output file}, is mutually -exclusive with \cmdopt{latexmk} option. - -\DescribeCmd{latexmk}{bolean}{off} -Using \Lscript{latexmk}\footnote{\url{https://www.ctan.org/pkg/latexmk}} for process \meta[cf=optcolor]{output file}. -This option is designed to full process \meta[cf=optcolor]{output file}, is mutually exclusive with \cmdopt{arara}. - -\DescribeCmd{zip}{bolean}{off} -Compress the files generated by the script in \texttt{./images} in \Lext{zip} format. -Does not include \meta[cf=optcolor]{output file}. - -\DescribeCmd{tar}{bolean}{off} -Compress the files generated by the script in \texttt{./images} in \Lext{tar.gz} format. -Does not include \meta[cf=optcolor]{output file}. - -\DescribeCmd{bibtex}{bolean}{off} -Run \Lprog{bibtex} on the \Lext{aux} file (if exists), is mutually -exclusive with \cmdopt{biber} option. - -\DescribeCmd{biber}{bolean}{off} -Run \Lprog{biber} on the \Lext{bcf} file (if exists), is mutually -exclusive with \cmdopt{bibtex} option. - -\subsection{Example of usage} - -An example of usage from command line: - -\begin{examplecmd} -[user@machine ~:]§ pst2pdf --luatex -e -p -j --imgdir pics test.ltx -\end{examplecmd} - -Create a \texttt{./pics} directory (if it does not exist) with all extracted environments converted to image -formats (\Lext{pdf}, \Lext{eps}, \Lext{png}, \Lext{jpg}) in individual files, an stanalone files (\Lext{ltx}) for all environments extracted, -an output file \LFile{test-pdf.ltx} with all extracted environments converted to \Lcs{includegraphics} and a single file -\LFile{test-fig-all.ltx} with only the extracted environments -using \Lprog{dvilualatex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} -and \LPack{preview} package for for process \LFile{test.ltx} and -\Lprog{lualatex} for \LFile{test-pdf.ltx}. - -\section{Working in another way} - -By design, the script generates separate images and files following a predetermined -routine that has already been described in this documentation. Another way to generate -images is as follows: - -\begin{enumerate}[font=\small, nosep, noitemsep,leftmargin=*] -\item Execute the script using \cmdopt{norun} to generate \meta{standalone} files, move to \texttt{./images} -and generate \Lext{pdf} files runing: - -\begin{examplecmd} -[user@machine~:]§for i in *.tex; do `\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} \oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` $i; done -[user@machine~:]§for i in *.pdf; do pdfcrop `\small\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` $i $i; done -\end{examplecmd} - -\item Execute the script using \cmdopt{norun}, move to \texttt{./images} \Lext{pdf} file runing: - -\begin{examplecmd} -[user@machine~:]§`\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} \oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test-fig-all.tex -[user@machine~:]§pdfcrop `\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test-fig-all.pdf -\end{examplecmd} - -\end{enumerate} - -\section{Example files} - -The \texttt{pst2pdf} documentation provides three example files \LFile{test1.tex}, \LFile{test2.tex} -and \LFile{test3.tex} plus an image file \LFile{tux.jpg} to test and view the script in action. -Copy these files to a directory you have write access to and execute: - -\begin{examplecmd} -[user@machine~:]§pst2pdf `\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test1.tex -\end{examplecmd} - -To see how this works. -%\newpage -\clearpage -\nocite{*} -\printbibliography - -\printindex - -\end{document} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf deleted file mode 100644 index 9766af2cb72..00000000000 Binary files a/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test1.tex b/Master/texmf-dist/doc/latex/pst2pdf/test1.tex deleted file mode 100644 index 9d52356ba09..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test1.tex +++ /dev/null @@ -1,69 +0,0 @@ -\documentclass[12pt,english]{article} -\usepackage[T1]{fontenc} -\usepackage{pstricks} -\usepackage{pst-node} -\usepackage{pst-3dplot} -\usepackage{pst-calendar} -\usepackage{blindtext} -\usepackage{babel} -\usepackage{microtype}% for the last pdflatex run -\begin{document} - -foo\begin{pspicture}[showgrid=true](4,2)\psscaleboxto(8,2){foo}\end{pspicture}bar - -\begin{pspicture}[showgrid=true](4,2) - \psscaleboxto(8,2){foo bar} -\end{pspicture} - -\blindtext - -foo\begin{pspicture}[showgrid=true](4,2) - \psscaleboxto(8,2){foo bar baz} -\end{pspicture}bar - -\blindtext - - -\begin{postscript} -\psscalebox{0.5}{% -\psCalDodecaeder[style=january,unit=0.75,Year=2010]} -\end{postscript} - -\includegraphics{tux.jpg}% a jpg image - -\blindtext - -\begin{postscript}\rnode{foo}{foo} bar baz - -foo bar baz foo bar \rnode{baz}{baz} foo bar baz -\ncarc[linecolor=red]{<->}{foo}{baz}\end{postscript} - -\blindtext - -\begin{postscript} -\psframebox{% -\begin{pspicture}(-3,-2)(3,6.5) -\pstThreeDCoor[zMax=7] -\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} -\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) -\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) -\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) -\end{pspicture} -} -\end{postscript} - -\blindtext - -\blindtext - -\begin{postscript} -\begin{pspicture*}(-4,-2)(3,6.5) -\pstThreeDCoor[zMax=7] -\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} -\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) -\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) -\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) -\end{pspicture*} -\end{postscript} - -\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf deleted file mode 100644 index a1dedfef29f..00000000000 Binary files a/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test2.tex b/Master/texmf-dist/doc/latex/pst2pdf/test2.tex deleted file mode 100644 index 42babf4234c..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test2.tex +++ /dev/null @@ -1,66 +0,0 @@ -\documentclass[12pt,english]{article} -\usepackage[T1]{fontenc} -\usepackage{pstricks} -\usepackage{pst-node} -\usepackage{pst-3dplot} -\usepackage{pst-calendar} -\usepackage{blindtext} -\usepackage{babel} -\usepackage{microtype}% for the last pdflatex run -\begin{document} - -foo\begin{pspicture}[showgrid=true](4,2)\psscaleboxto(8,2){foo}\end{pspicture}bar - -\begin{pspicture}[showgrid=true](4,2) - \psscaleboxto(4,2){foo bar} -\end{pspicture} - - -foo\begin{pspicture}[showgrid=true](4,2) - \psscaleboxto(8,2){foo bar baz} -\end{pspicture}bar - - - -\begin{postscript} -\psscalebox{0.5}{% -\psCalDodecaeder[style=january,unit=0.75,Year=2020]} -\end{postscript} - -\includegraphics{tux.jpg}% a jpg image - - -foo bar baz foo bar baz - -\begin{postscript}\rnode{foo}{foo} bar baz - -foo bar baz foo bar \rnode{baz}{baz} foo bar baz -\ncarc[linecolor=red]{<->}{foo}{baz}\end{postscript} - -foo bar baz - -\begin{postscript} -\psframebox{% -\begin{pspicture}(-3,-2)(3,6.5) -\pstThreeDCoor[zMax=7] -\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} -\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) -\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) -\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) -\end{pspicture} -} -\end{postscript} - - -\begin{postscript} -\begin{pspicture*}(-4,-2)(3,6.5) -\pstThreeDCoor[zMax=7] -\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} -\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) -\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) -\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) -\end{pspicture*} -\end{postscript} - - -\end{document} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf deleted file mode 100644 index 99f28c30255..00000000000 Binary files a/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test3.tex b/Master/texmf-dist/doc/latex/pst2pdf/test3.tex deleted file mode 100644 index 7703cf05364..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test3.tex +++ /dev/null @@ -1,27 +0,0 @@ -\documentclass{article} -\usepackage{graphicx,pst-3dplot} -\pagestyle{empty} -\parindent=0pt -\begin{document} - -foo -\begin{postscript} -\psframebox{% begin box -\pspicture(-3,-2)(3,6.5) -\pstThreeDCoor[zMax=7] -\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} -\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) -\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) -\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) -\endpspicture}% end box -\end{postscript} - -bar - -\pspicture(3,3) -\psframe[fillstyle=solid,fillcolor=red!30](3,3) -\endpspicture - -\includegraphics{tux.jpg} -% Ende -\end{document} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/tux.jpg b/Master/texmf-dist/doc/latex/pst2pdf/tux.jpg deleted file mode 100644 index 275f977a3aa..00000000000 Binary files a/Master/texmf-dist/doc/latex/pst2pdf/tux.jpg and /dev/null differ diff --git a/Master/texmf-dist/doc/support/pst2pdf/Changes b/Master/texmf-dist/doc/support/pst2pdf/Changes new file mode 100644 index 00000000000..95ee0eea16b --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/Changes @@ -0,0 +1,40 @@ +pst2pdf.pl -------- +0.20 2020-08-24 - Fix graphicx detection + - Fix typo in documentation + - Remove unused vars +0.19 2020-08-17 - Add new options to CLI + - Remove deprecate code + - Rewrite documentation + - Remove unused options +0.18 2017-10-04 - Fix typos in the code comments +0.17 2017-09-11 - Fix escape character in regex +0.16 2014-09-14 - Using gs for split pdf (no more pdftk) + - Support package pst-exa for examples + - Adding svg image support + - Ignore inline verbatim +0.15 2013-06-16 - Adding short options for command line + - Create png and jpg files in Linux and Windows + - Pass options to ps2pdf +0.14 2013-02-27 - Suport xelatex and -help from command line +0.13 2011-12-12 - Some more improvements to the code +0.12 2011-01-19 - New optional arguments for running + bibtex or biber +0.11 2010-10-03 - Use graphicspath instead of $imageDir to + allow working with Windows + - Test for pst-exa to write \psset in the + pdf file +0.10 2010-01-04 - Allow using the package pst-exa +0.09 2009-10-01 - Allow pspicture* +0.08 2009-08-28 - Test for png files (only for Linux) +0.07 2009-07-24 - Fix bug with \begin{postscript} and following + pspicture environment + - Add some more documentation +0.06 2007-08-28 - Fix bug with \begin{pspicture} and \pspicture +0.05 2007-07-05 - Allow different extensions for the source file + e.g. tex, ltx + - Ignore verbatim environment + - Better log file support +0.04 2007-07-04 - Allow all \begin ..\end sequences anywhere + in a line, see testcase +0.03 2007-06-21 - Fix nested environments +0.02 2007-06-20 - First (public) version diff --git a/Master/texmf-dist/doc/support/pst2pdf/Makefile.doc b/Master/texmf-dist/doc/support/pst2pdf/Makefile.doc new file mode 100644 index 00000000000..852c7ab5e53 --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/Makefile.doc @@ -0,0 +1,47 @@ +# `Makefile' for `pst2pdf.pdf', hv, 2017/08/11 + +.SUFFIXES : .tex .ltx .dvi .ps .pdf .eps + +PACKAGE = pst2pdf + +MAIN = $(PACKAGE)-doc + +LATEX = xelatex + +ARCHNAME = $(MAIN)-$(shell date +%y%m%d) + +ARCHFILES = $(PACKAGE).sty $(PACKAGE).tex $(PACKAGE).pro $(MAIN).tex README Changes Makefile + +TDS = ~/PSTricks/PSTricks-TDS + +all : doc clean + +doc: + $(LATEX) --shell-escape $(MAIN) + biber $(MAIN) + $(LATEX) --shell-escape $(MAIN) + $(LATEX) --shell-escape $(MAIN) + +clean : + $(RM) $(addprefix $(MAIN), .log .aux .glg .glo .gls .ilg .idx .ind .tmp .toc .out ) + $(RM) $(addprefix $(MAIN), .dvi .ps .bbl .bcf .blg .run.xml) + +veryclean : clean + $(RM) $(addprefix $(MAIN), .pdf .bbl .blg) + +arch : + zip $(ARCHNAME).zip $(ARCHFILES) + +#tds: +# cp -u Changes $(TDS)/scripts/$(PACKAGE)/ +# cp -u README $(TDS)/scripts/$(PACKAGE)/ +# cp -u doc/$(MAIN).pdf $(TDS)/scripts/$(PACKAGE)/ +# cp -u doc/$(MAIN).tex $(TDS)/scripts/$(PACKAGE)/ +# cp -u doc/$(MAIN).bib $(TDS)/scripts/$(PACKAGE)/ +# cp -u Makefile $(TDS)/scripts/$(PACKAGE)/ +# cp -u doc/test?.tex $(TDS)/scripts/$(PACKAGE)/ +# cp -u doc/test?-pdf.pdf $(TDS)/scripts/$(PACKAGE)/ +# cp -u script/pst2pdf.pl $(TDS)/scripts/$(PACKAGE)/ + + +# EOF diff --git a/Master/texmf-dist/doc/support/pst2pdf/README.md b/Master/texmf-dist/doc/support/pst2pdf/README.md new file mode 100644 index 00000000000..3ef4a697f47 --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/README.md @@ -0,0 +1,93 @@ +# pst2pdf – Running a PSTricks document with pdflatex + +Release v0.19 \[2020-08-17\] + +## Description + +`pst2pdf` is a Perl _script_ which isolates all `PostScript` or `PSTricks` related +parts of the TeX document, read all `postscript`, `pspicture`, `psgraph` and `PSTexample` +environments, extract source code in standalone files and converting them into image +format \(default `pdf`\). Create new file with all extracted environments converted to `\includegraphics` +and runs \(pdf/xe/lua\)latex. + +## Usage + +``` +pst2pdf.pl [] [.tex|.ltx] +``` + +or + +``` +pst2pdf.pl [.tex|.ltx] [] +``` + +Relative or absolute `paths` for directories and files is not supported. Options that accept +a _value_ require either a blank space or `=` between the option and the _value_. Some short +options can be bundling. + +If used without `[]` the extracted environments are converted to `pdf` image format +and saved in the `./images` directory using `latex>dvips>ps2pdf` and `preview` package to +process `` and `pdflatex` to process the output file ``. + +## Restrictions + +The `pspicture` environment can be nested, the `postscript` one **NOT!** `pspicture` can be +inside of a `postscript` environment, but not vice versa. + +```latex +\begin{postscript} + ... + \begin{pspicture} + .... + \end{pspicture} + ... +\end{postscript} +``` + +The `postscript` environment should be used for all other PostScript related commands, which +are not part of a `pspicture` environment, e.g. nodes inside normal text or `\psset{...}` +outside of environment. + +## Installation + +The script `pst2pdf` is present in `TeXLive` and `MiKTeX`, use the package manager to install. + +For manual installation, download [pst2pdf.zip](http://mirrors.ctan.org/graphics/pstricks/scripts/pst2pdf.zip) and unzip it +and move all files to appropriate locations: + +``` + pst2pdf-doc.pdf -> TDS:doc/support/pst2pdf/pst2pdf-doc.pdf + pst2pdf-doc.tex -> TDS:doc/support/pst2pdf/pst2pdf-doc.tex + pst2pdf-doc.bib -> TDS:doc/support/pst2pdf/pst2pdf-doc.bib + test1.tex -> TDS:doc/support/pst2pdf/test1.tex + test2.tex -> TDS:doc/support/pst2pdf/test2.tex + test3.tex -> TDS:doc/support/pst2pdf/test3.tex + test1-pdf.tex -> TDS:doc/support/pst2pdf/test1-pdf.pdf + test2-pdf.tex -> TDS:doc/support/pst2pdf/test2-pdf.pdf + test3-pdf.tex -> TDS:doc/support/pst2pdf/test3-pdf.pdf + tux.jpg -> TDS:doc/support/pst2pdf/tux.jpg + README.md -> TDS:doc/support/pst2pdf/README.md + Changes -> TDS:doc/support/pst2pdf/Changes + pst2pdf.pl -> TDS:scripts/pst2pdf/pst2pdf.pl +``` + +## Documentation + +For more documentation use: + +``` +$ pst2pdf --help +``` + +or + +``` +$ texdoc pst2pdf +``` + +To reproduce the documentation run `xelatex pst2pdf-doc.tex`. + +## Copyright + +Copyright 2013 - 2020 by Herbert Voss `` and Pablo González L ``. diff --git a/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.bib b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.bib new file mode 100644 index 00000000000..81ec2771ce2 --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.bib @@ -0,0 +1,149 @@ +@STRING{tugboat = {TUGboat} } +@STRING{beiprogramm = {{\TeX}-Beiprogramm} } +@STRING{bretter = {Bretter, die die Welt bedeuten} } +@STRING{dtk = {{D}ie {\TeX}nische {K}om{\"o}die} } +@STRING{editorial = {Editorial} } +@STRING{fremdebuehne = {Von fremden B{\"u}hnen} } +@STRING{fundus = {Aus dem Fundus} } +@STRING{hinterbuehne = {Hinter der B{\"u}hne} } +@STRING{leserbrief = {Leserbrief(e)} } +@STRING{magazin = {Magazin} } +@STRING{rezension = {Rezensionen} } +@STRING{schonimmer = {Was Sie schon immer {\"u}ber {\TeX} wissen wollten \dots} } +@STRING{theaterkasse = {Von der Theaterkasse} } +@STRING{theatertage = {{\TeX}-Theatertage} } + +@Book{tlgc2, + author = {Michel Goosens and Frank Mittelbach and Sebastian Rahtz and Denis Roegel and Herbert Vo{\ss}}, + title = {The {\LaTeX} {G}raphics {C}ompanion}, + publisher = {{Addison-Wesley Publishing Company}}, + edition = 2, + year = {2007}, + address = {Reading, Mass.} +} + + +@Article{girou:01:, + author = {Denis Girou}, + title = {Pr\'esentation de {PST}ricks}, + journal = {Cahier {GUT}enberg}, + year = 1994, + volume = {16}, + month = apr, + pages = {21-70} +} + +@Article{girou:02:, + author = {{Timothy van} Zandt and Denis Girou}, + title = {Inside {PST}ricks}, + journal = TUGboat, + year = 1994, + volume = {15}, + month = sep, + pages = {239-246} +} + +@online{pstricks, + Title = {PSTricks - {\PS} macros for generic {\TeX}}, + Author = {{Timothy van} Zandt}, + url = {http://www.tug.org/application/PSTricks}, + year = 1993 +} + +@Book{PSTricks2, + author = {Herbert Vo\ss}, + title = {\texttt{PSTricks} -- {G}rafik f\"ur \TeX{} und \LaTeX}, + edition = {7}, + publisher = {DANTE -- Lehmanns}, + year = {2010}, + address = {Heidelberg/Berlin} +} + +@Book{PSTricks2-UIT, + author = {Herbert Vo\ss}, + title = {PSTricks -- Graphics for \TeX\ and \LaTeX}, + publisher = {UIT}, + year = {2011}, + address = {Cambridge} +} + +@Book{LaTeXRef-UIT, + author = {Herbert Vo\ss}, + title = {{\LaTeX} quick reference}, + publisher = {UIT}, + year = {2012}, + address = {Cambridge} +} + +@online{pst-tools, + author = {Herbert Voß}, + title = {\texttt{pst-tools} -- Helper functions}, + publisher = {CTAN}, + year = {2012}, + url = {https://www.ctan.org/pkg/pst-tools} +} + +@online{preview, + author = {David Kastrup}, + title = {The \texttt{preview} package for \hologo{LaTeX}}, + publisher = {CTAN}, + year = {2017}, + url = {https://www.ctan.org/pkg/preview} +} + +@online{pst-pdf, + author = {Rolf Niepraschk}, + title = {The \texttt{pst-pdf} package}, + publisher = {CTAN}, + year = {2019}, + url = {https://www.ctan.org/pkg/pst-pdf} +} + +@online{auto-pst-pdf, + author = {Will Robertson}, + title = {The \texttt{auto-pst-pdf} package}, + publisher = {CTAN}, + year = {2009}, + url = {https://www.ctan.org/pkg/auto-pst-pdf} +} + +@online{auto-pst-pdf-lua, + author = {Herbert Voß}, + title = {The \texttt{auto-pst-pdf-lua} package - Using \hologo{LuaLaTeX} with \texttt{PSTricks}}, + publisher = {CTAN}, + year = {2018}, + url = {https://www.ctan.org/pkg/auto-pst-pdf-lua} +} + +@online{pst-exa, + author = {Herbert Voß}, + title = {\texttt{pst-exa} - Typeset \texttt{PSTricks} examples, with \hologo{pdfTeX}}, + publisher = {CTAN}, + year = {2017}, + url = {https://www.ctan.org/pkg/pst-exa} +} + +@online{graphicx, + author = {The \hologo{LaTeX3} Project}, + title = {\texttt{graphics} - Enhanced support for graphics}, + publisher = {CTAN}, + year = {2017}, + url = {https://www.ctan.org/pkg/graphicx} +} + +@online{grfext, + author = {Heiko Oberdiek}, + title = {The \texttt{grfext} package}, + publisher = {CTAN}, + year = {2017}, + url = {https://www.ctan.org/pkg/grfext} +} + +@online{pst-plot, + author = {{Timothy van} Zandt and Herbert Voß}, + title = {\texttt{pst-plot} - Plot data using \texttt{PSTricks}}, + publisher = {CTAN}, + year = {2019}, + url = {https://www.ctan.org/pkg/pst-plot} +} + diff --git a/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.pdf b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.pdf new file mode 100644 index 00000000000..4c12fc0f457 Binary files /dev/null and b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.pdf differ diff --git a/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.tex b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.tex new file mode 100644 index 00000000000..b1df6bb901b --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/pst2pdf-doc.tex @@ -0,0 +1,1242 @@ +\documentclass[11pt,english, + BCOR=10mm,DIV=10,% <- changed + bibliography=totoc,parskip=half*,<- changed + headings=small,% <- changed + headinclude=false,% <- changed + footinclude=false,oneside,mpinclude=false]{pst-doc} +\AfterCalculatingTypearea{% + \newgeometry{top=0.5in, bottom=0.3in,left=1.4in,right=0.7in,% + marginparwidth=1.3in,marginparsep=0.1in,footskip=0.2in,% + headheight=1cm,headsep=0.27cm,reversemarginpar}% + \KOMAoptions{headwidth=text,headsepline=:text,footwidth=text}% <- added +} +\recalctypearea +\RedeclareSectionCommand[ + %runin=false, + afterindent=false, + beforeskip=\baselineskip, + afterskip=.5\baselineskip]{section} +\RedeclareSectionCommand[ + %runin=false, + afterindent=false, + beforeskip=.75\baselineskip, + afterskip=.5\baselineskip]{subsection} +\RedeclareSectionCommand[ + %runin=false, + afterindent=false, + beforeskip=.5\baselineskip, + afterskip=.25\baselineskip]{subsubsection} +\listfiles +\let\Lfile\LFile +\usepackage{biblatex} +\addbibresource{\jobname.bib} +%\lstset{language=PSTricks,basicstyle=\footnotesize\ttfamily} +\def\DVI{\textsc{DVI}} +\def\PDF{\textsc{PDF}} +\def\gs{\textsc{Ghostscript}} +\usepackage{multicol,enumitem,hologo,accsupp,csquotes} + +% Identification +\def\myscript{pst2pdf} +\def\fileversion{0.20} +\def\filedate{2020-08-22} + +% Config hyperref +\hypersetup{ + linktoc = all, + pdftitle = {.:: pst2pdf v\fileversion{} [\filedate] --- Running a PSTricks document with (pdf/xe/lua)latex ::.},% + pdfauthor = {Herbert Vo\ss, Pablo Gonz\'{a}lez Luengo},% + pdfsubject = {Documentation for version \fileversion},% + pdfkeywords = {extract, conversion, images, pstricks, standalone files}, + pdfstartview = {FitH},% + bookmarksopenlevel = 2,% +} + +% Some font for verbatim examples +\newfontfamily\lmmitalic{lmmono10-italic.otf}[ + Scale = 0.95,% + Extension = .otf,% + ItalicFont = lmmono10-italic,% + SmallCapsFont = lmmonocaps10-oblique,% + SlantedFont = lmmonoslant10-regular, + ] +% The character of visible space is now taken from Latin Modern Mono +% to prevent fonts in T1. The original definition for xetex/luatex is +% \def\verbvisiblespace{\usefont{OT1}{cmtt}{m}{n}\asciispace} +\def\verbvisiblespace{{\fontfamily{lmtt}\selectfont\char"2423}} +% Add some colors +\definecolor{optcolor}{rgb}{0.281,0.275,0.485} +\definecolor{pkgcolor}{rgb}{0,0.5,0.5} +\definecolor{araracolor}{rgb}{0, 0.72, 0.28} +\definecolor{linkcolor}{rgb}{0.04,0.38,0.04} +\definecolor{rulecolor}{rgb}{0.96,0.96,0.96} + +% new macros +\makeatletter +\def\Lscript#1{\texttt{#1}\index{#1@\texttt{#1}}\index{Script!#1@\texttt{#1}}} +\def\Losystem#1{\texttt{#1}\index{#1@\texttt{#1}}\index{Operating system!#1@\texttt{#1}}} +\def\Loptcmd#1{\index{Options in command line!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} +\def\Limgform#1{\texttt{#1}\index{Image format!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} +\def\Loptprg#1{\index{Compiler options!#1@\texttt{#1}}}% \index{#1@\texttt{#1}} +\def\Venv#1{\texttt{#1}\index{Environment Verbatim!#1@\texttt{#1}}} +\def\Wenv#1{\texttt{#1}\index{Environment Verbatim Write!#1@\texttt{#1}}} + +% Only index a starred version +\RenewDocumentCommand{\LFile}{sm} + { + \IfBooleanTF{#1}% + {% + \LFile{#2} + + }% + {% + \texttt{#2}% + }% + }% + +% \prgopt{sm} : #1 compiler opt, #2 program opt: +\NewDocumentCommand{\prgopt}{sm} + { + \IfBooleanTF{#1}% + {% + \mbox{\textcolor{gray}{\texttt{-{}#2}}}% + \Loptprg{-{}#2}% + }% + {% + \mbox{\textcolor{gray}{\texttt{-{}#2}}}% + \index{#2@\texttt{-{}#2}}\index{Program options!#1@\texttt{-{}#2}}% + }% + }% + +% \DescribeIF{m}, #1 image format +\newsavebox{\marginIF} +\NewDocumentCommand{\DescribeIF}{ m } + {% + \begin{lrbox}{\marginIF}% + \begin{minipage}[t]{\marginparwidth}% + \raggedleft\ttfamily\bfseries% + \textcolor{optcolor}{#1}\hfill + \end{minipage}% + \end{lrbox}% + \index{Image format!#1@\texttt{#1}}% + \leavevmode% + \marginpar{\usebox{\marginIF}}% + \ignorespaces% + }% + +% \myenv{environ} for margin +\NewDocumentCommand{\myenv}{m} + { + \begin{minipage}[t]{\marginparwidth}% + \raggedleft\ttfamily\small% + {\textcolor{gray}{\textbackslash begin\{}}{\bfseries\textcolor{pkgcolor}{#1}}\textcolor{gray}{\}}\par% + \meta[ac=lightgray,cf=gray]{env content}\par% + {\textcolor{gray}{\textbackslash end\{}}{\bfseries\textcolor{pkgcolor}{#1}}\textcolor{gray}{\}}% + \end{minipage}% + \index{Environment suport by default!#1@\texttt{#1}} + } +% CleanPST for margin +\NewDocumentCommand{\mytag}{m} + {% + \begin{minipage}[t]{\marginparwidth}% + \raggedleft\ttfamily\small% + \textcolor{gray}{\%}{\bfseries\textcolor{pkgcolor}{#1}}\par% + \meta[ac=lightgray,cf=gray]{code}\par% + \textcolor{gray}{\%}{\bfseries\textcolor{pkgcolor}{#1}}% + \end{minipage}% + \index{Remove PST code!#1@\texttt{#1}} + }% + +% \DescribeTE{sm}, #1 tag, #2 env +\newsavebox{\marginenvtag} +\NewDocumentCommand{\DescribeTE}{sm}{% +\begin{lrbox}{\marginenvtag}% + \begin{minipage}[t]{\marginparwidth}% + \raggedleft + \IfBooleanTF{#1}{\mytag{#2}}{\myenv{#2}} + \end{minipage}% +\end{lrbox}% + \leavevmode% + \marginpar{\usebox{\marginenvtag}}% + \ignorespaces% +}% +\makeatother + +\ExplSyntaxOn +% \cmdopt[short]{long} +\NewDocumentCommand{\cmdopt}{om} + { + \IfNoValueTF{#1} + { + \textcolor{optcolor}{\texttt{-\/-#2}} + } + { + \textcolor{optcolor}{\texttt{-{}#1}}, + \textcolor{optcolor}{\texttt{-\/-#2}} + } + \Loptcmd{-\/-#2} + } + +% Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} for color +\NewDocumentCommand{\meta}{O{}m} + { + \myscript_meta_generic:Nnn \myscript_meta:n { #1 } { #2 } + } +\NewDocumentCommand{\marg}{O{}m} + { + \myscript_meta_generic:Nnn \myscript_marg:n { #1 } { #2 } + } +\NewDocumentCommand{\oarg}{O{}m} + { + \myscript_meta_generic:Nnn \myscript_oarg:n { #1 } { #2 } + } +% Variables and keys +\tl_new:N \l_myscript_meta_font_tl + +\keys_define:nn { myscript/meta } + { + type .choice:, + type / tt .code:n = \tl_set:Nn \l_myscript_meta_font_tl { \ttfamily }, + type / rm .code:n = \tl_set:Nn \l_myscript_meta_font_tl { \rmfamily }, + type .initial:n = rm, + cf .tl_set:N = \l_myscript_meta_color_tl, + cf .initial:n = black,% + ac .tl_set:N = \l_myscript_meta_anglecolor_tl, + ac .initial:n = lightgray, + sbc .tl_set:N = \l_myscript_meta_brackcolor_tl, + sbc .initial:n = gray, + cbc .tl_set:N = \l_myscript_meta_bracecolor_tl, + cbc .initial:n = gray, + } +% Internal commands +\cs_new_protected:Npn \myscript_meta_generic:Nnn #1 #2 #3 + { + \group_begin: + \keys_set:nn { myscript/meta } { #2 } + \color{ \l_myscript_meta_color_tl } + \l_myscript_meta_font_tl + #1 { #3 } % #1 is \myscript_meta:n, \myscript_marg:n or \myscript_oarg:n + \group_end: + } +\cs_new_protected:Npn \myscript_meta:n #1 + { + \myscript_meta_angle:n { \textlangle } + \myscript_meta_meta:n { #1 } + \myscript_meta_angle:n { \textrangle } + } +\cs_new_protected:Npn \myscript_marg:n #1 + { + \myscript_meta_brace:n { \textbraceleft } + \myscript_meta:n { #1 } + \myscript_meta_brace:n { \textbraceright } + } +\cs_new_protected:Npn \myscript_oarg:n #1 + { + \myscript_meta_brack:n { [ } + \myscript_meta:n { #1 } + \myscript_meta_brack:n { ] } + } +\cs_new_protected:Npn \myscript_meta_meta:n #1 + { + \textnormal{\textit{#1}} + } +\cs_new_protected:Npn \myscript_meta_angle:n #1 + { + \group_begin: + \fontfamily{lmr}\selectfont + \textcolor{\l_myscript_meta_anglecolor_tl}{#1} + \group_end: + } +\cs_new_protected:Npn \myscript_meta_brace:n #1 + { + \group_begin: + \color{\l_myscript_meta_bracecolor_tl} + #1 + \group_end: + } +\cs_new_protected:Npn \myscript_meta_brack:n #1 + { + \textcolor{\l_myscript_meta_brackcolor_tl}{#1} + } + +% \DescribeCmd[...]{...}{...}{...} +\newsavebox{\optcmdline} +\NewDocumentCommand{\DescribeCmd}{ o m m m } + { + \group_begin: + \begin{lrbox}{\optcmdline}% + \begin{minipage}[t]{\marginparwidth}% + \ttfamily\raggedleft% + \IfNoValueTF{#1} + {\textcolor{optcolor}{-\/-#2}} + {\textcolor{optcolor}{-{#1}}\textcolor{gray}{,} \textcolor{optcolor}{-\/-#2}}% + \end{minipage}% + \Loptcmd{-\/-#2} + \end{lrbox}% + \leavevmode% + \marginpar{\usebox{\optcmdline}}% + \meta[ac=lightgray,cf=gray]{#3} + \raggedleft\hfill\textcolor{gray}{\textsf{(default: ~ {#4})}}\ignorespaces\par% + %\vspace*{2pt}\par% + \group_end: +} + +\ExplSyntaxOff +% Don't copy numbers in code example for listings +\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}} + +% Create a language for documentation +\lstdefinelanguage{myscript-doc}{ + texcsstyle=*,% + escapechar=`,% + showstringspaces=false,% + extendedchars=true, % + stringstyle = {\color{red}},% + alsoletter={\-,.},% +% comments + morecomment=[l]{\%},% + commentstyle=\lmmitalic\color{lightgray},% +% Important words 1 + keywordstyle=[1]{\color{NavyBlue}},% + keywords=[1]{PassOptionsToPackage,AtBeginDocument,documentclass,usepackage,section},% +% Important words 2 (macros) + keywordstyle=[2]{\color{blue!75}},% + keywords=[2]{graphicspath,RequirePackage,renewcommand,includegraphics,coordinate,draw,approx,% + PreviewBbAdjust,setlength,parindent,usetikzlibrary,tikzexternalize,psset,tikzset,PrependGraphicsExtensions,% + DefineShortVerb,lstMakeShortInline,MakeSpecialShortVerb,UndefineShortVerb,verb,myverb,macro,put,line},% +% Important words 3, options in input file + keywordstyle=[3]{\color{optcolor!85}},% + keywords=[3]{arara,extensions,luatex,env,norun,% + clean,pst,tkz,eps,pdf,xetex,latex,luatex,dvips,png,latexmk,svg,srcenv,noprew,imgdir},% +% Important words 4, environments and tags + keywordstyle=[4]{\color{pkgcolor}},% + keywords=[4]{pspicture,endpspicture,description,filecontents,PSTexample,% + psgraph, endpsgraph,CleanPST,postscript},% +% Important words 5, directory + keywordstyle=[5]{\color{OrangeRed}},% + keywords=[5]{images},% ,pics +% Important words 6, begin, end and other + keywordstyle=[6]{\color{gray}},% replace this color + keywords=[6]{begin,end,-recorder,doc,active,inactive,tightpage,BEGIN,END,% + -shell-escape,osf,--output-format,dvi},% +% Important words 7, reserved for arara + keywordstyle=[7]{\color{araracolor}},% + keywords=[7]{lualatex,halt,xelatex},% +% Important words 8, pkg and others load in examples + keywordstyle=[8]{\color{SlateBlue}},% + keywords=[8]{graphicx,grfext,article,document,preview,libertinus,pst-pdf},% +% Important words 9, files used in examples + keywordstyle=[10]{\color{OrangeRed}},% + keywords=[10]{test.ltx,test-fig-all.pdf,test-fig-1981.tex,test-fig-1981.pdf, test-fig-1,test-fig-2,test-out,test-in.ltx,% + test-fig-1981.tex,test-out.tex,file-in.tex,file-out,test.tex,test-fig-all.dvi,test-fig-1.svg,test-fig-all.tex},% +}[keywords,tex,comments,strings]% end languaje + +% \begin{examplecode}[opts]...\end{examplecode} +\lstnewenvironment{examplecode}[1][]{% +\lstset{ + language=myscript-doc,% + stringstyle = {\color{red}},% + basicstyle=\ttfamily\small,% + numbersep=1em,% + 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} + {[}{{\textcolor{gray}{[}}}{1} + {]}{{\textcolor{gray}{]}}}{1} + {\*}{{\bfseries\textcolor{MediumOrchid}{*}}}{1} + {:}{{\textcolor{gray}{:}}}{1} + {,}{{\textcolor{gray}{,}}}{1} + {=}{{\textcolor{gray}{=}}}{1} + {/}{{\textcolor{OrangeRed}{/}}}{1} + {scale=1}{{\textcolor{gray}{scale=1}}}{7} + {\%CleanPST}{{\textcolor{gray}{\%}\textcolor{pkgcolor}{CleanPST}}}{9},% + #1,% + }% close lstset +}% +{}% close examplecode + +% \begin{examplecmd}...\end{examplecmd} +\lstnewenvironment{examplecmd}{% +\lstset{ + language=myscript-doc,% + basicstyle=\ttfamily\small,% + frame=single,% + alsoletter={\-,.,\-\-},% + rulecolor=\color{gray!50},% + framesep=\fboxsep,% + framerule=\fboxrule,% + xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,% + xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,% + keywordstyle=[20]{\color{gray}},% replace this color + keywords=[20]{--margins, -recorder,-shell-escape,-s,-o,-e,-p,-j,--imgdir,% + --luatex,--latexmk,--svg,--png,--nopdf,pics,-no-shell-escape,-interaction,nonstopmode},% +% Reserved words (cmd line options) + deletekeywords=[4]{pst2pdf},% + classoffset=7,% + keywordstyle=\bfseries\color{ForestGreen},% + morekeywords={pst2pdf},% +% % Reserved words (cmd line options) + classoffset=8,% + keywordstyle={\color{ForestGreen}},% + morekeywords={gs,pdftoppm,pdftocairo,pdftops,cd,perl,pdfcrop},% +% Only for command line options + classoffset=5,% + keywordstyle=\color{blue},% + keywords={user,machine},% + literate=*{[}{{\textcolor{darkgray}{[}}}{1} + {]}{{\textcolor{darkgray}{]}}}{1} + {=}{{\textcolor{gray}{=}}}{1} + {@}{{\textcolor{blue}{@}}}{1} + {\$}{{\textcolor{blue}{\$}}}{1} + {:}{{\textcolor{blue}{:}}}{1} + {§}{{\textcolor{red}{\$\space}}}{2} + {~}{{\textcolor{blue}{\bfseries\textasciitilde}}}{1}% + }% close lstset +}% +{}% close examplecmd + +% \lstinline[style=inline]|...| +\lstdefinestyle{inline} + { + language=myscript-doc,% + basicstyle=\ttfamily\color{gray},% + escapechar=`,% + upquote=true,% + deletekeywords=[8]{preview},% + morekeywords =[4]{preview},% + literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1} + {\*}{{\bfseries\textcolor{MediumOrchid}{*}}}{1} + } + +% set default style +\lstset{style=inline} + +\begin{document} + +\title{\texttt{pst2pdf}} +\subtitle{Running a PSTricks document with (pdf/xe/lua)latex;\\ v\fileversion{} --- \filedate\thanks{% + This file describes a documentation for version \fileversion, last revised \filedate.}} +\author{Herbert Voß \\ Pablo Gonz\'{a}lez L} +\date{} + +\maketitle + +\begin{abstract} + +\texttt{pst2pdf} is a \texttt{Perl} \emph{script} which isolates all \texttt{PostScript} or \texttt{PSTricks} related +parts of the \TeX{} document, read all \texttt{postscript}, \texttt{pspicture}, \texttt{psgraph} +and \texttt{PSTexample} environments and, extract source code in \emph{standalone} files and +converting them into image format \texttt{pdf, eps, jpg, svg} or \texttt{png} (default \texttt{pdf}). +Create new file with all extracted environments converted to \Lcs{includegraphics} and runs \texttt{(pdf/Xe/lua)latex}. +\end{abstract} + +\tableofcontents + +\clearpage +\newpage + +\section{Introduction} + +\PST\ as \PS\ related package uses the programming language \PS\ for internal +calculations. This is an important advantage, because floating point arithmetic is no +problem. Nearly all mathematical calculation can be done when running the \DVI-file +with \gs. However, creating a \PDF\ file in a direct way with \Lprog{pdflatex} is +not possible. \Lprog{pdflatex} cannot understand the \PS\ related stuff. + +Instead of running \Lprog{pdflatex} one can use the \emph{script} \Lscript{pst2pdf}, it extracts +all \PST\ related code into single documents with the same preamble as the original +main document. + +The \Lscript{pst2pdf} \emph{script} runs document, extract source code for all \PST\ as \PS\ related parts, clips all whitespace around the +image and creates a \Lext{pdf} images of the \PST\ related code. + +In a last run which is the \Lprog{pdflatex} the \PST\ code in the +main document is replaced by the created images. + +\section{License} + +This program is free software; you can redistribute it and/or modify +it under the terms of the \href{https://www.gnu.org/licenses/gpl-3.0.html}{GNU General Public License} as published by +the \href{https://www.fsf.org/}{Free Software Foundation}; either version 3 of the License, or +(at your option) any later version. + + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \href{https://www.gnu.org/licenses/gpl-3.0.html}{GNU General Public License} +for more details. + +\section{Requirements for operation} + +For the complete operation of \Lscript{pst2pdf}{} you need to have a modern % +\hologo{TeX} distribution such as \hologo{TeX} Live or \hologo{MiKTeX}, the packages \LPack{preview}\cite{preview}, +\LPack{pst-pdf}\cite{pst-pdf}, \LPack{graphicx}\cite{graphicx} and \LPack{grfext}\cite{grfext}, have +a version equal to or greater than \liningnums{5.28} of \Lprog{perl}, a +version equal to or greater than \liningnums{9.24} of \Lprog{Ghostscript}, a +version equal to or greater than \liningnums{1.40} of \Lscript{pdfcrop} +and have a version equal to or greater than \liningnums{0.52} of % +\Lprog{poppler-utils}. + +The distribution of \hologo{TeX} Live 2020 for \Losystem{Windows} includes % +\Lscript{pst2pdf} and all requirements, \hologo{MiKTeX} users must install the +appropriate software for full operation. + +The script auto detects the \Lprog{Ghostscript}, but not \Lprog{poppler-utils}. +You should keep this in mind if you are using the script directly and not +the version provided in your \hologo{TeX} distribution. + +The script has been tested on \Losystem{Windows} (v10) and % +\Losystem{Linux} (fedora 32) using \Lprog{Ghostscript} % +\liningnums{v9.52}, \Lprog{poppler-utils} \liningnums{v0.84}, \Lprog{perl} \liningnums{v5.30} +and the standard classes offers by \hologo{LaTeX}: \LClass{book}, +\LClass{report}, \LClass{article} and \LClass{letter}. + +\section{How it works} +\label{sec:howtowork} + +It is important to have a general idea of how the \emph{\enquote{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{input file}, the \meta{verbatim content} +and the \meta{steps process}. + +\subsection{The input file} +\label{sec:inputfile} + +The \meta{input file} must comply with \emph{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| and after +\lstinline|\end{document}| can go any type of content, internally the script will +\emph{\enquote{split}} the \meta{input file} at this points. + +If the \meta{input file} contains files using \Lcs{input}\marg[type=tt]{file} or +\Lcs{include}\marg[type=tt]{file} 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 \Lscript{latexpand}\footnote{\url{https://www.ctan.org/pkg/latexpand}} +first and then process the file. + +Like \Lcs{input}\marg[type=tt]{file} or \Lcs{include}\marg[type=tt]{file}, 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 \Lprog{chktex}\footnote{\url{https://www.ctan.org/pkg/chktex}} and +\Lscript{latexindent}\footnote{\url{https://www.ctan.org/pkg/latexindent}}, especially if you want to +extract the source code of the environments. + +Both \Lcs{thispagestyle}\marg[type=tt]{style} and \Lcs{pagestyle}\marg[type=tt]{style} +are treated in a special way by the script, if they do not appear in the +preamble then \Lcs{pagestyle}\marg[type=tt]{empty} will be added and if they are present +and \marg[type=tt]{style} is different from \marg[type=tt]{empty} this +will be replaced by \marg[type=tt]{empty}. + +This is necessary for the image creation process, it does not affect the \meta{output file}, but +it does affect the \emph{standalone} files. For the script the process of dividing the \meta{input file} into four +parts and then processing them: + +\begin{examplecode}[numbers=left,frame=single] +% Part One: Everything before \documentclass +\documentclass{article} +% Part two: Everything between \documentclass and \begin{document} +\begin{document} +% Part three: : Everything between \begin{document} and \end{document} +\end{document} +% Part Four: Everything after \end{document} +\end{examplecode} + +If for some reason you have an environment \Lenv{filecontens} before \lstinline|\documentclass| or +in the preamble of the \meta{input file} that contains a \emph{sub-document} or \emph{environment} +you want to extract, the script will ignore them. Similarly, the content after \lstinline|\end{document}| +is ignored in the extraction process. + +\subsection{Verbatim contents} +\label{sec:verbatim} + +One of the greatest capabilities of this script is to \emph{\enquote{skip}} +the complications that \meta{verbatim content} produces with the extraction +of environments using tools outside the \enquote{\hologo{TeX} world}. +In order to \emph{\enquote{skip}} the complications, the \meta{verbatim content} is classified into +three types: + +\begin{itemize}[nosep] + \item Verbatim in line. + \item Verbatim standard. + \item Verbatim write. +\end{itemize} + +\subsubsection{Verbatim in line} +\label{sec:verbatim:inline} + +The small pieces of code written using a \emph{\enquote{verbatim macro}} +are considered \meta{verbatim in line}, such as \lstinline+\verb|+\meta{code}\lstinline+|+ +or \lstinline+\verb*|+\meta{code}\lstinline+|+ or \lstinline+\macro+\marg[type=tt]{code} or +\lstinline+\macro+\oarg[type=tt]{opts}\marg[type=tt]{code}. + +Most \emph{\enquote{verbatim macro}} provide by packages \LPack{minted}, % +\LPack{fancyvrb} and \LPack{listings} have been tested and are fully +supported. They are automatically detected the \emph{verbatim macro} (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) generates by +\Lcs{newmint} and \Lcs{newmintinline} and the following list: + +\vspace*{-10pt} +\begin{multicols}{3} +\begin{itemize}[font=\sffamily\small,partopsep=5pt,parsep=5pt,nosep,leftmargin=*] +\small +\item \Lcs{mint} +\item \Lcs{spverb} +\item \Lcs{qverb} +\item \Lcs{fverb} +\item \Lcs{verb} +\item \Lcs{Verb} +\item \Lcs{lstinline} +\item \Lcs{pyginline} +\item \Lcs{pygment} +\item \Lcs{Scontents} +\item \Lcs{tcboxverb} +\item \Lcs{mintinline} +\end{itemize} +\end{multicols} + +Some packages define abbreviated versions for \emph{\enquote{verbatim macro}} as % +\Lcs{DefineShortVerb}, \Lcs{lstMakeShortInline} and % +\Lcs{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 macros, such as \LPack{shortvrb} or % +\LPack{doc} for example in which there is no explicit \lstinline+\macro+ in the +document by means of which the abbreviated form can be detected, for +automatic detection need to find \Lcs{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 \emph{\enquote{verbatim macro}} is not +supported by default or can not detect, use the options described in \ref% +{sec:optline}. + +\subsubsection{Verbatim standard} +\label{sec:verbatim:std} + +These are the \emph{\enquote{classic}} environments for \emph{\enquote{writing code}} are considered % +\meta{verbatim standard}, such as \Venv{verbatim} and \Venv{lstlisting} +environments. The following list (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) +is considered as \meta{verbatim standard} environments: + +\begin{multicols}{4} +\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] +\small +\item \Venv{Example} +\item \Venv{CenterExample} +\item \Venv{SideBySideExample} +\item \Venv{PCenterExample} +\item \Venv{PSideBySideExample} +\item \Venv{verbatim} +\item \Venv{Verbatim} +\item \Venv{BVerbatim} +\item \Venv{LVerbatim} +\item \Venv{SaveVerbatim} +\item \Venv{PSTcode} +\item \Venv{LTXexample} +\item \Venv{tcblisting} +\item \Venv{spverbatim} +\item \Venv{minted} +\item \Venv{listing} +\item \Venv{lstlisting} +\item \Venv{alltt} +\item \Venv{comment} +\item \Venv{chklisting} +\item \Venv{verbatimtab} +\item \Venv{listingcont} +\item \Venv{boxedverbatim} +\item \Venv{demo} +\item \Venv{sourcecode} +\item \Venv{xcomment} +\item \Venv{pygmented} +\item \Venv{pyglist} +\item \Venv{program} +\item \Venv{programl} +\item \Venv{programL} +\item \Venv{programs} +\item \Venv{programf} +\item \Venv{programsc} +\item \Venv{programt} +\end{itemize} +\end{multicols} + +They are automatically detected \meta{verbatim standard} environments +(including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) +generates by commands: + +\begin{multicols}{2} +\begin{itemize}[font=\sffamily\small,noitemsep,leftmargin=*] +\small +\item \Lcs{DefineVerbatimEnvironment} +\item \Lcs{NewListingEnvironment} +\item \Lcs{DeclareTCBListing} +\item \Lcs{ProvideTCBListing} +\item \Lcs{lstnewenvironment} +\item \Lcs{newtabverbatim} +\item \Lcs{specialcomment} +\item \Lcs{includecomment} +\item \Lcs{newtcblisting} +\item \Lcs{NewTCBListing} +\item \Lcs{newverbatim} +\item \Lcs{NewProgram} +\item \Lcs{newminted} +\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}. + +\subsubsection{Verbatim write} +\label{sec:verbatim:write} + +Some environments have the ability to write \emph{\enquote{external files}} +or \emph{\enquote{store content}} in memory, these environments are +considered \meta{verbatim write}, such as \Wenv{scontents}, \Wenv{filecontents} +or \Lenv{VerbatimOut} environments. The following list is considered (including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) as % +\meta{verbatim write} environments: + +\begin{multicols}{4} +\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] +\ttfamily\small +\item \Wenv{scontents} +\item \Wenv{filecontents} +\item \Wenv{tcboutputlisting} +\item \Wenv{tcbexternal} +\item \Wenv{tcbwritetmp} +\item \Wenv{extcolorbox} +\item \Wenv{extikzpicture} +\item \Wenv{VerbatimOut} +\item \Wenv{verbatimwrite} +\item \Wenv{filecontentsdef} +\item \Wenv{filecontentshere} +\item \Wenv{filecontentsdefmacro} +\item \Wenv{filecontentsdefstarred} +\item \Wenv{filecontentsgdef} +\item \Wenv{filecontentsdefmacro} +\item \Wenv{filecontentsgdefmacro} +\end{itemize} +\end{multicols} + +They are automatically detected \meta{verbatim write} +(including \texttt{\small\bfseries\textcolor{MediumOrchid}{*}} argument) environments generates +by commands: + +\begin{itemize}[font=\sffamily\small, noitemsep,leftmargin=*] +\small +\item \Lcs{renewtcbexternalizetcolorbox} +\item \Lcs{renewtcbexternalizeenvironment} +\item \Lcs{newtcbexternalizeenvironment} +\item \Lcs{newtcbexternalizetcolorbox} +\item \Lcs{newenvsc} +\end{itemize} + +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}. + +\subsection{Steps process} +\label{sec:steps:process} + +For creation of the image formats, extraction of source code of environments and creation of an +\meta{output file}, \Lscript{pst2pdf} need a various steps. Let's assume that the % +\meta{input file} is \LFile{test.tex}, \meta{output file} is % +\LFile{test-pdf.tex}, the working directory are \enquote{\texttt{./}}, the +directory for images are \texttt{./images}, the temporary +directory is \texttt{/tmp} and we want to generate images in \Limgform{pdf} +format and \meta{standalone} files for all environments extracted. + +We will use the following code as \LFile{test.tex}: + +\begin{examplecode}[numbers=left,frame=single] +% Some commented lines at begin file +\documentclass{article} +\usepackage{pstricks} +\begin{document} +Some text +\begin{pspicture} + Some code +\end{pspicture} +Always use \verb|\begin{pspicture}| and \verb|\end{pspicture}| to open +and close environment +\begin{pspicture} + Some code +\end{pspicture} +Some text +\begin{verbatim} +\begin{pspicture} + Some code +\end{pspicture} +\end{verbatim} +Some text +\end{document} +Some lines that will be ignored by the script +\end{examplecode} + +\subsubsection{Validating Options} + +The first step is read and validated \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} from the command +line, verifying that \LFile{test.tex} contains \emph{some} environment to extract, +check the directory \texttt{./images} if it doesn't exist create it and create a temporary directory \texttt{/tmp/hG45uVklv9}. + +The entire \LFile{test.tex} file is loaded into memory and \emph{\enquote{split}} to start the extraction process. + +\subsubsection{Comment and ignore} +In the second step, once the file \LFile{test.tex} is loaded and divided in memory, +proceeds (in general terms) as follows: + +\begin{quotation} +Search the words \lstinline|\begin{| and \lstinline|\end{| in verbatim standard, verbatim write, verbatim in line and +commented lines, if it finds them, converts to \lstinline|\BEGIN{| and \lstinline|\END{|, then places all code to +extract inside the \lstinline|\begin{preview}| \ldots \lstinline|\end{preview}|. +\end{quotation} + +At this point \emph{\enquote{all}} the code you want to extract is inside \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}|. + +\subsubsection{Creating standalone files and extracting} + +In the third step, the script generate \meta{standalone} files: \LFile{test-fig-1.tex}, +\LFile{test-fig-2.tex}, \dots{} and saved in \texttt{./images} then proceed in two ways +according to the \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} +passed to generate a temporary file with a random number (1981 for example): + +\begin{enumerate}[leftmargin=*] +\item If script is call \emph{without} \cmdopt{noprew} options, the following lines +will be added at the beginning of the \LFile{test.tex} (in memory): + +\begin{examplecode} +\PassOptionsToPackage{inactive}{pst-pdf}% +\AtBeginDocument{% +\RequirePackage[inactive]{pst-pdf}% +\RequirePackage[active,tightpage]{preview}% +\renewcommand\PreviewBbAdjust{-60pt -60pt 60pt 60pt}}% +% rest of input file +\end{examplecode} + +The different parts of the file read in memory are joined and save in a temporary +file \LFile{test-fig-1981.tex} in \texttt{./}. This file will contain all the environments +for extraction between \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}| along with the rest of the document. +If the document contains images, these must be in the formats supported by the \emph{engine} selected to process the \meta{input file}. + +\item If script is call \emph{with} \cmdopt{noprew} options, the \lstinline|\begin{preview}|\ldots\lstinline|\end{preview}| +lines are only used as delimiters for extracting the content \emph{without} using the package \LPack{preview}, the following lines +will be added at the beginning of the \LFile{test.tex} (in memory): + +\begin{examplecode} +\PassOptionsToPackage{inactive}{pst-pdf}% +\AtBeginDocument{% +\RequirePackage[inactive]{pst-pdf}}% +% only environments extracted +\end{examplecode} + +Then it is joined with all extracted environments separated by \Lcs{newpage} and saved +in a temporary file \LFile{test-fig-1981.tex} in \enquote{\texttt{./}}. + +\end{enumerate} + +If \cmdopt{norun} is passed, the temporary file \LFile{test-fig-1981.tex} +is renamed to \LFile{test-fig-all.tex} and moved to \texttt{./images}. + +\subsubsection{Generate image formats} + +In the fourth step, the script generating the file \LFile{test-fig-1981.pdf} with all code extracted and croping, running: +\begin{examplecmd} +[user@machine ~:]§ `\small\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler}` -no-shell-escape -interaction=nonstopmode -recorder test-fig-1981.tex +[user@machine ~:]§ pdfcrop --margins `\small\textcolor{gray}{0}` test-fig-1981.pdf test-fig-1981.pdf +\end{examplecmd} + +Now move \LFile{test-fig-1981.pdf} to \texttt{/tmp/hG45uVklv9} and rename to \LFile{test-fig-all.pdf}, generate image files \LFile{test-fig-1.pdf} +and \LFile{test-fig-2.pdf} and copy to \texttt{./images}, if the image files exist, they will be rewritten each time you run the script. The file \LFile{test-fig-1981.tex} is +moved to the \texttt{./images} and rename to \LFile{test-fig-all.tex}. + +Note the options passed to \meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} always use \prgopt*{no-shell-escape} +and \prgopt*{recorder}, to generate the \Lext{fls} file which is used to delete temporary files and directories after +the process is completed. The \cmdopt{shell} option activates \prgopt*{shell-escape} for compatibility with packages +such as \LPack{minted} or others. + +\subsubsection{Create output file} + +In the fifth step, the script creates the output file \LFile{test-pdf.tex} converting all extracted code to +\Lcs{includegraphics}, remove all \PST{} packages and content betwen \lstinline|%CleanPST ... %CleanPST|, then +adding the following lines at end of preamble: + +\begin{examplecode}[numbers=left] +\usepackage{graphicx} +\graphicspath{{images/}} +\usepackage{grfext} +\PrependGraphicsExtensions*{.pdf} +\end{examplecode} + +The script will try to detect whether the \LPack{graphicx} package and +the \Lcs{graphicspath} command are in the preamble of the \meta[cf=optcolor]{output file}. +If it is not possible to find it, it will read the \Lext{log} file generated by the temporary file. +Once the detection is complete, the package \LPack{grfext} and \Lcs{PrependGraphicsExtensions*} +will be added at the end of the preamble, then proceed to run: + +\begin{examplecmd} +[user@machine ~:]§ `\small\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler}` -recorder -shell-escape test-pdf.tex +\end{examplecmd} +generating the file \LFile{test-pdf.pdf}. + +\subsubsection{Clean temporary files and dirs} + +In the sixth step, the script read the files \LFile{test-fig-1981.fls} +and \LFile{test-out.fls}, extract the information from the +temporary files and dirs generated in the process in \enquote{\texttt{./}} and then +delete them together with the directory \texttt{/tmp/hG45uVklv9}. + +Finally the output file \texttt{test-pdf.tex} looks like this: + +\begin{examplecode}[numbers=left] +% some commented lines at begin document +\documentclass{article} +\usepackage{graphicx} +\graphicspath{{images/}} +\usepackage{grfext} +\PrependGraphicsExtensions*{.pdf} +\begin{document} +Some text +\includegraphics[scale=1]{test-fig-1} +Always use \verb|\begin{pspicture}| and \verb|\end{pspicture}| to open +and close environment +\includegraphics[scale=1]{test-fig-2} +Some text +\begin{verbatim} +\begin{pspicture} + Some code +\end{pspicture} +\end{verbatim} +Some text +\end{document} +\end{examplecode} + +\section{Default extracted environments} +\label{sec:extract:env} + +\nxLprog{pst2pdf} support fourth environments for extraction. Internally +the script converts all environments to extract in \Lenv{preview} environments. +Is better comment this package in preamble unless the option \cmdopt{noprew} is used. + +\DescribeTE{postscript} +Environment provide by \LPack{pst-pdf}\cite{pst-pdf}, \LPack{auto-pst-pdf}\cite{auto-pst-pdf} +and \LPack{auto-pst-pdf-lua}\cite{auto-pst-pdf-lua} packages. Since the \LPack{pst-pdf}, \LPack{auto-pst-pdf} +and \LPack{auto-pst-pdf-lua} packages internally use the \LPack{preview} package, is better comment this in preamble. +Only the \emph{content} of this environment is extracted and \emph{\enquote{not}} the environment itself when using the +\cmdopt{srcenv} option. The \Lenv{postscript} environment should always be used, when there is some code before a \Lenv{pspicture} +environment or for some code which is not inside of a \Lenv{pspicture} environment. + +\DescribeTE{pspicture} +Environment provide by \LPack{pstricks}\cite{girou:02:} package. The plain \hologo{TeX} +syntax \lstinline|\pspicture ... \endpspicture| its converted to \hologo{LaTeX} syntax +\lstinline|\begin{pspicture} ... \end{pspicture}| if not within the \Lenv{PSTexample} or \Lenv{postscript} environments. + +\DescribeTE{psgraph} +Environment provide by \LPack{pst-plot}\cite{pst-plot} package. The plain \hologo{TeX} syntax \lstinline|\psgraph ... \endpsgraph| +its converted to \hologo{LaTeX} syntax \lstinline|\begin{psgraph} ... \end{psgraph}| if +not within the \Lenv{PSTexample} or \Lenv{postscript} environments. + +\DescribeTE{PSTexample} +Environment provide by \LPack{pst-exa}\cite{pst-exa} package. The script automatically detects the +\lstinline|\begin{PSTexample}| \lstinline|...\end{PSTexample}| +environments and processes them as separately compiled files. The user should have loaded the +package with [\Loption{swpl}] or [\Loption{tcb}] option. + +\section{Remove \PST\ code} + +By design, the script remove all \PST{} packages in preamble of \meta{output file}, if you need delete other \PST\ code in preamble use: + +\DescribeTE*{CleanPST} +All content betwen \lstinline|%CleanPST ... %CleanPST| are deleted in preamble of the \meta[cf=optcolor]{output file}. +This lines can \emph{not} be nested and should be at the beginning of the line and in separate lines. + +\section{Supported image formats} +\label{sec:image:format} + +The \Larga{image formats} generated by the \Lscript{pst2pdf} using \Lprog{Ghostscript} +and \Lprog{poppler-utils} are the following command lines: + +\DescribeIF{pdf} +The image format generated using \Lprog{Ghostscript}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress +\end{examplecmd} + +\DescribeIF{eps} +The image format generated using \Lprog{pdftoeps}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ pdftops -q -eps +\end{examplecmd} + +\DescribeIF{png} +The image format generated using \Lprog{Ghostscript}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pngalpha -r150 +\end{examplecmd} + +\DescribeIF{jpg} +The image format generated using \Lprog{Ghostscript}. The line executed by the system is: +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=jpeg -r150 -dJPEGQ=100 \ + -dGraphicsAlphaBits=4 -dTextAlphaBits=4 +\end{examplecmd} + +\DescribeIF{ppm} +The image format generated using \Lprog{pdftoppm}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ pdftoppm -q -r 150 +\end{examplecmd} + +\DescribeIF{tiff} +The image format generated using \Lprog{Ghostscript}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=tiff32nc -r150 +\end{examplecmd} + +\DescribeIF{svg} +The image format generated using \Lprog{pdftocairo}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ pdftocairo -q -r 150 +\end{examplecmd} + +\DescribeIF{bmp} +The image format generated using \Lprog{Ghostscript}. The line executed by the system is: + +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=bmp32b -r150 +\end{examplecmd} + +\section{How to use} + +\subsection{Syntax} + +The syntax for \myscript\ is simple, if your use the version provided in your \hologo{TeX} distribution: + +\begin{examplecmd} +[user@machine ~:]§ pst2pdf `\small\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} \meta[cf=optcolor]{input file}` +\end{examplecmd} +or +\begin{examplecmd} +[user@machine ~:]§ pst2pdf `\small\meta[cf=optcolor]{input file} \oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options}` +\end{examplecmd} +If the development version is used: +\begin{examplecmd} +[user@machine ~:]§ perl pst2pdf `\small\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} \meta[cf=optcolor]{input file}` +\end{examplecmd} + +The extension valid for \meta[cf=optcolor]{input file} are \Lext{tex} or \Lext{ltx}, +relative or absolute paths for files and directories is not supported. If used without +\oarg[type=tt,cf=optcolor,sbc=gray,ac=lightgray]{options} the extracted environments are converted to \Limgform{pdf} +image format and saved in the \texttt{./images} directory using \Lprog{latex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} +and \LPack{preview} package for process \meta[cf=optcolor]{input file} and \Lprog{pdflatex} for compiler \meta[cf=optcolor]{output file}. + +\subsection{Command line interface} +\label{sec:optline} + +The script provides a \emph{command line interface} with short \textcolor{optcolor}{\bfseries\texttt{-}} +and long \textcolor{optcolor}{\bfseries\texttt{--}} option, they may be given before +the name of the \meta[cf=optcolor]{input file}, the order of specifying the options is not significant. +Options that accept a \meta{value} require either a blank space \verb*| | or \textcolor{optcolor}{\bfseries\texttt{=}} +between the option and the \meta{value}. Some short options can be bundling. + +\DescribeCmd[h]{help}{bolean}{off} +Display a command line help and exit. + +\DescribeCmd[l]{log}{bolean}{off} +Write a \LFile{pst2pdf.log} file with all process information. + +\DescribeCmd[v]{version}{bolean}{off} +Display the current version (\fileversion) and exit. + +\DescribeCmd[V]{verbose}{bolean}{off} +Show verbose information of process in terminal. + +\DescribeCmd[d]{dpi}{integer}{150} +Dots per inch for images files. Values are positive integers less than or equal to 2500. + +\DescribeCmd[t]{tif}{bolean}{off} +Create a \Lext{tif} images files using \Lprog{Ghostscript}. + +\DescribeCmd[b]{bmp}{bolean}{off} +Create a \Lext{bmp} images files using \Lprog{Ghostscript}. + +\DescribeCmd[j]{jpg}{bolean}{off} +Create a \Lext{jpg} images files using \Lprog{Ghostscript}. + +\DescribeCmd[p]{png}{bolean}{off} +Create a \Lext{png} transparent image files using \Lprog{Ghostscript}. + +\DescribeCmd[e]{eps}{bolean}{off} +Create a \Lext{eps} image files using \Lprog{pdftops}. + +\DescribeCmd[s]{svg}{bolean}{off} +Create a \Lext{svg} image files using \Lprog{pdftocairo}. + +\DescribeCmd[P]{ppm}{bolean}{off} +Create a \Lext{ppm} image files using \Lprog{pdftoppm}. + +\DescribeCmd[g]{gray}{bolean}{off} +Create a gray scale for all images using \Lprog{Ghostscript}. The line behind this options is: + +\begin{examplecmd} +[user@machine ~:]§ gs -q -dNOSAFER -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress \ + -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray +\end{examplecmd} + +\DescribeCmd[f]{force}{bolean}{off} +Try to capture \lstinline|\psset|\marg[type=tt]{code} to extract. +When using the \cmdopt{force} option the script will try to capture \lstinline|\psset|\marg[type=tt]{code} and +leave it inside the \Lenv{preview} environment, any line that is between \lstinline|\psset|\marg[type=tt]{code} and +\lstinline|\begin{pspicture}| will be captured. + +\DescribeCmd[np]{noprew}{bolean}{off} +Create images files without \LPack{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 \LPack{preview}. +Using this option \emph{\enquote{only}} the extracted environments are processed and not the whole \meta[cf=optcolor]{input file}, sometimes +it is better to use it together with \cmdopt{force}. Alternative name \cmdopt{single}. + +\DescribeCmd[m]{margins}{integer}{0} +Set margins in bp for \Lscript{pdfcrop}. + +\DescribeCmd[r]{runs}{\textnormal{\ttfamily 1\textbar 2\textbar 3}}{1} +Set the number of times the \meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} will run +on the \meta[cf=optcolor]{input file} for environment extraction. + +\DescribeCmd{myverb}{macro name}{myverb} +Set custom verbatim command \lstinline+\myverb+. Just pass the \meta{macro name}{} +\emph{without} \enquote{\textcolor{optcolor}{\texttt{\bfseries\textbackslash}}}. + +\DescribeCmd{ignore}{environment name}{empty} +Add a verbatim environment to internal list. + +\DescribeCmd{imgdir}{string}{images} +Set the name of directory for save generated files. Only the \meta{name} of directory +must be passed \emph{without} relative or absolute paths. + +\DescribeCmd{srcenv}{bolean}{off} +Create separate files with \emph{\enquote{only code}} for all extracted +environments. + +\DescribeCmd{shell}{bolean}{off} +Enable \Lcs{write18}\meta{shell command}. + +\DescribeCmd[ni]{norun}{bolean}{off} +Execute the script, but do not create image files. This option is designed to +to generate standalone files or used in conjunction with \cmdopt{srcenv} and to +debug the \meta[cf=optcolor]{output file}. Alternative name \cmdopt{noimages}. + +\DescribeCmd{nopdf}{bolean}{off} +Don't create a \Lext{pdf} image files. + +\DescribeCmd{nocrop}{bolean}{off} +Don't run \Lscript{pdfcrop} in image files. + +\DescribeCmd[ns]{nosource}{bolean}{off} +Don't create standalone files. + +\DescribeCmd[x]{xetex}{bolean}{off} +Using \Lprog{xelatex} compiler \meta[cf=optcolor]{input file} and \meta[cf=optcolor]{output file}. + +\DescribeCmd{luatex}{bolean}{off} +Using \Lprog{dvilualatex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} +for compiler \meta[cf=optcolor]{input file} and \Lprog{lualatex} for \meta[cf=optcolor]{output file}. + +\DescribeCmd{arara}{bolean}{off} +Use \Lprog{arara}\footnote{\url{https://ctan.org/pkg/arara}} tool for compiler \meta[cf=optcolor]{output file}. +This option is designed to full process \meta[cf=optcolor]{output file}, is mutually +exclusive with \cmdopt{latexmk} option. + +\DescribeCmd{latexmk}{bolean}{off} +Using \Lscript{latexmk}\footnote{\url{https://www.ctan.org/pkg/latexmk}} for process \meta[cf=optcolor]{output file}. +This option is designed to full process \meta[cf=optcolor]{output file}, is mutually exclusive with \cmdopt{arara}. + +\DescribeCmd{zip}{bolean}{off} +Compress the files generated by the script in \texttt{./images} in \Lext{zip} format. +Does not include \meta[cf=optcolor]{output file}. + +\DescribeCmd{tar}{bolean}{off} +Compress the files generated by the script in \texttt{./images} in \Lext{tar.gz} format. +Does not include \meta[cf=optcolor]{output file}. + +\DescribeCmd{bibtex}{bolean}{off} +Run \Lprog{bibtex} on the \Lext{aux} file (if exists), is mutually +exclusive with \cmdopt{biber} option. + +\DescribeCmd{biber}{bolean}{off} +Run \Lprog{biber} on the \Lext{bcf} file (if exists), is mutually +exclusive with \cmdopt{bibtex} option. + +\subsection{Example of usage} + +An example of usage from command line: + +\begin{examplecmd} +[user@machine ~:]§ pst2pdf --luatex -e -p -j --imgdir pics test.ltx +\end{examplecmd} + +Create a \texttt{./pics} directory (if it does not exist) with all extracted environments converted to image +formats (\Lext{pdf}, \Lext{eps}, \Lext{png}, \Lext{jpg}) in individual files, an stanalone files (\Lext{ltx}) for all environments extracted, +an output file \LFile{test-pdf.ltx} with all extracted environments converted to \Lcs{includegraphics} and a single file +\LFile{test-fig-all.ltx} with only the extracted environments +using \Lprog{dvilualatex}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lprog{dvips}\textcolor{optcolor}{\texttt{\bfseries\guillemotright}}\Lscript{ps2pdf} +and \LPack{preview} package for for process \LFile{test.ltx} and +\Lprog{lualatex} for \LFile{test-pdf.ltx}. + +\section{Working in another way} + +By design, the script generates separate images and files following a predetermined +routine that has already been described in this documentation. Another way to generate +images is as follows: + +\begin{enumerate}[font=\small, nosep, noitemsep,leftmargin=*] +\item Execute the script using \cmdopt{norun} to generate \meta{standalone} files, move to \texttt{./images} +and generate \Lext{pdf} files runing: + +\begin{examplecmd} +[user@machine~:]§for i in *.tex; do `\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} \oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` $i; done +[user@machine~:]§for i in *.pdf; do pdfcrop `\small\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` $i $i; done +\end{examplecmd} + +\item Execute the script using \cmdopt{norun}, move to \texttt{./images} \Lext{pdf} file runing: + +\begin{examplecmd} +[user@machine~:]§`\meta[type=tt,cf=ForestGreen,ac=lightgray]{compiler} \oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test-fig-all.tex +[user@machine~:]§pdfcrop `\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test-fig-all.pdf +\end{examplecmd} + +\end{enumerate} + +\section{Example files} + +The \texttt{pst2pdf} documentation provides three example files \LFile{test1.tex}, \LFile{test2.tex} +and \LFile{test3.tex} plus an image file \LFile{tux.jpg} to test and view the script in action. +Copy these files to a directory you have write access to and execute: + +\begin{examplecmd} +[user@machine~:]§pst2pdf `\oarg[type=tt,cf=gray,sbc=optcolor,ac=gray]{options}` test1.tex +\end{examplecmd} + +To see how this works. +%\newpage +\clearpage +\nocite{*} +\printbibliography + +\printindex + +\end{document} diff --git a/Master/texmf-dist/doc/support/pst2pdf/test1-pdf.pdf b/Master/texmf-dist/doc/support/pst2pdf/test1-pdf.pdf new file mode 100644 index 00000000000..e8bc6d3ef4f Binary files /dev/null and b/Master/texmf-dist/doc/support/pst2pdf/test1-pdf.pdf differ diff --git a/Master/texmf-dist/doc/support/pst2pdf/test1.tex b/Master/texmf-dist/doc/support/pst2pdf/test1.tex new file mode 100644 index 00000000000..9d52356ba09 --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/test1.tex @@ -0,0 +1,69 @@ +\documentclass[12pt,english]{article} +\usepackage[T1]{fontenc} +\usepackage{pstricks} +\usepackage{pst-node} +\usepackage{pst-3dplot} +\usepackage{pst-calendar} +\usepackage{blindtext} +\usepackage{babel} +\usepackage{microtype}% for the last pdflatex run +\begin{document} + +foo\begin{pspicture}[showgrid=true](4,2)\psscaleboxto(8,2){foo}\end{pspicture}bar + +\begin{pspicture}[showgrid=true](4,2) + \psscaleboxto(8,2){foo bar} +\end{pspicture} + +\blindtext + +foo\begin{pspicture}[showgrid=true](4,2) + \psscaleboxto(8,2){foo bar baz} +\end{pspicture}bar + +\blindtext + + +\begin{postscript} +\psscalebox{0.5}{% +\psCalDodecaeder[style=january,unit=0.75,Year=2010]} +\end{postscript} + +\includegraphics{tux.jpg}% a jpg image + +\blindtext + +\begin{postscript}\rnode{foo}{foo} bar baz + +foo bar baz foo bar \rnode{baz}{baz} foo bar baz +\ncarc[linecolor=red]{<->}{foo}{baz}\end{postscript} + +\blindtext + +\begin{postscript} +\psframebox{% +\begin{pspicture}(-3,-2)(3,6.5) +\pstThreeDCoor[zMax=7] +\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} +\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) +\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) +\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) +\end{pspicture} +} +\end{postscript} + +\blindtext + +\blindtext + +\begin{postscript} +\begin{pspicture*}(-4,-2)(3,6.5) +\pstThreeDCoor[zMax=7] +\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} +\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) +\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) +\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) +\end{pspicture*} +\end{postscript} + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/doc/support/pst2pdf/test2-pdf.pdf b/Master/texmf-dist/doc/support/pst2pdf/test2-pdf.pdf new file mode 100644 index 00000000000..93a0b12ae6a Binary files /dev/null and b/Master/texmf-dist/doc/support/pst2pdf/test2-pdf.pdf differ diff --git a/Master/texmf-dist/doc/support/pst2pdf/test2.tex b/Master/texmf-dist/doc/support/pst2pdf/test2.tex new file mode 100644 index 00000000000..42babf4234c --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/test2.tex @@ -0,0 +1,66 @@ +\documentclass[12pt,english]{article} +\usepackage[T1]{fontenc} +\usepackage{pstricks} +\usepackage{pst-node} +\usepackage{pst-3dplot} +\usepackage{pst-calendar} +\usepackage{blindtext} +\usepackage{babel} +\usepackage{microtype}% for the last pdflatex run +\begin{document} + +foo\begin{pspicture}[showgrid=true](4,2)\psscaleboxto(8,2){foo}\end{pspicture}bar + +\begin{pspicture}[showgrid=true](4,2) + \psscaleboxto(4,2){foo bar} +\end{pspicture} + + +foo\begin{pspicture}[showgrid=true](4,2) + \psscaleboxto(8,2){foo bar baz} +\end{pspicture}bar + + + +\begin{postscript} +\psscalebox{0.5}{% +\psCalDodecaeder[style=january,unit=0.75,Year=2020]} +\end{postscript} + +\includegraphics{tux.jpg}% a jpg image + + +foo bar baz foo bar baz + +\begin{postscript}\rnode{foo}{foo} bar baz + +foo bar baz foo bar \rnode{baz}{baz} foo bar baz +\ncarc[linecolor=red]{<->}{foo}{baz}\end{postscript} + +foo bar baz + +\begin{postscript} +\psframebox{% +\begin{pspicture}(-3,-2)(3,6.5) +\pstThreeDCoor[zMax=7] +\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} +\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) +\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) +\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) +\end{pspicture} +} +\end{postscript} + + +\begin{postscript} +\begin{pspicture*}(-4,-2)(3,6.5) +\pstThreeDCoor[zMax=7] +\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} +\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) +\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) +\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) +\end{pspicture*} +\end{postscript} + + +\end{document} diff --git a/Master/texmf-dist/doc/support/pst2pdf/test3-pdf.pdf b/Master/texmf-dist/doc/support/pst2pdf/test3-pdf.pdf new file mode 100644 index 00000000000..ac794dad4f7 Binary files /dev/null and b/Master/texmf-dist/doc/support/pst2pdf/test3-pdf.pdf differ diff --git a/Master/texmf-dist/doc/support/pst2pdf/test3.tex b/Master/texmf-dist/doc/support/pst2pdf/test3.tex new file mode 100644 index 00000000000..7703cf05364 --- /dev/null +++ b/Master/texmf-dist/doc/support/pst2pdf/test3.tex @@ -0,0 +1,27 @@ +\documentclass{article} +\usepackage{graphicx,pst-3dplot} +\pagestyle{empty} +\parindent=0pt +\begin{document} + +foo +\begin{postscript} +\psframebox{% begin box +\pspicture(-3,-2)(3,6.5) +\pstThreeDCoor[zMax=7] +\pstIIIDCylinder[RotY=30,fillstyle=solid,fillcolor=red!20,linecolor=black!60](0,0,0){2}{5} +\pstThreeDLine[linecolor=red]{->}(0,0,5)(0,0,7) +\pstThreeDLine[linecolor=red]{->}(-1,0,0)(4,0,0) +\pstThreeDLine[linecolor=red]{->}(0,-1,0)(0,4,0) +\endpspicture}% end box +\end{postscript} + +bar + +\pspicture(3,3) +\psframe[fillstyle=solid,fillcolor=red!30](3,3) +\endpspicture + +\includegraphics{tux.jpg} +% Ende +\end{document} diff --git a/Master/texmf-dist/doc/support/pst2pdf/tux.jpg b/Master/texmf-dist/doc/support/pst2pdf/tux.jpg new file mode 100644 index 00000000000..275f977a3aa Binary files /dev/null and b/Master/texmf-dist/doc/support/pst2pdf/tux.jpg differ diff --git a/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl b/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl index 3b33bdbf91c..a0cf34c638c 100755 --- a/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl +++ b/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl @@ -2,8 +2,7 @@ use v5.26; ############################# LICENCE ################################## -# $Id: pst2pdf.pl 119 2014-09-24 12:04:09Z herbert $ # -# v0.19 2020-08-16 simplify the use of PSTricks with pdf # +# v0.20 2020-08-24 simplify the use of PSTricks with pdf # # (c) Herbert Voss # # Pablo González L # # # @@ -51,7 +50,6 @@ my $norun = 0; # 1->no create images my $noprew = 0; # 1->create images in nopreview mode my $runbibtex = 0; # 1->runs bibtex my $runbiber = 0; # 1->runs biber and sets $runbibtex=0 -my $all = 0; # 1->create all images and files for type my $xetex = 0; # 1->Using (Xe)LaTeX for compilation. my $luatex = 0; # 1->Using dvilualatex for compilation. my $latexmk = 0; # 1->Using latexmk for compiler output file. @@ -81,9 +79,9 @@ my %opts_cmd; # hash to store options for Getopt::Long and log ### Script identification my $scriptname = 'pst2pdf'; -my $nv = 'v0.19'; -my $date = '2020-08-17'; -my $ident = '$Id: pst2pdf.pl 119 2020-08-16 12:04:09Z herbert $'; +my $nv = 'v0.20'; +my $date = '2020-08-22'; +my $ident = '$Id: pst2pdf.pl 119 2020-08-22 12:04:09Z herbert $'; ### Log vars my $LogFile = "$scriptname.log"; @@ -347,7 +345,7 @@ my $result=GetOptions ( 'imgdir=s' => \$imgdir, # string 'myverb=s' => \$myverb, # string 'ignore=s' => \$tmpverbenv, # string - 'c|clear' => \$clear, # flag + 'c|clear' => \$clear, # flag (unused) 'ni|norun|noimages' => \$norun, # flag 'np|noprew|single' => \$noprew, # flag 'bibtex' => \$runbibtex,# flag @@ -368,7 +366,6 @@ my $result=GetOptions ( 's|svg' => \$opts_cmd{image}{svg}, # pdftocairo 'e|eps' => \$opts_cmd{image}{eps}, # pdftops 'P|ppm' => \$opts_cmd{image}{ppm}, # pdftoppm - 'a|all' => \$all, # flag 'x|xetex' => \$xetex, # flag 'luatex' => \$luatex, # flag 'ns|nosource' => \$nosource, # flag @@ -1153,14 +1150,15 @@ if (@env_preview) { ### Pass verbatim write environments to dtxtag Log("Pass verbatim write environments to %<*$dtxverb> ... %"); -$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| - ($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| + ($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$atbegindoc =~ s/($verb_wrt)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; ### Pass verbatim environments to dtxtag Log("Pass verbatim environments to %<*$dtxverb> ... %"); -$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| - \%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - ($verb_std)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; +$document =~ s/\\begin\{nopreview\}.+?\\end\{nopreview\}(*SKIP)(*F)| + \%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ($verb_std)/\%<\*$dtxverb>$1\%<\/$dtxverb>/gmsx; ### Pass %CleanPST to dtxtag Log("Pass %CleanPST ... %CleanPST to %<*remove$tmp> ... %"); @@ -1409,9 +1407,7 @@ if (!$norun) { } ### Set -q for system command line (gs, poppler-utils, dvips) -my $quiet = $verbose ? q{} - : '-q' - ; +my $quiet = $verbose ? q{} : '-q'; ### Set options for ghostscript my %opt_gs_dev = ( @@ -1590,6 +1586,7 @@ $preamout =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; ### Remove %<*$dtxverb> ... % in tmpbodydoc and preamout $tmpbodydoc =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; $preamout =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; +$atbeginout =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; ### Adjust nopreview environments $tmpbodydoc =~ s/\\begin\{nopreview\}\%$tmp @@ -1848,45 +1845,6 @@ if (!$norun) { ### Constant my $findgraphicx = 'true'; -### Suport for pst-exa package -my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x; -my @pst_exa; -my %pst_exa; - -### Possible packages that load graphicx -my @pkgcandidates = qw ( - rotating epsfig lyluatex xunicode parsa xepersian-hm gregoriotex teixmlslides - teixml fotex hvfloat pgfplots grfpaste gmbase hep-paper postage schulealt - schule utfsym cachepic abc doclicense rotating epsfig semtrans mgltex - graphviz revquantum mpostinl cmpj cmpj2 cmpj3 chemschemex register papercdcase - flipbook wallpaper asyprocess draftwatermark rutitlepage dccpaper-base - nbwp-manual mandi fmp toptesi isorot pinlabel cmll graphicx-psmin ptmxcomp - countriesofeurope iodhbwm-templates fgruler combinedgraphics pax pdfpagediff - psfragx epsdice perfectcut upmethodology-fmt ftc-notebook tabvar vtable - teubner pas-cv gcard table-fct pdfpages keyfloat pdfscreen showexpl simplecd - ifmslide grffile reflectgraphics markdown bclogo tikz-page pst-uml realboxes - musikui csbulobalka lwarp mathtools sympytex mpgraphics miniplot.sty:77 - dottex pdftricks2 feupphdteses tex4ebook axodraw2 hagenberg-thesis dlfltxb - hu-berlin-bundle draftfigure quicktype endofproofwd euflag othelloboard - pdftricks unswcover breqn pdfswitch latex-make figlatex repltext etsvthor - cyber xcookybooky xfrac mercatormap chs-physics-report tikzscale ditaa - pst-poker gmp CJKvert asypictureb hletter tikz-network powerdot-fuberlin - skeyval gnuplottex plantslabels fancytooltips ieeepes pst-vectorian - phfnote overpic xtuformat stubs graphbox ucs pdfwin metalogo mwe - inline-images asymptote UNAMThesis authorarchive amscdx pst-pdf adjustbox - trimclip fixmetodonotes incgraph scanpages pst-layout alertmessage - svg quiz2socrative realhats autopdf egplot decorule figsize tikzexternal - pgfcore frontespizio textglos graphicx tikz tcolorbox pst-exa - ); - -my $pkgcandidates = join q{|}, map { quotemeta } sort { length $a <=> length $b } @pkgcandidates; -$pkgcandidates = qr/$pkgcandidates/x; -my @graphicxpkg; - -### \graphicspath -my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix; -my @graphicspath; - ### Replacing the extracted environments with \includegraphics Log("Convert pstricks extracted environments to \\includegraphics for $name-pdf$ext"); my $grap = "\\includegraphics[scale=1]{$name-fig-"; @@ -1900,49 +1858,84 @@ $preamble = "$atbegindoc$preamble"; ### Remove content in preamble my @tag_remove_preamble = $preamble =~ m/(?:^\%<\*remove$tmp>.+?\%<\/remove$tmp>)/gmsx; if (@tag_remove_preamble) { - Log("Removing the content between <*remove> ... tags in preamble for $name-pdf$ext"); + Log("Removing the content between %CleanPST ... %CleanPST in preamble for $name-pdf$ext"); $preamble =~ s/^\%<\*remove$tmp>\s*(.+?)\s*\%<\/remove$tmp>(?:[\t ]*(?:\r?\n|\r))?+//gmsx; } -### To be sure that the package is in the main document and not in a -### verbatim write environment we make the changes using the hash and -### range operator in a copy -my %tmpreplace = ( - 'graphicx' => 'TMPGRAPHICXTMP', - 'pst-exa' => 'TMPPSTEXATMP', - 'graphicspath' => 'TMPGRAPHICSPATHTMP', -); - -my $findtmp = join q{|}, map { quotemeta } sort { length $a <=> length $b } keys %tmpreplace; -my $preambletmp = $preamble; -my @lineas = split /\n/, $preambletmp; +### Suport for pst-exa package +my $pstexa = qr/(?:\\ usepackage) \[\s*(.+?)\s*\] (?:\{\s*(pst-exa)\s*\} ) /x; +my @pst_exa; +my %pst_exa; -### We remove the commented lines -s/\%.*(?:[\t ]*(?:\r?\n|\r))?+//msg foreach @lineas; +### Search pst-exa package +@pst_exa = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$pstexa/gmsx; +%pst_exa = map { $_ => 1 } @pst_exa; -### We make the changes in the environments verbatim write -my $DEL; -for (@lineas) { - if (/\\begin\{($verbatim_w\*?)(?{ $DEL = "\Q$^N" })\}/ .. /\\end\{$DEL\}/) { - s/($findtmp)/$tmpreplace{$1}/g; +### If found comment and adjust path for graphic files +if (@pst_exa) { + Log("Comment pst-exa package in preamble for $name-pdf$ext"); + $findgraphicx = 'false'; + $preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + (\\usepackage\[)\s*(swpl|tcb)\s*(\]\{pst-exa\})/\%$1$2,pdf$3/msxg; + # Change for [tcb] option (path for graphic files) + if (exists $pst_exa{tcb}) { + Log("Suport for \\usepackage[tcb,pdf]\{pst-exa\} for $name-pdf$ext"); + $bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imgdir\/$name-fig-exa-\d*)\}/$1$2\}\{$3\}/gsmx; } } -### Join lines in $preambletmp -$preambletmp = join "\n", @lineas; +### Regex for remove (pst-?) packages in preamble +$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add | -pdf )? | psfrag |psgo |vaucanson-g| auto-pst-pdf(?: -lua )? )/x; +$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x; + +Log("Remove pstricks packages in preamble for $name-pdf$ext [no pst-exa]"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg; +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + (?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx; + +### Uncomment pst-exa package +if (@pst_exa) { + Log("Uncomment pst-exa package in preamble for $name-pdf$ext"); + $preamble =~ s/(?:\%)(\\usepackage\[\s*)(swpl|tcb)(,pdf\s*\]\{pst-exa\})/$1$2$3/msxg; +} + +Log("Remove \\psset\{...\} in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx; + +Log("Remove \\SpecialCoor in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx; -### We removed the blank lines -$preambletmp =~ s/^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; +Log("Remove empty lines in preamble for $name-pdf$ext"); +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; +$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| + ^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; -### Now we're trying to capture -@graphicxpkg = $preambletmp =~ m/($pkgcandidates)/gmsx; -if (@graphicxpkg) { - Log("Found graphicx package in preamble for $name-pdf$ext"); - $findgraphicx = 'false'; +### To be sure that the package graphicx and \graphicspath is in the main +### document and not in a verbatim write environment we make the changes +my %tmpreplace = ( + 'graphicx' => 'TMPGRAPHICXTMP', + 'graphicspath' => 'TMPGRAPHICSPATHTMP', +); +my $findtmp = join q{|}, map { quotemeta } sort { length $a <=> length $b } keys %tmpreplace; + +### We go line by line and make the changes [need /p for ${^MATCH}] +while ($preamble =~ /\%<\*$dtxverb>(.+?)\%<\/$dtxverb> | $tmpcomment /pgmsx) { + my ($pos_inicial, $pos_final) = ($-[0], $+[0]); + my $encontrado = ${^MATCH}; + $encontrado =~ s/($findtmp)/$tmpreplace{$1}/g; + substr $preamble, $pos_inicial, $pos_final-$pos_inicial, $encontrado; + pos ($preamble) = $pos_inicial + length $encontrado; } -### Search graphicspath -@graphicspath = $preambletmp =~ m/graphicspath/msx; +### Now we're trying to capture \graphicspath{...} +my $graphicspath= qr/\\ graphicspath \{ ((?: $llaves )+) \}/ix; +my @graphicspath; +@graphicspath = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|($graphicspath)/gmsx; + if (@graphicspath) { Log("Found \\graphicspath in preamble for $name-pdf$ext"); $findgraphicx = 'false'; @@ -1961,19 +1954,53 @@ if (@graphicspath) { } } -### Search pst-exa -@pst_exa = $preambletmp =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$pstexa/xg; -%pst_exa = map { $_ => 1 } @pst_exa; -if (@pst_exa) { - Log("Comment pst-exa package in preamble for $name-pdf$ext"); +### Possible packages that load graphicx +my @pkgcandidates = qw ( + rotating epsfig lyluatex xunicode parsa xepersian-hm gregoriotex teixmlslides + teixml fotex hvfloat pgfplots grfpaste gmbase hep-paper postage schulealt + schule utfsym cachepic abc doclicense rotating epsfig semtrans mgltex + graphviz revquantum mpostinl cmpj cmpj2 cmpj3 chemschemex register papercdcase + flipbook wallpaper asyprocess draftwatermark rutitlepage dccpaper-base + nbwp-manual mandi fmp toptesi isorot pinlabel cmll graphicx-psmin ptmxcomp + countriesofeurope iodhbwm-templates fgruler combinedgraphics pax pdfpagediff + psfragx epsdice perfectcut upmethodology-fmt ftc-notebook tabvar vtable + teubner pas-cv gcard table-fct pdfpages keyfloat pdfscreen showexpl simplecd + ifmslide grffile reflectgraphics markdown bclogo tikz-page pst-uml realboxes + musikui csbulobalka lwarp mathtools sympytex mpgraphics miniplot.sty:77 + dottex pdftricks2 feupphdteses tex4ebook axodraw2 hagenberg-thesis dlfltxb + hu-berlin-bundle draftfigure quicktype endofproofwd euflag othelloboard + pdftricks unswcover breqn pdfswitch latex-make figlatex repltext etsvthor + cyber xcookybooky xfrac mercatormap chs-physics-report tikzscale ditaa + pst-poker gmp CJKvert asypictureb hletter tikz-network powerdot-fuberlin + skeyval gnuplottex plantslabels fancytooltips ieeepes pst-vectorian + phfnote overpic xtuformat stubs graphbox ucs pdfwin metalogo mwe + inline-images asymptote UNAMThesis authorarchive amscdx adjustbox + trimclip fixmetodonotes incgraph scanpages alertmessage + svg quiz2socrative realhats autopdf egplot decorule figsize tikzexternal + pgfcore frontespizio textglos graphicx tikz tcolorbox + ); + +my $pkgcandidates = join q{|}, map { quotemeta } sort { length $a <=> length $b } @pkgcandidates; +$pkgcandidates = qr/$pkgcandidates/x; +my @graphicxpkg; + +### Now we're trying to capture graphicx package +@graphicxpkg = $preamble =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|($pkgcandidates)/gmsx; + +if (@graphicxpkg and $findgraphicx ne 'false') { + Log("Found graphicx package in preamble for $name-pdf$ext"); $findgraphicx = 'false'; - $preamble =~ s/(\\usepackage\[)\s*(swpl|tcb)\s*(\]\{pst-exa\})/\%$1$2,pdf$3/msxg; -} -if (exists $pst_exa{tcb}) { - Log("Suport for \\usepackage[tcb,pdf]\{pst-exa\} for $name-pdf$ext"); - $bodydoc =~ s/(graphic=\{)\[(scale=\d*)\]($imgdir\/$name-fig-exa-\d*)\}/$1$2\}\{$3\}/gsmx; } +### Revert changes in preamble for temp +my %tmpoutreplace = ( + 'TMPGRAPHICXTMP' => 'graphicx', + 'TMPGRAPHICSPATHTMP' => 'graphicspath', +); + +%replace = (%changes_out,%tmpoutreplace); +$find = join q{|}, map {quotemeta} sort { length $a <=> length $b } keys %replace; + ### Try to capture arara:compiler in preamble of my @arara_engines = qw (latex pdflatex lualatex xelatex luahbtex); my $arara_engines = join q{|}, map { quotemeta} sort { length $a <=> length $b } @arara_engines; @@ -1981,28 +2008,36 @@ $arara_engines = qr/\b(?:$arara_engines)/x; my $arara_rule = qr /^(?:\%\s{1}arara[:]\s{1}) ($arara_engines) /msx; ### Capture graphicx.sty in .log of LaTeX file -if ($findgraphicx eq 'true') { +if ($findgraphicx ne 'false') { Log("Couldn't capture the graphicx package for $name-pdf$ext in preamble"); my $ltxlog; my @graphicx; my $null = devnull(); + # Copy preamble and revert changes + my $preambletmp = $preamble; + $preambletmp =~ s/($find)/$replace{$1}/g; + $preambletmp =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; Log("Creating $name-fig-$tmp$ext [only preamble]"); if ($verbose) { say "Creating [$name-fig-$tmp$ext] with only preamble"; } open my $OUTfile, '>', "$name-fig-$tmp$ext"; - print {$OUTfile} "$preamble\n\\stop"; + print {$OUTfile} "$preambletmp\n\\stop"; close $OUTfile; - # Set compiler + # Set compiler for arara if ($opts_cmd{compiler}{arara}) { - my @engine = $preamble =~ m/$arara_rule/msx; + my @engine = $atbegindoc =~ m/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)|$arara_rule/msx; my %engine = map { $_ => 1 } @engine; if (%engine) { for my $var (@arara_engines) { if (defined $engine{$var}) { + Log("Found engine [$var] for arara"); $compiler = $var; } } } - else { $compiler = 'pdflatex'; } + else { + Log("Not detected engine for arara, use default [pdflatex]"); + $compiler = 'pdflatex'; + } } if ($compiler eq 'latex') { $compiler = 'pdflatex'; } if ($compiler eq 'dvilualatex') { $compiler = 'lualatex'; } @@ -2025,48 +2060,28 @@ if ($findgraphicx eq 'true') { else { Log("Not found graphicx package in $name-fig-$tmp.log"); Log("Add \\usepackage\{graphicx\} to preamble of $name-pdf$ext"); - $preamble= "$preamble\n\\usepackage\{graphicx\}"; + $preamble= "$preamble\\usepackage\{graphicx\}\n"; } } -### Regex for clean (pst-?) in preamble -$PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add | -pdf )? | psfrag |psgo |vaucanson-g| auto-pst-pdf(?: -lua )? )/x; -$FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}(\%*)?/x; - -Log("Remove pstricks packages in preamble for $name-pdf$ext"); -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - ^ $USEPACK (?: $CORCHETES )? $FAMILIA \s*//msxg; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - (?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))+//gmsx; -$preamble =~ s/\%<\*$dtxverb> .+?\%<\/$dtxverb>(*SKIP)(*F)| - \\SpecialCoor(?:[\t ]*(?:\r?\n|\r))+//gmsx; -$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; - -if (@pst_exa) { - Log("Uncomment pst-exa package in preamble for $name-pdf$ext"); - $preamble =~ s/(?:\%)(\\usepackage\[\s*)(swpl|tcb)(,pdf\s*\]\{pst-exa\})/$1$2$3/msxg; -} - ### Add last lines if (!@graphicspath) { Log("Not found \\graphicspath in preamble for $name-pdf$ext"); Log("Add \\graphicspath\{\{$imgdir/\}\} to preamble for $name-pdf$ext"); - $preamble= "$preamble\n\\graphicspath\{\{$imgdir/\}\}"; + $preamble= "$preamble\\graphicspath\{\{$imgdir/\}\}\n"; } + Log("Add \\usepackage\{grfext\} to preamble for $name-pdf$ext"); -$preamble = "$preamble\n\\usepackage\{grfext\}"; +$preamble = "$preamble\\usepackage\{grfext\}\n"; Log("Add \\PrependGraphicsExtensions\*\{\.pdf\} to preamble for $name-pdf$ext"); -$preamble = "$preamble\n\\PrependGraphicsExtensions\*\{\.pdf\}"; +$preamble = "$preamble\\PrependGraphicsExtensions\*\{\.pdf\}"; $preamble =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; -$preamble =~ s/^\\usepackage\{\}(?:[\t ]*(?:\r?\n|\r))+/\n/gmsx; -$preamble =~ s/^(?:[\t ]*(?:\r?\n|\r))?+//gmsx; ### Create a my $out_file = "$preamble\n$bodydoc\n$enddoc"; -### Clean \psset content in output file +### Clean \psset{...} content in +Log("Remove \\psset\{...\} in body for $name-pdf$ext"); $out_file =~ s/\\begin\{nopreview\}\%$tmp.+?\\end\{nopreview\}\%$tmp(*SKIP)(*F)| \%<\*$dtxverb> .+? \%<\/$dtxverb>(*SKIP)(*F)| \\psset\{(?:\{.*?\}|[^\{])*\}(?:[\t ]*(?:\r?\n|\r))?+//gmsx; @@ -2087,7 +2102,7 @@ $out_file =~ s/\\begin\{nopreview\}%$tmp ### Remove internal mark for verbatim and verbatim write environments $out_file =~ s/\%<\*$dtxverb>(.+?)\%<\/$dtxverb>/$1/gmsx; -%replace = (%changes_out); +%replace = (%changes_out,%tmpoutreplace); $find = join q{|}, map {quotemeta} sort { length $a <=> length $b } keys %replace; $out_file =~ s/($find)/$replace{$1}/g; @@ -2115,13 +2130,20 @@ my $ltxmkopt = $xetex ? "-pdfxe -silent -xelatex=\"xelatex $write18 -recorder % : $luatex ? "-pdflua -silent -lualatex=\"lualatex $write18 -recorder %O %S\"" : "-pdf -silent -pdflatex=\"pdflatex $write18 -recorder %O %S\"" ; + ### Set options for compiler $opt_compiler = $arara ? '--log' : $latexmk ? "$ltxmkopt" : "$write18 -interaction=nonstopmode -recorder" ; -### Set compiler name for arara and latexmk +### Set message in terminal +$msg_compiler = $xetex ? 'xelatex' + : $luatex ? 'lualatex' + : 'pdflatex' + ; + +### Set compiler message and compiler for arara and latexmk if ($arara) { $compiler = $msg_compiler = 'arara'; } if ($latexmk) { $compiler = $msg_compiler = 'latexmk'; } diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 95994267d07..7fba8680a4f 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2670,6 +2670,7 @@ $standardsource = '(\.(bat|c|drv|dtx|fea|fdd|ins|sfd)' 'poetrytex', 'Makefile|' . $standardsource, 'pseudo', 'NULL', # keep together 'pst-pdf', '\.(dtx|ins|e?ps|png)$|CHANGES.tex', + 'pst2pdf', 'NULL', 'pygmentex', 'NULL', # keep together 'rcs', 'rcs.el|src|' . $standardsource, 'ruhyphen', '^[^.]*$|README.ru|hyphen.rules', @@ -3630,7 +3631,8 @@ sub set_dir_defaults { $standarddocfmt = $standardsourcefmt = $standardfmt = "xelatex"; $guess = "$standarddocfmt for fmt/docfmt/srcfmt"; - } elsif ($ctan_dir =~ m!/(CTAN|tex-archive)/(support|web)/!) { + } elsif ($ctan_dir + =~ m!/(CTAN|tex-archive)/(support|web|graphics/.*/scripts)/!) { $standarddocfmt = $standardsourcefmt = "support"; $guess = "$standarddocfmt for docfmt/srcfmt"; -- cgit v1.2.3