diff options
author | Karl Berry <karl@freefriends.org> | 2014-09-24 21:43:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-09-24 21:43:37 +0000 |
commit | ab53e4ac1fa7c4f7e35d26bc4fa9b055305371ee (patch) | |
tree | 134786a15c6da7f5cfa284e97debc034925b89ab /Master | |
parent | b6cb826a8d5edf82e16adf164bea852ebc88cf97 (diff) |
pst2pdf (24sep14)
git-svn-id: svn://tug.org/texlive/trunk@35247 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/Changes | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/Makefile.doc | 62 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/README | 39 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib | 149 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf | bin | 76161 -> 76775 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex | 84 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test.pdf | bin | 68528 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test.tex | 408 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf | bin | 117779 -> 137035 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf | bin | 165265 -> 128767 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test2.pdf | bin | 20917 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf | bin | 73649 -> 78630 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pst2pdf/test3.tex | 2 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl | 1382 |
14 files changed, 1058 insertions, 1078 deletions
diff --git a/Master/texmf-dist/doc/latex/pst2pdf/Changes b/Master/texmf-dist/doc/latex/pst2pdf/Changes index 00844724a41..3aaf4ab41ed 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/Changes +++ b/Master/texmf-dist/doc/latex/pst2pdf/Changes @@ -1,7 +1,11 @@ pst2pdf.pl -------- +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 + - 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 @@ -19,8 +23,8 @@ pst2pdf.pl -------- 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 + - 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 diff --git a/Master/texmf-dist/doc/latex/pst2pdf/Makefile.doc b/Master/texmf-dist/doc/latex/pst2pdf/Makefile.doc deleted file mode 100644 index 442e4f0040d..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/Makefile.doc +++ /dev/null @@ -1,62 +0,0 @@ -# `Makefile' for `pst2pdf.pdf', hv, 2006/08/11 - -.SUFFIXES : .tex .ltx .dvi .ps .pdf .eps - -PACKAGE = pst2pdf - -MAIN = $(PACKAGE)-doc - -LATEX = latex - -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: $(MAIN).pdf - -$(MAIN).pdf : $(MAIN).ps - GS_OPTIONS=-dAutoRotatePages=/None ps2pdf $< - -$(MAIN).ps : $(MAIN).dvi - dvips $< - -$(MAIN).dvi : $(MAIN).tex - $(LATEX) $< - $(LATEX) $< - if ! test -f $(basename $<).glo ; then touch $(basename $<).glo; fi - if ! test -f $(basename $<).idx ; then touch $(basename $<).idx; fi - makeindex -s gglo.ist -t $(basename $<).glg -o $(basename $<).gls \ - $(basename $<).glo - makeindex -t $(basename $<).ilg -o $(basename $<).ind \ - $(basename $<).idx - bibtex $(basename $<) - $(LATEX) $< - $(LATEX) $< - -clean : - $(RM) $(addprefix $(MAIN), .log .aux .glg .glo .gls .ilg .idx .ind .tmp .toc .out ) - $(RM) $(addprefix $(MAIN), .dvi .ps) - -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 $(MAIN).pdf $(TDS)/scripts/$(PACKAGE)/ - cp -u $(MAIN).tex $(TDS)/scripts/$(PACKAGE)/ - cp -u $(MAIN).bib $(TDS)/scripts/$(PACKAGE)/ - cp -u Makefile $(TDS)/scripts/$(PACKAGE)/ - cp -u test?.tex $(TDS)/scripts/$(PACKAGE)/ - cp -u test?-pdf.pdf $(TDS)/scripts/$(PACKAGE)/ - cp -u pst2pdf.pl $(TDS)/scripts/$(PACKAGE)/ - - -# EOF diff --git a/Master/texmf-dist/doc/latex/pst2pdf/README b/Master/texmf-dist/doc/latex/pst2pdf/README index 62bc39fa882..75ca92173dd 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/README +++ b/Master/texmf-dist/doc/latex/pst2pdf/README @@ -33,23 +33,28 @@ pdflatex, which then creates file-pdf.pdf. The created images are named file-fig-<No>.pdf Options: - -h,-help - display this help and exit - -l,-license - display license information and exit - -imageDir - the dir for the created images (default images) - -d,-DPI=<int> - the dots per inch for a cretaed ppm files (default 75) - -j,-jpg - create .jpg files (need pdftoppm and ImageMagick) - -p,-png - create .png files (need pdftoppm and ImageMagick) - -e,-eps - create .eps files (need pdftops) - -Iscale=<real> - the value for [scale=] in \\includegraphics - -noImages - generate file-pdf.tex, but not images - -v,-verbose - creates log file (.plog) - -c,-clear - delete all tmp files - -runBibTeX - run bibtex on the aux file, if exists - -runBiber - run biber on the bcf file, if exists - -s,-single - create images whitout pdftk - -a,-all - create all image type and images.tex - -x,-xetex - using (Xe)LaTeX for compilation - -PS2=<opt> - pass options to ps2pdf (default empty) +Options: + -h,--help - display this help and exit + -l,--license - display license information and exit + -v,--version - display version (current $nv) and exit + -d,--dpi=<int> - the dots per inch for images (default 300) + -j,--jpg - create .jpg files (need Ghostscript) + -p,--png - create .png files (need Ghostscript) + -e,--eps - create .eps files (need pdftops) + -s,--svg - create .svg files (need pdf2svg) + -P,--ppm - create .ppm files (need pdftoppm) + -a,--all - create .(pdf,eps,jpg,png,ppm,svg) images + -c,--clear - delete all temp and aux files + -x,--xetex - using (Xe)LaTeX for create images + -m,--margins=<int> - margins for pdfcrop (in bp) (default 1) + -ni,--noimages - generate file-pdf.tex, but not images + -np,--single - create images files whitout preview and Ghostscript + -ns,--nosource - delete all source(.tex) for images files + --imgdir=<string> - the folder for the created images (default images) + --ignore=<string> - skip other verbatim environment (default other) + --bibtex - run bibtex on the aux file, if exists + --biber - run biber on the bcf file, if exists + --Verbose - creates a long log file (.plog) for more documentation => pst2pdf --help or read the documentation -- 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 b51192400d3..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.bib +++ /dev/null @@ -1,149 +0,0 @@ -%% -*-bibtex-*- -@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} } - -@Article{ dtk02.2:jackson.voss:plot-funktionen, - author = {Laura E. Jackson and Herbert Vo{\ss}}, - title = {Die {P}lot-{F}unktionen von {\texttt{pst-plot}}}, - journal = dtk, - year = 2002, - volume = {2/02}, - altvolume = 2, - altnumber = 14, - month = jun, - pages = {27--34}, - annote = bretter, - keywords = {}, - abstract = { Im letzten Heft wurden die mathematischen Funktionen von - \PS~im Zusammenhang mit dem {\LaTeX}-Paket - \texttt{pst-plot} zum Zeichnen von Funktionen beschrieben - und durch Beispiele erl{\"a}utert. In diesem Teil werden - die bislang nur erw{\"a}hnten Plot-Funktionen f{\"u}r - externe Daten behandelt. } -} - -@Article{ dtk02.1:voss:mathematischen, - author = {Herbert Vo{\ss}}, - title = {Die mathematischen {F}unktionen von {P}ost{S}cript}, - journal = dtk, - year = 2002, - volume = {1/02}, - altvolume = 1, - altnumber = 14, - month = mar, - pages = {}, - annote = bretter, - keywords = {}, - abstract = { \PS, faktisch genauso alt wie {\TeX}, ist im - Verh{\"a}ltnis dazu allgemein noch weniger bekannt, wenn es - darum geht zu beurteilen, was es denn nun im eigentlichen - Sinne ist. Au{\ss}erdem wird h{\"a}ufig vergessen, dass - sich mit den \PS-Funktionen viele Dinge erledigen lassen, - bei denen sonst auf externe Programme zur{\"u}ckgegriffen - wird. Dies wird im Folgenden f{\"u}r die mathematischen - Funktionen im Zusammenhang mit dem Paket \texttt{pst-plot} - gezeigt. } -} - -@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 = second, - 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} -} - -@Book{PostScript, - Author = {Kollock, Nikolai G.}, - Title = {Post{S}cript richtig eingesetzt: vom {K}onzept zum - praktischen {E}insatz}, - Publisher = {IWT}, - Address = {Vaterstetten}, - year = 1989, -} - -@Manual{pstricks, - Title = {PSTricks - {\PS} macros for generic {\TeX}}, - Author = {{Timothy van} Zandt and Herbert Vo{\ss}}, - Organization = {}, - Address = {\url{http://PSTricks.tug.org/}}, - Note = {}, - year = 2011 -} - -@Manual{pst-plot, - Title = {\texttt{pst-plot}: Plotting two dimensional functions and data}, - Author = {{Timothy van} Zandt and Herbert Vo{\ss}}, - Organization = {}, - Address = {\url{CTAN:graphics/pstricks/generic/pst-plot.tex}}, - Note = {}, - year = 2011 -} - -@Manual{multido, - Title = {\texttt{multido.tex} - a loop macro, that supports fixed-point addition}, - Author = {{Timothy van} Zandt}, - Organization = {}, - Address = {\url{CTAN:/graphics/pstricks/generic/multido.tex}}, - Note = {}, - year = 1997 -} - -@Book{PSTricks2, - author = {Herbert Vo\ss}, - title = {\texttt{PSTricks} -- {G}rafik f\"ur \TeX{} und \LaTeX}, - edition = {6.}, - publisher = {DANTE -- Lehmanns}, - year = {2011}, - address = {Heidelberg/Hamburg} -} - -@Book{voss:math, - author = {Herbert Vo\ss}, - title = {Typesetting mathematics with \LaTeX}, - publisher = {UIT}, - year = {2010}, - address = {Cambridge} -} - -@Book{PSTricks2-UIT, - author = {Herbert Vo\ss}, - title = {PSTricks -- Graphics for \TeX\ and \LaTeX}, - publisher = {UIT}, - year = {2011}, - address = {Cambridge} -} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf Binary files differindex 928f35f43b2..226845234cb 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf +++ b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.pdf diff --git a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex index a89995f74b8..7a59358ff9d 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex +++ b/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex @@ -16,7 +16,7 @@ \begin{document} \title{\texttt{pst2pdf}} -\subtitle{Running a PSTricks document with pdflatex;\\ \small v. 0.15} +\subtitle{Running a PSTricks document with pdflatex;\\ \small v. 0.16} \author{Herbert Vo\ss \\ Pablo Gonz\'{a}lez Luengo} \docauthor{} \date{\today} @@ -38,14 +38,15 @@ all \PST\ related code into single documents with the same preamble as the origi main document. The \nxLprog{pst2pdf} \emph{script} runs document, clips all whitespace around the -image and creates a \Lext{pdf} (and \Lext{eps},\Lext{ppm}) image of the \PST\ -related code. In a last run which is the \Lprog{pdflatex} the \PST\ code in 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{Requirements} \subsection{Programs needed} -\nxLprog{pst2pdf} needs \Lprog{pdftk}, \Lprog{ImageMagick}, \Lprog{pdftoppm} and \Lprog{pdftops} -(from \Lprog{poppler-utils} or \Lprog{xpdf-utils}) for the process file. If you need a create .pdf image files (whitout \Lprog{pdftk}) use single mode (see \ref{single}). +\nxLprog{pst2pdf} needs a latest version \Lprog{Ghostscript} (9.14), \Lprog{perl} (>=5.18), \Lprog{pdf2svg}, \Lprog{pdftoppm} and \Lprog{pdftops} +(from \Lprog{poppler-utils} or \Lprog{xpdf-utils}) for the process file. If you need a create .pdf images whitout \Lprog{Ghostscript}, use single mode (see \ref{single}). \subsection{Preparating file} The script scan the file for \Lenv{pspicture} and \Lenv{postscript} environments, @@ -55,9 +56,16 @@ the \Lenv{postscript} one not! But it can contain an environment \Lenv{pspicture 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. -Put all related \PST\ package in separate lines in your preamble, \nxLprog{pst2pdf} delete al lines contains \PST\ package before last run. +\nxLprog{pst2pdf} delete al lines contains \PST\ package before last run, if you need delete other \PST\ code in preamble use: + +\begin{verbatim} +%CleanPST +pstricks code +%CleanPST +\end{verbatim} -This is an example of environments that support for \nxLprog{pst2pdf}: +\section{Environments support} +\nxLprog{pst2pdf} support fourth environments in default and single way: \vspace{10pt} \begin{minipage}[c]{0.25\textwidth} @@ -93,6 +101,10 @@ pstricks code \end{verbatim} \end{minipage} +\vspace{10pt} +Note: When using the default mode, images are created using \Lprog{Ghostscript} and \LPack{preview} package, in this case, it is not necessary +to write \Lenv{psset} into \PST\ environment. +\newpage \section{Running the script} \subsection{Default mode} The general syntax for the \Lprog{perl} \emph{script} is simple: @@ -108,13 +120,13 @@ For \TeX Live users: \end{BDef} In this way \nxLprog{pst2pdf} creates a new file called \Larg{file-pst.tex} and copy all \Lenv{pspicture} -and \Lenv{postscript} environments, then processed and create file-pdf.pdf and file-fig-1.pdf, file-fig-2.pdf, file-fig-\dots.pdf and file-fig-1.tex, file-fig-2.tex, file-fig-\dots.tex for all \Lenv{pspicture} and \Lenv{postscript} using \nxLprog{pdftk}. +and \Lenv{postscript} environments, then processed and create file-pdf.pdf and file-fig-1.pdf, file-fig-2.pdf, file-fig-\dots.pdf and file-fig-1.tex, file-fig-2.tex, file-fig-\dots.tex for all \Lenv{pspicture} and \Lenv{postscript} using \nxLprog{Ghostscript}. \subsection{Single mode} \label{single} -If you do not have \nxLprog{pdftk} use the option \Loption{--single} in this mode the files are processed separately (take a more time to create images files) by default create PDF files. For example: +If you do not have \nxLprog{Ghostscript} use the option \Loption{-np,---single} in this mode, the files are processed separately (take a more time to create images files). For example: \begin{BDef} -\nxLprog{pst2pdf} \Larg{file.tex} \OptArg*{--single} +\nxLprog{pst2pdf} \Larg{file.tex} \OptArg*{---single} \end{BDef} create file-pdf.pdf and file-fig-1.pdf, file-fig-2.pdf, file-fig-\dots.pdf and file-fig-1.tex, file-fig-2.tex, file-fig-\dots.tex for all \Lenv{pspicture} and \Lenv{postscript} environments (see \ref{options}). @@ -127,24 +139,27 @@ The options listed in Table~\ref{perloptions} refer only to the \emph{script} an \caption{Optional arguments for \nxLprog{pst2pdf}}\label{perloptions} \begin{tabularx}{\linewidth}{@{} l l >{\ttfamily}l X @{}}\\\toprule \emph{name} & \emph{values} & \textrm{\emph{default}} & \emph{description}\\\midrule -\Loption{--imageDir} & literal & images/ & the directory for the created images.\\ -\Loption{--Iext} & literal & .pdf & the extension for \Loption{PrependGraphicsExtensions}.\\ -\Loption{--DPI} & integer & 75 & the dots per inch for a created \Lext{ppm} file.\\ -\Loption{--Iscale} & real & 1 & the value for the option \Loption{scale} in \Lcs{includegraphics}.\\ -\Loption{--eps} & boolean & 0 & creates \Lext{eps} images (need \Lprog{pdftops}).\\ -\Loption{--jpg} & boolean & 0 & creates \Lext{jpg} images (need \Lprog{pdftoppm} and \Lprog{ImageMagick}).\\ -\Loption{--png} & boolean & 0 & creates \Lext{png} images (need \Lprog{pdftoppm} and \Lprog{ImageMagick}).\\ -\Loption{--verbose} & boolean & 1 & for a long \nxLprog{pst2pdf} log.\\ -\Loption{--PS2} & literal & empty & pass options to \nxLprog{ps2pdf}.\\ -\Loption{--clear} & boolean & 0 & delete all temporary files.\\ -\Loption{--help} & boolean & 1 & print help and exit.\\ -\Loption{--single} & boolean & 0 & create images type (whitout pdftk).\\ -\Loption{--all} & boolean & 0 & generte all image (.pdf, .eps, .jpg, .png, .tex) and clear.\\ -\Loption{--license} & boolean & 0 & print license and exit.\\ -\Loption{--xetex} & boolean & 0 & using \Lprog{xelatex} instead of \Lprog{latex} for the process.\\ -\Loption{--noImages} & boolean & 0 & generate file-pdf.tex, but no images.\\ -\Loption{--runBibTeX}& boolean & 0 & runs \Lprog{bibtex} \\ -\Loption{--runBiber} & boolean & 0 & runs \Lprog{biber} if a file with extension \Lext{bcf} exists \\\bottomrule +\Loption{-h,---help} & boolean & 1 & print help and exit.\\ +\Loption{-l,---license} & boolean & 0 & print license and exit.\\ +\Loption{-v,---version} & boolean & 1 & print version and exit.\\ +\Loption{-m,---margins} & literal & 1 & margins for pdfcrop (in bp).\\ +\Loption{-d,---dpi} & integer & 300 & the dots per inch for a created \Lext{ppm} file.\\ +\Loption{-j,---jpg} & boolean & 0 & creates \Lext{jpg} images (need \Lprog{Ghostscript}).\\ +\Loption{-p,---png} & boolean & 0 & creates \Lext{png} images (need \Lprog{Ghostscript}).\\ +\Loption{-e,---eps} & boolean & 0 & creates \Lext{eps} images (need \Lprog{pdftops}).\\ +\Loption{-s,---svg} & boolean & 0 & creates \Lext{ppm} images (need \Lprog{pdf2svg}).\\ +\Loption{-P,---ppm} & boolean & 0 & creates \Lext{ppm} images (need \Lprog{pdftoppm}).\\ +\Loption{-c,---clear} & boolean & 0 & delete all temporary files.\\ +\Loption{-a,---all} & boolean & 0 & generte all images type and clear.\\ +\Loption{-x,---xetex} & boolean & 0 & using \Lprog{xelatex} instead of \Lprog{latex} for process.\\ +\Loption{-np,---single} & boolean & 0 & create images type (whitout Ghostscript).\\ +\Loption{-ni,---noimages} & boolean & 0 & generate file-pdf.tex, but no images.\\ +\Loption{-ns,---nosource} & boolean & 0 & delte all source for images.\\ +\Loption{---imgdir} & literal & images/ & the directory for the created images.\\ +\Loption{---ignore} & literal & other & skip other verbatim environment.\\ +\Loption{---Verbose} & boolean & 1 & for a long \nxLprog{pst2pdf} log.\\ +\Loption{---bibtex} & boolean & 0 & runs \Lprog{bibtex}.\\ +\Loption{---bibtex} & boolean & 0 & runs \Lprog{biber} if a file with extension \Lext{bcf} exists. \\\bottomrule \end{tabularx} \end{table} @@ -154,19 +169,16 @@ For Help in command line use: \nxLprog{pst2pdf} \OptArg*{--help} \end{BDef} -\section{Image format} -\nxLprog{pst2pdf} can create image files in the formats: \Lext{pdf}, \Lext{eps}, \Lext{jpg} and \Lext{png}. If you need to create other image formats use \nxLprog{pst2pdf} \Larg{file.tex} \OptArg*{-png} without the option -\OptArg*{-clear} , than move to images dir and use \nxLprog{mogrify} command (from \Lprog{ImageMagick}), for examples:\\ +\section{Other image format} +If you need to create other image formats use \nxLprog{pst2pdf}, move to images dir and use +\nxLprog{mogrify} command (from \Lprog{ImageMagick}), for examples:\\ \begin{BDef} -\nxLprog{mogrify} -format gif \OptArg*{*.ppm} -\end{BDef} -generate \Lext{gif} images files and \\ -\begin{BDef} \nxLprog{mogrify} -format tiff \OptArg*{*.ppm} \end{BDef} generate \Lext{tiff} images files. -\enlargethispage{1cm} +\newpage +% \bgroup \raggedright \nocite{*} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test.pdf Binary files differdeleted file mode 100644 index 8ffafa7a152..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test.pdf +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test.tex b/Master/texmf-dist/doc/latex/pst2pdf/test.tex deleted file mode 100644 index c664fb0a0d7..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test.tex +++ /dev/null @@ -1,408 +0,0 @@ -\documentclass{article} -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{textcomp} -\usepackage{lmodern} -\usepackage[dvipsnames]{xcolor} -\usepackage{pst-solides3d} -\usepackage{psgo} -\usepackage{pst-text} -\usepackage{pst-blur} -\usepackage[tiling]{pst-fill} -\usepackage{pst-calendar} -\usepackage{pst-eucl} -\usepackage{pst-labo} -\usepackage{pst-3d} -\usepackage{psfrag} -\usepackage{pst-bar} -\usepackage{pst-barcode} -\usepackage{pst-gr3d} -\usepackage{pst-ob3d} -\usepackage{pst-3dplot} -\usepackage{pst-tree} -\usepackage{pst-coil} -\usepackage{pst-bezier} -\usepackage{pst-coxeterp} -\usepackage{pst-circ} -\usepackage{pst-func} -\usepackage{pstricks-add} -\usepackage{pst-plot,pst-math} -\usepackage{pst-slpe} -\usepackage{pst-fr3d} -\usepackage{vaucanson-g} -\usepackage{blindtext} -\usepackage{multido} -\usepackage{pst-grad} -\usepackage{pstricks-add} -%\usepackage[pspdf={-dPDFSETTINGS=/prepress}]{auto-pst-pdf} -\begin{document} -A test for pst2pdf ... -\texttt{blindtext,pst-node} -\begin{postscript} -\SpecialCoor -\rnode{A}{The beginning of it all:} -\blindtext -\rnode{E}{And this is the end my friend.} -\nccurve[linewidth=5pt,strokeopacity=0 .4,ncurvB=0.9,arrowscale=1.5,arrows=->]{A}{E} -\end{postscript} - -\texttt{pstricks-add} -\begin{pspicture}(-0.04,-0.04)(1,1) -\psset{unit=5} -\psgrid[subgriddiv=5,subgridcolor=lightgray] -\psplotDiffEqn[whichabs=0,whichord=1,linecolor=red, -method=rk4,algebraic,plotpoints=400, -showpoints=true]{0}{10}{0 0}% -{cos(Pi*x^2/2)|sin(Pi*x^2/2)} -\end{pspicture} - -\texttt{pst-solides3d} -\begin{pspicture}[solidmemory](-4,-5)(7,4) -\psset{viewpoint=50 -40 10 rtp2xyz,Decran=50, -linecolor=darkgray,lightsrc=viewpoint} -\psSolid[object=grille,action=draw,base=-3 5 -3 5, -linecolor=Salmon!40](0,0,-3) -\psSolid[object=cylindre,r=2,h=6,ngrid=6 24, -plansepare={[0.707 0 0.707 0]},name=Zylinder, -action=none](0,0,-3) -\psSolid[object=load,load=Zylinder1, -fillcolor=black!5,fcol=0 (Goldenrod)] -\psSolid[object=load,load=Zylinder0,RotZ=90, -fillcolor=black!5,rm=0,hollow,incolor=Goldenrod](0,4,0) -\psSolid[object=plan,action=draw,definition=equation, -args={[0.707 0 0.707 0] 90},base=-2 2 -3 3,planmarks] -\psSolid[object=line,args=0 0 0 0 5.5 0, -linecolor=blue]% first half of y axis -\color{white}\axesIIID[showOrigin=false, -linecolor=blue](0,6.8,0)(3.5,8,3.5) -\end{pspicture} - -\texttt{pstricks} -\begin{postscript} -\psset{unit=0.05mm}% 1:20,or=0.1mm for 1:10 -\begin{pspicture}(-100,-100)(1000,650) -\pspolygon[linewidth=2pt,fillcolor=gray!10, -fillstyle=solid](0,0)(0,470)(860,625)(860,0) -\psset{linewidth=0.2pt,arrowscale=2,tbarsize=10pt} -\psline{|<->|}(0,-100)(860,-100) -\rput*(430,-100){430mm} -\psline{|<->|}(960,0)(960,625) -\rput*{90}(960,312.5){625mm} -\psline{|<->|}(-100,0)(-100,470) -\rput*{90}(-100,235){470mm} -\end{pspicture} -\end{postscript} - -\texttt{pstricks, pst-node, and pst-plot} -\begin{pspicture}(-1,-3)(4.75,3) -\psscalebox{0.75}{ -\psaxes{->}(0,0)(-1,-3)(5,3) -\psplot[polarplot,linewidth=2pt,algebraic, -plotpoints=500]{0}{6.289}{2*(1+cos(x))} -\multido{\r=0.000+0.314}{21}{ % -\psplotTangent[polarplot,Derive=-2*sin(x), -algebraic,arrows=<->]{\r}{1.5}{2*(1+cos(x))}} -} -\end{pspicture} - -\texttt{pst-plot} -\begin{pspicture}[showgrid=true](-1.1,-1.1)(1.1,1.1) -\psset{xunit=1.5cm,yunit=1.5cm} -\psparametricplot[plotstyle=curve,linewidth=1.5pt, -plotpoints=200]{-360}{360}% -{t 1.5 mul sin t 2 mul 60 add sin} -\end{pspicture} - -\texttt{pst-tree} -\begin{postscript} -\pstree[levelsep=1cm,radius=3pt]{\Toval{Wurzel}}{% -\pstree{\TC}{% -\TC -\pstree{\TC*}{\TC\TC\TC\TC}% -\TC\TC}} -\end{postscript} - -\texttt{pst-bezier} -\begin{pspicture}[showgrid=true](5,3) -\psset{showpoints=true} -\psbcurve[linecolor=blue,linewidth=0.01](1,1)% -(2,2)(3,1)(4,2) -\psbcurve(1,1)(2,2)l(2,1)(3,1)(4,2) -\uput[-90](2,1){$\vec{l}_{2}$} -\end{pspicture} - -\texttt{pst-text} -\begin{pspicture}(0,0)(.25\linewidth,8) -\DeclareFixedFont{\ps}{U}{psy}{m}{n}{8cm} -\psboxfill{\footnotesize$\pi$} -\pscharpath[fillstyle=solid, -fillcolor=cyan!20, -addfillstyle=boxfill,fillangle=30, -fillsep=0.6mm]{% -\rput[b](-0.5,0){\ps\char112}} -\end{pspicture} - -\texttt{pst-fill} -\begin{postscript} -\psset{unit=1.5,dimen=middle} -\begin{pspicture*}(3,3) -\psboxfill{\begin{pspicture}(1,1) -\psframe(1,1)\end{pspicture}} -\psframe[fillstyle=boxfill](3,3) -\psboxfill{\begin{pspicture}(1,1) -\rput{-37}{\psframe[linecolor=red](0.8,0.8)} -\end{pspicture}} -\psframe[fillstyle=boxfill](3,4) -\pspolygon[fillstyle=hlines,hatchangle=90](1,2)(1.64,1.53)(2,2) -\end{pspicture*} -\end{postscript} - - -\texttt{pst-coils} -\begin{pspicture}(4,3) -\cnode*(0.5,0.5){0.5}{A} -\cnode*(3.5,2.5){0.5}{B} -\pccoil[coilwidth=0.4,coilaspect=35,coilheight=0.5,linecolor=white]{<->}(A)(B) -\nccoil[coilwidth=0.4,coilaspect=35,coilheight=0.5]{A}{B} -\end{pspicture} - - -\texttt{pst-grad} -\begin{pspicture}(5,3.5) -\psframe[fillstyle=gradient,gradbegin=white](5,1.5) -\newrgbcolor{gradbegin}{0 1 1} -\psframe[fillstyle=gradient](0,2)(5,3.5) -\end{pspicture} - -\texttt{pst-slpe} -\begin{pspicture}(2.5,2.5) -\def\st#1{\makebox[2.75cm]{$\vcenter to 55pt{}#1$}} -\psset{fading,endfading=0.75,linecolor=black!40} -\psframe*(-0.3,-0.25)(3.5,20pt) -\psframebox[fillstyle=slope]{\LARGE\st{slope}} -\end{pspicture} - -\texttt{pst-blur} -\begin{postscript} -\DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{1.75cm} -\psset{shadow=true,blur=true,shadowsize=10pt,blurradius=5pt} -\pscharpath{\RM PSTricks} -\end{postscript} - -\texttt{pst-3d} - -\begin{pspicture}(-4.5,-3)(3,4.75) -\psset{viewpoint=1 1.5 0.8} -{\psset{gridlabels=0pt,subgriddiv=0,gridcolor=black!50} -\ThreeDput[normal=0 0 1]{\psgrid(5,5)} -\ThreeDput[normal=0 -1 0] {\ psgrid(5,5)} -\ThreeDput[normal=1 0 0]{\psgrid(5,5)}} -\ThreeDput[normal=0 0 1] {% -\psline[linewidth=3pt,linecolor=blue]{->}(4,4)(4,5.5) -\uput[90](4,5.5){% -\psrotateleft{\textcolor{blue}{$\vec{n}_A$}}}}%$%xy -\ThreeDput[normal=0 -1 0]{% -\psline[linewidth=3pt,linecolor=green]{->}(4,0)(5.5,0) -\uput[90](5.5,0){ \ psscalebox{-1 1}{% -\textcolor{green}{$\vec{n}_B$}}}}%$%xz -\ThreeDput[normal=1 0 0]{% -\psline[linewidth=3pt,linecolor=red]{->}(0,4)(0,5.5) -\uput[0](0,5.5){$\vec{n}_{top}$}} %yz -\ThreeDput[normal=0 0 1] (0,0,4){% -\psframe*[linecolor=gray!25] (4,4) -\rput(2,2){\Huge\textbf{TOP}}} -\ThreeDput[normal=0 1 0](4,4,0){% -\psframe*[linecolor=gray!5](4,4) -\rput(2,2){\Huge\textbf{side A}}} -\ThreeDput[normal=1 0 0] (4,0,0){% -\psframe*[linecolor=gray!15](4,4) -\rput(2,2){\Huge\textbf{side B}}} -% Die kleinen Achsen -\ThreeDput[normal=0 0 1](0,0,4){% -\psline(4,0)\uput[90](3,0){X$_{top}$} -\psline(0,4)\uput[0] (0,3){Y$_{top}$}} -\ThreeDput[normal=0 1 0](4,4,0){% -\psline(4,0)\uput[90](3,0){X$_{A}$} -\psline(0,4)\uput[0] (0,3){Y$_{A}$}} -\ThreeDput[normal=1 0 0] (4,0,0){% -\psline(4,0)\uput[90](3,0){X$_{B}$} -\psline(0,4)\uput[0](0,3){Y$_{B}$}} -\end{pspicture} - -\texttt{pst-ob3d} -\begin{pspicture}(-1,-0.5)(3,1.7) -\psset{fillstyle=solid,fillcolor=yellow,RandomFaces=true} -\PstDie[viewpoint=1 -3 1] -\rput(1.5,0){\PstCube[Corners=true,CornersColor=blue, -fillstyle=solid,fillcolor=cyan,viewpoint=1 2 1] -{1}{1}{1}} -\end{pspicture} - -\texttt{pst-gr3d} -\begin{postscript} -\psscalebox{0.5}{\footnotesize -\PstGridThreeD[GridThreeDNodes,unit=2.5](2,3,2) -\multido{\ix=0+1}{3}{% -\multido{\iy=0+1}{4}{% -\multido{\iz=0+1}{3}{% -\rput*(Gr3dNode\ix\iy\iz){$\ix\iy\iz$}}}} -\psset{linecolor=blue,linestyle=dashed, -linewidth=0.3pt,arrowscale=2,nodesep=8pt} -\pcline{->}(Gr3dNode000)(Gr3dNode202) -\pccurve{->}(Gr3dNode000)(Gr3dNode232)} -\end{postscript} - -\texttt{pst-fr3d} -\begin{postscript} -\PstFrameBoxThreeD[FrameBoxThreeDOn=false] -{\Large Off} -\quad -\PstFrameBoxThreeD{\Large On}% default -\end{postscript} - -\texttt{pst-3dplot} -\begin{pspicture}(-4.8,-1.75)(4.8,3.75) -\psset{unit=4cm,drawCoor,beginAngle=90,endAngle=180,linestyle=dotted} -\def\oA{\pstThreeDLine[linecolor=blue,linewidth=3pt, -arrows=c-> ](0,0,0)(1,60,70)} -\def\oB{\pstThreeDLine[linecolor=red,linewidth=3pt, -arrows=c->](0,0,0)(1,10,50)} -\def\oAB{\pstThreeDEllipse[beginAngle=58, -endAngle=90](0,0,0)(1,140,40)(1,10,50)} - -\pstThreeDCoor[drawing,linewidth=1pt,linecolor=black, -linestyle=solid,xMin=0,xMax=1.1,yMin=0,yMax=1.1, -zMin=0,zMax=1.1] -\pstThreeDEllipse(0,0,0)(-1,0,0)(0,1,0) -\pstThreeDEllipse(0,0,0)(-1,0,0)(0,0,1) -\pstThreeDEllipse[beginAngle=0, -endAngle=90](0,0,0)(0,0,1)(0,1,0) -\psset{SphericalCoor,linestyle=solid} -\pstThreeDDot[dotstyle=none](1,10,50) -\pstThreeDDot[dotstyle=none](1,60,70) -\pscustom[fillstyle=solid,fillcolor=black!20, -linestyle=none]{\oB\oAB\oA} \oA\oB\oAB -\pstThreeDPut[origin=lb](1.1,60,70){$\vec\Omega_1$} -\pstThreeDPut[origin=rb](1.2,10,50){$\vec\Omega_2$} -\pstThreeDPut[origin=lb](1,10,65){$\gamma_{12}$} -\end{pspicture} - -\texttt{pst-solides3d} -\begin{pspicture}(-2,-2)(2,2) -\psset{viewpoint=100 50 20 rtp2xyz, -Decran=60,lightsrc=10 15 10} -\defFunction[algebraic]{corne}(u,v)% -{(2 + u*cos(v))*sin(2*pi*u)}% -{(2 + u*cos(v))*cos(2*pi*u)+2*u}% -{u *sin(v)} -\psSolid[object=surfaceparametree,base=0 1 0 2 pi mul,function=corne,ngrid=20] -\end{pspicture} - -\texttt{pst-circ} -\begin{pspicture}(4,3.5) -\pnode(0,3){A}\pnode(0,0){B} -\pnode(4,1.5){C} -\OA[OAperfect=false,OAiplus, -OAiminus,OAiout, -OAipluslabel=$i_P$, -OAiminuslabel=$i_M$, -OAioutlabel=$i_A$, -intensitycolor=red, -intensitylabelcolor=red](A)(B)(C) -\end{pspicture} - - - -\texttt{pst-barcode} -\begin{postscript} -\psframebox{\begin{pspicture}(2.5,1in) -\psbarcode{12345678}{includetext}{ean8} -\end{pspicture}} -\end{postscript} - -\texttt{pst-bar} -\begin{postscript} -\psset{unit=0.5in}% -\begin{pspicture}(0,-0.5)(3,4.5)% -\psgrid[xunit=1.5in,gridlabels=0,% -subgriddiv=0,griddots=30](0,0)(1,4)% -\psaxes[axesstyle=frame,Ox=0,Dx=1,labels=y,% -ticks=y](0,0)(3,4)% -\readpsbardata{\data}{example2.csv}% -\psbarchart[barstyle={red,blue}]{\data}% -\end{pspicture} -\end{postscript} - -\texttt{pst-math} -\begin{pspicture*}(-0.75,-.75)(6,5) -\psaxes{->}(6,5) -\psset{linewidth=1.5pt,plotpoints=200} -\psplot{.1}{6}{x GAMMA} -\psplot{.1}{6}{x GAMMALN} -\end{pspicture*} - -\texttt{pst-func} -\begin{pspicture*}(-3,-2.2)(3.6,2.5) -\psaxes{->}(0,0)(-3,-2)(3.2,2)[$x$,0][$y$,90] -\psplotImp[linewidth=2pt,algebraic](-5,-2.2)(5,2.4){% -(x^2+y^2)^2-8*(x^2-y^2)} -\rput*(2,1.5){$\left(x^2+y^2\right)^2-8(x^2-y^2)=0$} -\psplotImp[linewidth=1pt,linecolor=red, -algebraic](-5,-2.2)(5,2.4){(x^2+y^2)^2-4*(x^2-y^2)} -\end{pspicture*} - -\texttt{pst-eucl} -\begin{postscript} -\pstGeonode[PosAngle={0,90}](2,2){A_0}(-2,2){B_0}% -\psset{RotAngle=90} -\pstRotation[PosAngle=270]{A_0}{B_0}[D_0] -\pstRotation[PosAngle=180]{D_0}{A_0}[C_0] -\pspolygon(A_0)(B_0)(C_0)(D_0)% -\psset{PointSymbol=none, PointName=none, HomCoef=.2} -\multido{\n=1+1,\i=0+1}{20}{% -\pstHomO[PosAngle=0]{B_\i}{A_\i}[A_\n] -\pstHomO[PosAngle=90]{C_\i}{B_\i}[B_\n] -\pstHomO[PosAngle=180]{D_\i}{C_\i}[C_\n] -\pstHomO[PosAngle=270]{A_\i}{D_\i}[D_\n] -\pspolygon(A_\n)(B_\n)(C_\n)(D_\n)}% fin multido -\end{postscript} - -\texttt{pst-labo} -\begin{postscript} -\psset{unit=0.5cm, -glassType=becher, -burette=false} -\pstDosage[phmetre] -\end{postscript} - -\texttt{psgo} -\begin{postscript} -\psscalebox{0.7}{% -\begin{psgopartialboard}[9]{(4,1)(9,6)} -\stone{white}{c}{3} \stone{white}{e}{3} -\stone{white}{d}{2} \stone{white}{d}{4} -\stone{black}{f}{3} \stone{black}{e}{2} -\stone{black}{e}{4} -\end{psgopartialboard}} -\end{postscript} - -\texttt{vaucanson-g} -\begin{postscript} -\begin{VCPicture}{(0,-2)(5.5,2)} -\State[p]{(0,0)}{A} \State{(2.5,0)}{B} -\State[r]{(5.5,0)}{C}\Initial{A} \Final{C} -\EdgeL{A}{B}{a} \ArcL{B}{C}{b} -\ArcL{C}{B}{b} \LoopN{A}{a} \LoopS{C}{d} -\end{VCPicture} -\end{postscript} - -Example for PSFRAG (from auto-pst-pdf) -psfrag example with replacements defined in example-psfrag.tex:\par -\begin{postscript} -\psfragfig{example} -\end{postscript} -The same example with a psfrag override (bottom left): -\begin{postscript} -\psfragfig{example}[\psfrag{[Mp]}{$N_Q*$}] -\end{postscript} -\end{document} diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf Binary files differindex bb3659ee69e..6a1e636665b 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf +++ b/Master/texmf-dist/doc/latex/pst2pdf/test1-pdf.pdf diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf Binary files differindex 5b507dae2ee..292c5eef341 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf +++ b/Master/texmf-dist/doc/latex/pst2pdf/test2-pdf.pdf diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test2.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test2.pdf Binary files differdeleted file mode 100644 index e92616a5433..00000000000 --- a/Master/texmf-dist/doc/latex/pst2pdf/test2.pdf +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf b/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf Binary files differindex 39e83c9d5b7..73beb930dd7 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf +++ b/Master/texmf-dist/doc/latex/pst2pdf/test3-pdf.pdf diff --git a/Master/texmf-dist/doc/latex/pst2pdf/test3.tex b/Master/texmf-dist/doc/latex/pst2pdf/test3.tex index db581e1b374..7703cf05364 100644 --- a/Master/texmf-dist/doc/latex/pst2pdf/test3.tex +++ b/Master/texmf-dist/doc/latex/pst2pdf/test3.tex @@ -1,5 +1,5 @@ \documentclass{article} -\usepackage{graphicx,pst-calendar,pst-3dplot}% Pakete +\usepackage{graphicx,pst-3dplot} \pagestyle{empty} \parindent=0pt \begin{document} diff --git a/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl b/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl index 568f0aef049..01b7a946e5f 100755 --- a/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl +++ b/Master/texmf-dist/scripts/pst2pdf/pst2pdf.pl @@ -1,12 +1,12 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; -use strict; # to be sure, that all is safe ... :-) - -# $Id: pst2pdf.pl 611 2011-12-14 08:41:35Z herbert $ -# v. 0.15 simplify the use of PSTricks with pdf -# 2011-12-12 (c) Herbert Voss <hvoss@tug.org> -# Pablo González Luengo +use strict; # to be sure, that all is safe ... :-) +use v5.18; +# $Id: pst2pdf.pl 119 2014-09-24 12:04:09Z herbert $ +# v. 0.16 2014-09-14 simplify the use of PSTricks with pdf +# 2014-09-24 (c) Herbert Voss <hvoss@tug.org> +# Pablo González Luengo <pablogonz@yahoo.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,39 +23,46 @@ use strict; # to be sure, that all is safe ... :-) # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # +use re 'eval'; use File::Path; # creating/removing dirs use File::Copy; # copying files -use File::Basename; # scan argument +use File::Basename; # scan argument use IO::File; # simple IO operation -use Getopt::Long; # read parameter -use autodie; # more safe +use Getopt::Long qw(:config bundling_override); # read parameter and activate "bundling" +use autodie; # more safe +use Config; +use File::Spec; +use File::Find; + #----------------------- User part begin ------------------------ -my $imageDir = "images"; # where to save the images -my $Iext = ".pdf"; # leave empty, if not a special one my $tempDir = "."; # temporary directory -my $verbose = 0; # 0 or 1, logfile +my $imageDir = "images"; # where to save the images +my $margins = "1"; # margins in pdfcrop +my $Verbose = 0; # 0 or 1, logfile my $clear = 0; # 0 or 1, clears all temporary files -my $DPI = 75; # very low value for the png's -my $Iscale = 1; # for \includegraphics +my $DPI = 300; # very low value for the png's my $noImages = 0; # 1->no create images -my $single = 0; # 1->create images in single mode +my $nopreview = 0; # 1->create images in nopreview mode my $runBibTeX = 0; # 1->runs bibtex my $runBiber = 0; # 1->runs biber and sets $runBibTeX=0 my $jpg = 0; # 1->create .jpg files my $png = 0; # 1->create .png files my $ppm = 0; # 1->create .ppm files my $eps = 0; # 1->create .eps files -my $files = 1; # 1->create image files .tex +my $svg = 0; # 1->create .svg files my $all = 0; # 1->create all images and files for type my $xetex = 0; # 1->Using (Xe)LaTeX for compilation. -my $PS2 = " "; # Options for ps2pdf -#----------------------- User part end --------------------------- -#-------------- program identification, options and help --------- -my $program = "pst2pdf"; -my $nv="0.15"; -my $ident = '$Id: pst2pdf.pl 611 2011-12-14 08:41:35Z herbert $'; +my $exacount = 1; # Counter for PSTexample +my $noSource = 0; # Delete TeX source for images +my $other = "other"; # search other verbatim environment +#------------------------- User part end ------------------------------- + +#---------------- Program identification, options and help ------------- +my $program = 'pst2pdf'; +my $nv='v0.16'; +my $ident = '$Id: pst2pdf.pl 119 2014-09-24 12:04:09Z herbert $'; my $copyright = <<END_COPYRIGHT ; -Copyright 2011-2013 (c) Herbert Voss <hvoss\@tug.org> and Pablo González. +Copyright 2011-2014 (c) Herbert Voss <hvoss\@tug.org> and Pablo González. END_COPYRIGHT my $licensetxt= <<END_LICENSE ; This program is free software; you can redistribute it and/or modify @@ -64,60 +71,76 @@ my $licensetxt= <<END_LICENSE ; (at your option) any later version. END_LICENSE +my $version= <<END_VERSION ; +${program} ${nv} ${ident} +${copyright} +END_VERSION my $title = "$program $nv $ident\n"; my $usage = <<"END_OF_USAGE"; ${title}Usage: $program <texfile.tex> [Options] -pst2pdf run a TeX source, read all PS-related part and convert in - single images in pdf,eps,jpg or png format (default pdf) and - create new file whitout pst-enviroment and runs (pdf/Xe)latex. +pst2pdf run a TeX source, read all PS-related part and convert in images + in pdf,eps,jpg or png format (default pdf) and create new file + whitout pst-enviroment and runs (pdf/Xe)latex. See pst2pdf documentation for more info. Options: - -h,-help - display this help and exit - -l,-license - display license information and exit - -imageDir= - the dir for the created images (default images) - -d,-DPI=<int> - the dots per inch for a cretaed ppm files (default 75) - -j,-jpg - create .jpg files (need pdftoppm and ImageMagick) - -p,-png - create .png files (need pdftoppm and ImageMagick) - -e,-eps - create .eps files (need pdftops) - -Iscale=<real> - the value for [scale=] in \\includegraphics - -noImages - generate file-pdf.tex, but not images - -v,-verbose - creates log file (.plog) - -c,-clear - delete all tmp files - -runBibTeX - run bibtex on the aux file, if exists - -runBiber - run biber on the bcf file, if exists - -s,-single - create images whitout pdftk - -a,-all - create all image type and images.tex - -x,-xetex - using (Xe)LaTeX for compilation - -PS2=<opt> - pass options to ps2pdf (default empty) + -h,--help - display this help and exit + -l,--license - display license information and exit + -v,--version - display version (current $nv) and exit + -d,--dpi=<int> - the dots per inch for images (default 300) + -j,--jpg - create .jpg files (need Ghostscript) + -p,--png - create .png files (need Ghostscript) + -e,--eps - create .eps files (need pdftops) + -s,--svg - create .svg files (need pdf2svg) + -P,--ppm - create .ppm files (need pdftoppm) + -a,--all - create .(pdf,eps,jpg,png,ppm,svg) images + -c,--clear - delete all temp and aux files + -x,--xetex - using (Xe)LaTeX for create images + -m,--margins=<int> - margins for pdfcrop (in bp) (default 1) + -ni,--noimages - generate file-pdf.tex, but not images + -np,--single - create images files whitout preview and Ghostscript + -ns,--nosource - delete all source(.tex) for images files + --imgdir=<string> - the folder for the created images (default images) + --ignore=<string> - skip other verbatim environment (default other) + --bibtex - run bibtex on the aux file, if exists + --biber - run biber on the bcf file, if exists + --Verbose - creates a long log file (.plog) + Examples: -* $program test.tex -all -* produce test-pdf.tex whitout pst-enviroment and create image dir -* whit all images (pdf,eps,jpg,png) and source(.tex) for all pst-enviroment +* $program test.tex -e -p -j -c --imgdir=pics +* produce test-pdf.tex whitout pstriks related parts and create image +* dir whit all images (pdf,eps,png,jpg) and source (.tex) for all pst +* enviroment in "pics" dir using Ghostscript and cleaning all tmp files. +* suport bundling for short options $program test.tex -epjc --imgdir=pics END_OF_USAGE # my $result=GetOptions ( - 'h|help' => \$::opt_help, - 'l|license' => \$::opt_license, - 'd|DPI=i' => \$DPI, # numeric - "Iscale=f" => \$Iscale, # real - "imageDir=s" => \$imageDir, # string - "PS2=s" => \$PS2, # string - "tempDir=s" => \$tempDir, # string - "Iext=s" => \$Iext, # string - 'c|clear' => \$clear, # flag - "noImages" => \$noImages, # flag - 's|single' => \$single, # flag - "runBibTeX" => \$runBibTeX, # flag - 'e|eps' => \$eps, # flag - 'j|jpg' => \$jpg, # flag - 'p|png' => \$png, # flag - 'a|all' => \$all, # flag - 'x|xetex' => \$xetex, # flag - "runBiber" => \$runBiber, # flag - 'v|verbose' => \$verbose, + 'h|help' => \$::opt_help, + 'v|version' => \$::opt_version, + 'l|license' => \$::opt_license, + 'd|dpi=i' => \$DPI,# numeric + 'm|margins=i' => \$margins,# numeric + 'imgdir=s' => \$imageDir, # string + 'ignore=s' => \$other, # string + 'c|clear' => \$clear, # flag + 'ni|noimages' => \$noImages, # flag + 'np|single' => \$nopreview, # flag + 'bibtex' => \$runBibTeX,# flag + 'e|eps' => \$eps, # flag + 'j|jpg' => \$jpg, # flag + 'p|png' => \$png, # flag + 'P|ppm' => \$ppm, # flag + 's|svg' => \$svg, # flag + 'a|all' => \$all, # flag + 'x|xetex' => \$xetex, # flag + 'biber' => \$runBiber, # flag + 'ns|nosource' => \$noSource, # flag + 'Verbose' => \$Verbose, ) or die $usage; #------------------------ Help functions -------------------------- -sub errorUsage { die "Error: @_ (try --help for more information)\n"; } +sub errorUsage { + die "Error: @_ (try --help for more information)\n"; + } + # options for command line if ($::opt_help) { print $usage; @@ -129,36 +152,240 @@ if ($::opt_license) { print $licensetxt; exit (0); } +if ($::opt_version) { +print $version; + exit (0); +} + # open file my $InputFilename = ""; @ARGV > 0 or errorUsage "Input filename missing"; @ARGV < 2 or errorUsage "Unknown option or too many input files"; $InputFilename = $ARGV[0]; -my @SuffixList = (".tex","",".ltx"); # possible extensions -my ($name,$path,$ext) = fileparse($ARGV[0],@SuffixList); -if ($ext eq "") { $ext = ".tex"; } # me need the extension as well -my $TeXfile = "$path$name$ext"; +#------------------------ Arreglo de la extensión ---------------------- +my @SuffixList = ('.tex', '', '.ltx'); # posible extensión +my ($name, $path, $ext) = fileparse($ARGV[0], @SuffixList); +$ext = '.tex' if not $ext; + +#--------------------- Directorio destino de imágenes ------------------ +-e $imageDir or mkdir($imageDir,0744) or die "No puedo crear $imageDir: $!\n"; + +# expresion regular para swpl +my $graphics = "graphic=\{\[scale=1\]$imageDir/$name-exa"; + +# directorio en el cual están las imágenes +my $dir = "$tempDir/$imageDir"; + +# archivo de entrada para el resto del script +my $TeXfile = "$tempDir/$name-tmp$ext"; + + +#----------------------------- Search GS ------------------------------ +# The next code its part of pdfcrop from TexLive 2014 +# Windows detection +my $Win = 0; +$Win = 1 if $^O =~ /mswin32/i; +$Win = 1 if $^O =~ /cygwin/i; + +my $archname = $Config{'archname'}; +$archname = 'unknown' unless defined $Config{'archname'}; + +# get Ghostscript command name +$::opt_gscmd = ''; +sub find_ghostscript () { + return if $::opt_gscmd; + if ($Verbose) { + print "* Perl executable: $^X\n"; + if ($] < 5.006) { + print "* Perl version: $]\n"; + } + else { + printf "* Perl version: v%vd\n", $^V; + } + if (defined &ActivePerl::BUILD) { + printf "* Perl product: ActivePerl, build %s\n", ActivePerl::BUILD(); + } + printf "* Pointer size: $Config{'ptrsize'}\n"; + printf "* Pipe support: %s\n", + (defined($Config{'d_pipe'}) ? 'yes' : 'no'); + printf "* Fork support: %s\n", + (defined($Config{'d_fork'}) ? 'yes' : 'no'); + } + my $system = 'unix'; + $system = "dos" if $^O =~ /dos/i; + $system = "os2" if $^O =~ /os2/i; + $system = "win" if $^O =~ /mswin32/i; + $system = "cygwin" if $^O =~ /cygwin/i; + $system = "miktex" if defined($ENV{"TEXSYSTEM"}) and + $ENV{"TEXSYSTEM"} =~ /miktex/i; + print "* OS name: $^O\n" if $Verbose; + print "* Arch name: $archname\n" if $Verbose; + print "* System: $system\n" if $Verbose; + my %candidates = ( + 'unix' => [qw|gs gsc|], + 'dos' => [qw|gs386 gs|], + 'os2' => [qw|gsos2 gs|], + 'win' => [qw|gswin32c gs|], + 'cygwin' => [qw|gs gswin32c|], + 'miktex' => [qw|mgs gswin32c gs|] + ); + if ($system eq 'win' or $system eq 'cygwin' or $system eq 'miktex') { + if ($archname =~ /mswin32-x64/i) { + my @a = (); + foreach my $name (@{$candidates{$system}}) { + push @a, 'gswin64c' if $name eq 'gswin32c'; + push @a, $name; + } + $candidates{$system} = \@a; + } + } + my %exe = ( + 'unix' => '', + 'dos' => '.exe', + 'os2' => '.exe', + 'win' => '.exe', + 'cygwin' => '.exe', + 'miktex' => '.exe' + ); + my $candidates_ref = $candidates{$system}; + my $exe = $Config{'_exe'}; + $exe = $exe{$system} unless defined $exe; + my @path = File::Spec->path(); + my $found = 0; + foreach my $candidate (@$candidates_ref) { + foreach my $dir (@path) { + my $file = File::Spec->catfile($dir, "$candidate$exe"); + if (-x $file) { + $::opt_gscmd = $candidate; + $found = 1; + print "* Found ($candidate): $file\n" if $Verbose; + last; + } + print "* Not found ($candidate): $file\n" if $Verbose; + } + last if $found; + } + if (not $found and $Win) { + $found = SearchRegistry(); + } + if ($found) { + print "* Autodetected ghostscript command: $::opt_gscmd\n" if $Verbose; + } + else { + $::opt_gscmd = $$candidates_ref[0]; + print "* Default ghostscript command: $::opt_gscmd\n" if $Verbose; + } +} + +sub SearchRegistry () { + my $found = 0; + eval 'use Win32::TieRegistry qw|KEY_READ REG_SZ|;'; + if ($@) { + if ($Verbose) { + print "* Registry lookup for Ghostscript failed:\n"; + my $msg = $@; + $msg =~ s/\s+$//; + foreach (split /\r?\n/, $msg) { + print " $_\n"; + } + } + return $found; + } + my $open_params = {Access => KEY_READ(), Delimiter => '/'}; + my $key_name_software = 'HKEY_LOCAL_MACHINE/SOFTWARE/'; + my $current_key = $key_name_software; + my $software = new Win32::TieRegistry $current_key, $open_params; + if (not $software) { + print "* Cannot find or access registry key `$current_key'!\n" + if $::opt_verbose; + return $found; + } + print "* Search registry at `$current_key'.\n" if $Verbose; + my %list; + foreach my $key_name_gs (grep /Ghostscript/i, $software->SubKeyNames()) { + $current_key = "$key_name_software$key_name_gs/"; + print "* Registry entry found: $current_key\n" if $Verbose; + my $key_gs = $software->Open($key_name_gs, $open_params); + if (not $key_gs) { + print "* Cannot open registry key `$current_key'!\n" if $Verbose; + next; + } + foreach my $key_name_version ($key_gs->SubKeyNames()) { + $current_key = "$key_name_software$key_name_gs/$key_name_version/"; + print "* Registry entry found: $current_key\n" if $Verbose; + if (not $key_name_version =~ /^(\d+)\.(\d+)$/) { + print " The sub key is not a version number!\n" if $Verbose; + next; + } + my $version_main = $1; + my $version_sub = $2; + $current_key = "$key_name_software$key_name_gs/$key_name_version/"; + my $key_version = $key_gs->Open($key_name_version, $open_params); + if (not $key_version) { + print "* Cannot open registry key `$current_key'!\n" if $Verbose; + next; + } + $key_version->FixSzNulls(1); + my ($value, $type) = $key_version->GetValue('GS_DLL'); + if ($value and $type == REG_SZ()) { + print " GS_DLL = $value\n" if $Verbose; + $value =~ s|([\\/])([^\\/]+\.dll)$|$1gswin32c.exe|i; + my $value64 = $value; + $value64 =~ s/gswin32c\.exe$/gswin64c.exe/; + if ($archname =~ /mswin32-x64/i and -f $value64) { + $value = $value64; + } + if (-f $value) { + print " EXE found: $value\n" if $Verbose; + } + else { + print " EXE not found!\n" if $Verbose; + next; + } + my $sortkey = sprintf '%02d.%03d %s', + $version_main, $version_sub, $key_name_gs; + $list{$sortkey} = $value; + } + else { + print " Missing key `GS_DLL' with type `REG_SZ'!\n" if $Verbose; + } + } + } + foreach my $entry (reverse sort keys %list) { + $::opt_gscmd = $list{$entry}; + print "* Found (via registry): $::opt_gscmd\n" if $Verbose; + $found = 1; + last; + } + return $found; +} + +find_ghostscript(); + +if ($Win and $::opt_gscmd =~ /\s/) { + $::opt_gscmd = "\"$::opt_gscmd\""; +} +# end GS search + open my $LOGfile,'>', "$tempDir/$name.plog"; # our own log file LOG ("Parameters:"); - LOG ("==> imageDir = $imageDir"); - LOG ("==> Iext = $Iext"); - LOG ("==> DPI = $DPI"); - LOG ("==> PS2 = $PS2"); - LOG ("==> Iscale = $Iscale"); - LOG ("==> tempDir = $tempDir"); - LOG ("==> verbose = $verbose"); - LOG ("==> clear = $clear"); - LOG ("==> noImages = $noImages"); - LOG ("==> single = $single"); - LOG ("==> runBibTeX= $runBibTeX"); - LOG ("==> runBiber = $runBiber"); - LOG ("==> ppm = $ppm"); - LOG ("==> eps = $eps"); - LOG ("==> jpg = $jpg"); - LOG ("==> png = $png"); - LOG ("==> files = $files"); - LOG ("==> xetex = $xetex"); + LOG ("==> imageDir = $imageDir"); + LOG ("==> dpi = $DPI"); + LOG ("==> tempDir = $tempDir"); + LOG ("==> Verbose = $Verbose"); + LOG ("==> clear = $clear"); + LOG ("==> noImages = $noImages"); + LOG ("==> noSource = $noSource"); + LOG ("==> nopreview = $nopreview"); + LOG ("==> runBibTeX = $runBibTeX"); + LOG ("==> runBiber = $runBiber"); + LOG ("==> ppm = $ppm"); + LOG ("==> eps = $eps"); + LOG ("==> jpg = $jpg"); + LOG ("==> png = $png"); + LOG ("==> svg = $svg"); + LOG ("==> xetex = $xetex"); if ($runBibTeX && $runBiber) { LOG ("!!! you cannot run BibTeX and Biber at the same document ..."); @@ -175,25 +402,23 @@ if ($eps) { } if ($jpg) { LOG ("Generate .jpg files ..."); - $ppm = 1; - $jpg = 1; + $jpg = 1; } if ($png) { LOG ("Generate .png files ..."); - $ppm = 1; - $png = 1; + $png = 1; } -if ($files) { - LOG ("Generate .tex images files ..."); - $files=1; +if ($svg) { + LOG ("Generate .svg files ..."); + $svg = 1; } if ($all) { - LOG ("Generate all images eps/pdf/files and clear..."); - $eps =$ppm=$jpg=$png=$clear = 1; + LOG ("Generate images eps/pdf/files and clear..."); + $eps =$ppm=$jpg=$png=$svg=$clear = 1; } -if ($single) { - LOG ("single mode generate images files ..."); - $single= 1; +if ($nopreview) { + LOG ("nopreview mode generate images files ..."); + $nopreview= 1; } if ($xetex) { LOG ("Compiling using XeLaTeX ..."); @@ -201,68 +426,317 @@ if ($xetex) { } if ($noImages ) { LOG ("no create images"); - $single= 0; + $nopreview= 0; + } +if ($noSource) { + LOG ("Delete all source files"); + $noSource= 1; + } + +#----------------------------- Parte 1 --------------------------------- +# Comentamos los bloques PST dentro de verbatim de todo el archivo +# Abrimos el archivo +my $InputFilename = shift; +my @lineas; +{ + open my $FILE,'<:crlf',"$InputFilename"; + @lineas = <$FILE>; + close $FILE; +} + +# Creamos un hash con los cambios +my %cambios = ( + '\pspicture' => '\TRICKS', + '\endpspicture' => '\ENDTRICKS', + + '\begin{PSTexample' => '\begin{PSTEXAMPLE', + '\end{PSTexample' => '\end{PSTEXAMPLE', + + '\begin{pspicture' => '\begin{TRICKS', + '\end{pspicture' => '\end{TRICKS', + + '\begin{postscript}' => '\begin{POSTRICKS}', + '\end{postscript}' => '\end{POSTRICKS}', + + '\begin{document}' => '\begin{DOCTRICKS}', + '\end{document}' => '\end{DOCTRICKS}' +); + +# Definimos los entonos verbatim donde comentaremos +my $ENTORNO = qr/(?: (v|V)erbatim\*?| LTXexample | PSTcode |$other\*? | tcblisting\*? | spverbatim | minted | lstlisting | alltt | comment\*? | xcomment)/xi; +# +my $DEL; + +my $tcbverb = qr/\\(?:tcboxverb|myverb)/; + +my $arg_brac = qr/(?:\[.+?\])?/; + +my $arg_curl = qr/\{(.+)\}/; # ATENCIÓN + +for (@lineas) { + if (/^\\begin\{($ENTORNO)(?{ $DEL = "\Q$^N" })\}/ .. /^\\end\{$DEL\}/) { + while (my($busco, $cambio) = each %cambios) { + s/\Q$busco\E/$cambio/g; + } } + elsif (m/$tcbverb$arg_brac$arg_curl/) { + while (my($busco, $cambio) = each %cambios) { + s/\Q$busco\E/$cambio/g; + } + } #close elsif + } + +# Escritura del resultado +open my $SALIDA, '>', "$tempDir/$name-tmp$ext"; +print $SALIDA @lineas; +close $SALIDA; + +#--------------------------------Parte 2-------------------------------- +# Comentamos el texto en verbatim a lo largo del cuerpo +open my $ENTRADA, '<', "$tempDir/$name-tmp$ext"; +my $archivo; +{ + local $/; + $archivo = <$ENTRADA>; +} +close $ENTRADA; + +## Partición del documento +my($cabeza,$cuerpo,$final) = $archivo =~ m/\A (.+? ^\\begin{document}) (.+) (^ \\end{document} .*) \z/msx; + +## Variables y constantes +my $no_del = "\0"; +my $del = $no_del; + +## Reglas +my $llaves = qr/\{ .+? \} /x; +my $no_corchete = qr/(?:\[ .+? \])? /x; +my $delimitador = qr/\{ (?<del>.+?) \} /x; +my $spverb = qr/spverb [*]? /ix; +my $verb = qr/(v|V)erb [*]? /ix; +my $lst = qr/lstinline (?!\*) $no_corchete /ix; +my $mint = qr/mint (?!\*) $no_corchete $llaves /ix; +my $marca = qr/\\ (?:$verb | $lst | $mint ) (\S) .+? \g{-1} /x; +my $comentario = qr/^ \s* \%+ .+? $ /mx; +my $definedel = qr/\\ (?: DefineShortVerb | lstMakeShortInline ) $no_corchete $delimitador /ix; +my $indefinedel = qr/\\ (?: UndefineShortVerb | lstDeleteShortInline) $llaves /ix; + +## Cambiar +while ($cuerpo =~ + / $marca + | $comentario + | $definedel + | $indefinedel + | $del .+? $del # delimitado + /pgmx) { + + my($pos_inicial, $pos_final) = ($-[0], $+[0]); # posiciones + my $encontrado = ${^MATCH}; # lo encontrado + + if ($encontrado =~ /$definedel/){ # definimos delimitador + $del = $+{del}; + $del = "\Q$+{del}" if substr($del,0,1) ne '\\'; # es necesario "escapar" el delimitador + } + elsif($encontrado =~ /$indefinedel/) { # indefinimos delimitador + $del = $no_del; + } + else { # aquí se hacen los cambios + while (my($busco, $cambio) = each %cambios) { + $encontrado =~ s/\Q$busco\E/$cambio/g; # es necesario escapar $busco + } + substr $cuerpo, $pos_inicial, $pos_final-$pos_inicial, $encontrado; # insertamos los nuevos cambios + + pos($cuerpo)= $pos_inicial + length $encontrado; # re posicionamos la siguiente búsqueda + } +} + + +# Poner el atributo añadido a \begin{PSTexample} +while ($cuerpo =~ /^\\begin\{PSTexample\}(\[.+?\])?/gsm) { + + my $corchetes = $1; + my($pos_inicial, $pos_final) = ($-[1], $+[1]); # posición donde están los corchetes + + if (not $corchetes) { + $pos_inicial = $pos_final = $+[0]; # si no hay corchetes, nos ponemos al final de \begin + } + + if (not $corchetes or $corchetes =~ /\[\s*\]/) { # si no hay corchetes, o están vacíos, + $corchetes = "[$graphics-$exacount}]"; # ponemos los nuestros + } + else { # si sí hay corchetes, + $corchetes =~ s/\]/,$graphics-$exacount}]/; # lo agregamos al final, dentro de los corchetes + } + + substr($cuerpo, $pos_inicial, $pos_final - $pos_inicial) = $corchetes; + pos($cuerpo) = $pos_inicial + length $corchetes; # reposicionamos la búsqueda de la exp. reg. +} +continue { + $exacount++; +} + +#----------------------- Extract PSTexample files ---------------------- + +while ($cuerpo =~ /^\\begin\{PSTexample\}\[.+?(?<nombre_archivo_secundario>$imageDir\/.+?-\d+)\}\](?<contenido>.+?)(?=^\\end\{PSTexample})/gsm) { + open my $SALIDA, '>', "$+{'nombre_archivo_secundario'}$ext"; + print $SALIDA <<"EOC"; +$cabeza\n\\thispagestyle{empty}$+{'contenido'}\\end{document} +EOC + close $SALIDA; +} +# Now, deault way join all PSTexample files +if(!$nopreview){ +if (-e "$imageDir/$name-exa-1$ext") { +# print "PSTexample environment found\n"; +# 1- Leer los PSTexa files +my @pstexafiles = glob("$imageDir/$name-exa-*$ext"); + +# 2- Ordenar según el índice y extención +@pstexafiles = + map { $_->[1] } + sort { $a->[0] <=> $b->[0] } + map { [ ($_ =~ /(\d+$ext)/), $_ ] } + @pstexafiles; + +# 3- Bucle para leer las secciones +my @almacen; +for my $exafile (@pstexafiles) { + + # 3.1- Leer el archivo + open my $FH, '<', $exafile; # + my $tex = join q{}, <$FH>; # + close $FH; + + # 3.2- Extraer la parte que nos interesa + my($pedazo) = $tex =~ m/\\thispagestyle\{empty\}\s*(.+?)\s*\\end\{document\}/sm; + + # 3.3- Almacenamos, si hemos encontrado algo + push @almacen, $pedazo if $pedazo; +} + +# 4- Salida +open my $SALIDA, '>', "$tempDir/$name-exa$ext"; + +print $SALIDA "$cabeza\n"; + +my $fig = 1; +for my $item (@almacen) { + print $SALIDA "\\thispagestyle\{empty\}\n"; + print $SALIDA $item; + print $SALIDA "%fig . $fig\n"; + print $SALIDA "\\newpage\n"; + $fig++; +} + +print $SALIDA '\end{document}'; +close $SALIDA; + } # close join exa files (if exist) +} # close nopreview + +### Escribimos en el mismo archivo con los cambios en verbatim +open my $SALIDA, '>', "$tempDir/$name-tmp$ext"; +print $SALIDA "$cabeza$cuerpo$final"; +close $SALIDA; + +## Comentamos pst-exa en el preambulo, para no entorpecer a preview +$cabeza =~ +s/(?<exapack>\\usepackage\[(swpl|tcb)\]\{pst-exa\})/%$+{exapack}/gsmx; +## Eliminamos PSTexample y PSTcode para no entorpecer a preview +$cuerpo =~ +s/(?<initexa>\\begin\{PSTexample\})(?<code>.+?)(?<endexa>\\end\{PSTexample\})//gsmx; +$cuerpo =~ +s/(?<initexa>\\begin\{PSTcode\})(?<code>.+?)(?<endexa>\\end\{PSTcode\})//gsmx; + +## Escribimos el archivo completo para las figuras +if(!$nopreview){ +open my $OUTFILE, '>', "$tempDir/$name-pst$ext"; +print $OUTFILE "\\AtBeginDocument\{\n"; +if($xetex){ +print $OUTFILE "\\RequirePackage\[xetex,active,tightpage\]\{preview\}\n"; +} +else{ +print $OUTFILE "\\RequirePackage\[active,tightpage\]\{preview\}\n"; +} +print $OUTFILE "\\renewcommand\\PreviewBbAdjust\{-60pt -60pt 60pt 60pt\}%\n"; +print $OUTFILE "\\PreviewEnvironment\{pspicture\}\n"; +print $OUTFILE "\\PreviewEnvironment\{postscript\}\}\n"; +print $OUTFILE "$cabeza$cuerpo\\end\{document\}"; +close $OUTFILE; +} +## Escribimos en el mismo archivo, convirtiendo PSTexample +## esta sera el archivo de entrada en el resto del script + +my @lineas; +{ + open my $FILE, "$tempDir/$name-tmp$ext"; + @lineas = <$FILE>; + close $FILE; +} + +my $PSTexample = qr/(?: PSTexample | PSTcode )/xi; +# +my $DEL; + +for (@lineas) { + if (/^\\begin\{($PSTexample)(?{ $DEL = "\Q$^N" })\}/ .. /^\\end\{$DEL\}/) { + while (my($busco, $cambio) = each %cambios) { + s/\Q$busco\E/$cambio/g; + } + } + } + +# Escritura del resultado +open my $SALIDA, '>', "$tempDir/$name-tmp$ext"; +print $SALIDA @lineas; +close $SALIDA; +# end code for pstexample my $imgNo = 1; # internal image counter -#----------- single mode, no need pdftk ---------------------- -if ($single) { +#----------------- nopreview mode, dont'n need gs ---------------------- +if ($nopreview) { LOG ("Running on [$path][$name][$ext]"); open my $FILE,'<', "$TeXfile" ; # the source -LOG ("single mode generate images..."); -if (-d $imageDir) { LOG ("$imageDir exists") } -else { mkdir("$imageDir", 0744) ;} +if (!$noImages ) { +LOG ("nopreview mode generate images..."); savePreamble($name); -runXPD($name); runFile($name); +runPSTimg($name); close $FILE; # close source file close $LOGfile; -}#---------------- Default way, using pdftk -------------- + } +} +#----------------------- Default way, using gs ------------------------- else{ LOG ("Running on [$path][$name][$ext]"); open my $FILE,'<', "$TeXfile" ; # the source if (!$noImages ) { -if (-d $imageDir) { LOG ("$imageDir exists") } -else { mkdir("$imageDir", 0744) ; -LOG ("Imagedir created"); } -LOG ("go to savePreamble ... "); +LOG ("Using gs for split images ... "); savePreamble($name); -runXPD($name); runFile($name); +runPSTimg($name); LOG ("done!\n go to runFile ..."); LOG ("done!"); close $FILE; # close source file close $LOGfile; -}# !noImages -} -# Create xpdfrc conf for silent output pdftops/pdftoppm mesagge in windows + }# !noImages +}# close -sub runXPD{ -if ($^O eq 'MSWin32'){ -open my $ppmconf, '>', "$tempDir/xpd"; -print $ppmconf <<'EOH'; -errQuiet yes -EOH -close $ppmconf; - } -} -# end fix -# create a preamble file -# if we have a \input command inside the preamble, it doesn't hurt, we need -# it anyway for the postscript files and the pdf one. -# ----------------- Save Preamble --------------------- +#-------------------------- Save Preamble ------------------------------ +# Now create a preamble file if we have a \input command inside the +# preamble, it doesn't hurt, we need it anyway for the postscript +# files and the pdf one. sub savePreamble { my $filename = pop; # get the file name LOG ("----- Start Preamble -----"); open my $FILEp,'>',"$tempDir/$filename.preamble"; -open my $FILE, '<', "$name.tex"; +open my $FILE, '<', "$tempDir/$name-tmp$ext"; while (<$FILE>) { # read all until \begin{document} my $i = index($_,"begin{document}"); if ($i > 0) { if ($i > 1) { print $FILEp substr($_,0,--$i); } # write all until \begin{document} - if ($single) { + if ($nopreview) { print $FILEp "\\newenvironment{postscript}{}{}\n"; print $FILEp "\\pagestyle{empty}\n"; } @@ -277,30 +751,25 @@ else { } close $FILE; close $FILEp; - if ( $verbose ) { LOG("<-----Preamble<----"); } - return; } - +# Search in source-parser file sub searchPS { # search the PostScript parts - my @PS = (); # single PS sequence - my @PStotal = (); # all PS sequences as list of arrays + my @PS = (); # nopreview PS sequence + my @PStotal = (); # all PS sequences as list of arrays my $depth = -1; # counts nested macros my $type = -1; # -1-> none; 1->PST; 2->PS; - my $EndDocument = 0;# ignore all after \end{document} + my $EndDocument = 0; # ignore all after \end{document} my $iVerb = 0; # test for verbatim or lstlisting environment, must be ignored - open my $FILE, '<', "$name.tex"; - while (<$FILE>) { # scan the input file + open my $FILE, '<', "$tempDir/$name-tmp$ext"; + while (<$FILE>) { # scan the input file if (!$EndDocument) { - chomp; # delete EOL character + chomp; # delete EOL character my $line = $_; # save line if ( !$iVerb ) { - $iVerb = ((index($line,"begin{verbatim}") > 0) - or (index($line,"begin{lstlisting}") > 0) - or (index($line,"begin{Verbatim}") > 0) - or (index($line,"begin{verbatim*}") > 0)); - } # do nothing until \end{verbatim} + $iVerb = ((index($line,"begin{verbatim}") > 0) or ( index($line,"begin{lstlisting}") > 0)); + } # do nothing until \end{verbatim} if ( !$iVerb ) { - my $iPS = index($line,"begin{postscript}"); + my $iPS = index($line,"begin{postscript}"); my $iPST = index($line,"begin{pspicture*}"); if ($iPST < 0) { $iPST = index($line,"begin{pspicture}"); } # alternative if ($iPST < 0) { $iPST = index($line,"pspicture"); } # alternative \pspicture... @@ -331,11 +800,11 @@ sub searchPS { # search the PostScript parts $depth--; if ($depth < 0) { $type = -1; - if (index($line,"endpspicture") > 0) # add line, depends to type - { push @PS,substr($line,0,$iPST+12); } # \endpspicture + if (index($line,"endpspicture") > 0) # add line, depends to type + { push @PS,substr($line,0,$iPST+12); } # \endpspicture elsif (index($line,"pspicture*") > 0) { push @PS,substr($line,0,$iPST+15); }# \end{pspicture} - else { push @PS,substr($line,0,$iPST+14); } # \end{pspicture} + else { push @PS,substr($line,0,$iPST+14); } # \end{pspicture} LOG ("searchPS: set \$type=$type"); push @PStotal,[@PS]; # add PS sequence LOG ("---->PS---->\n@PS\n<----PS<----"); @@ -354,13 +823,10 @@ sub searchPS { # search the PostScript parts } my $i = index($line,"end{document}"); if ($i > 0) { $EndDocument++; LOG("EndDocument in searchPS"); } - } # if ( $iVerb ) - if (( index($line,"end{verbatim}") > 0 ) - or ( index($line,"end{lstlisting}") > 0 ) - or ( index($line,"end{Verbatim}") > 0 ) - or ( index($line,"end{verbatim*}") > 0 )) { $iVerb = 0; } + } # if ( $iVerb ) + if (( index($line,"end{verbatim}") > 0 ) or ( index($line,"end{lstlisting}") > 0 )) { $iVerb = 0; } }} - if ( $verbose ) { + if ( $Verbose ) { LOG("---->PStotal---->"); for my $aref ( @PStotal ) { my @a = @$aref; @@ -370,62 +836,16 @@ sub searchPS { # search the PostScript parts LOG ("<----PStotal<----"); } close $FILE; - return @PStotal; # return all PS sequences + return @PStotal; # return all PS sequences } -# Creating file.tex and .pdf(eps,ppm) for images in single mode -sub runsingle{ - my $filename = pop; - -if ($xetex){ - system("xelatex -interaction=batchmode $filename"); - system("pdfcrop -margins 1 -xetex $filename.pdf $imageDir/$filename-$imgNo.pdf"); - } -else{ - system("latex -interaction=batchmode $filename"); - system("dvips -q -Ppdf $filename"); - system("ps2pdf $PS2 $filename.ps"); - system("pdfcrop -margins 1 $filename.pdf $imageDir/$filename-$imgNo.pdf"); - } -if ($files){ - copy("$filename.tex", "$imageDir/$filename-$imgNo.tex"); - } - -if ($eps) { - if ($^O eq 'MSWin32'){ - system("pdftops -cfg $tempDir/xpd -q -level3 -eps $imageDir/$filename-$imgNo.pdf $imageDir/$filename-$imgNo.eps"); - } - else{ - system("pdftops -q -level3 -eps $imageDir/$filename-$imgNo.pdf $imageDir/$filename-$imgNo.eps"); - } - } -if ($ppm) { - if ($^O eq 'MSWin32'){ - system("pdftoppm -cfg xpd -q -r $DPI $imageDir/$filename-$imgNo.pdf $imageDir/$filename-$imgNo"); - } -else{ - system("pdftoppm -q -r $DPI $imageDir/$filename-$imgNo.pdf $imageDir/$filename-$imgNo"); - } - } - - $imgNo=$imgNo+1; -} -#------------------- Copy files.tex for images in default mode --------- -sub runTeX{ - my $filename = pop; - if ($files){ - copy("$filename.tex", "$imageDir/$filename-$imgNo.tex"); -} - $imgNo=$imgNo+1; -} - -#------------------ Create files.tex for images -------------- +#---------------------- Create files.tex for images -------------------- sub runFile { my $filename = pop; my @PSarray = searchPS(); - if ( $verbose ) { + if ( $Verbose ) { LOG("---->PSarray---->"); for my $aref ( @PSarray ) { my @a = @$aref; @@ -439,71 +859,199 @@ sub runFile { for my $aref ( @PSarray ) { my @PS = @$aref; open my $FILEp,'<',"$tempDir/$filename.preamble"; - open my $FILEsub,'>',"$tempDir/$filename-fig.tex"; + open my $FILEsub,'>',"$tempDir/$filename-fig$ext"; while (<$FILEp>) {print $FILEsub $_; } print $FILEsub "\\begin{document}\n"; - if ( $verbose ) { LOG("\@PS: $_"); } + if ( $Verbose ) { LOG("\@PS: $_"); } foreach ( @PS ) { print $FILEsub "$_\n"; } print $FILEsub "\\end{document}"; close $FILEsub; close $FILEp; - if ($single) { - runsingle("$tempDir/$filename-fig"); - } - else{runTeX("$tempDir/$filename-fig");} + runTeX("$tempDir/$filename-fig"); } } LOG ("runpdfTeX ... "); runpdfTeX("$path$name",$name); LOG ("all finished ... :-)"); -# ----------------Renaming ppm need for correct name -if(!$noImages){ - my $dren = "$tempDir/$imageDir"; - my $fich = ''; - my $ppmren = ''; - my $PPMno = 1; - my $renNo = 1; - if(opendir(DIR,$dren)){ - foreach (readdir DIR){ - $fich = $_; - if ( $fich =~ /($name-fig-)(\d+|\d+[-]\d+).ppm/) { - my $renNo = int($2); - my $newname="$1$renNo.ppm"; - $ppmren = rename("$dren/$fich","$dren/$newname"); - if($jpg){ - system("convert $imageDir/$name-fig-$renNo.ppm $imageDir/$name-fig-$renNo.jpg"); - } - if($png){ - system("convert $imageDir/$name-fig-$renNo.ppm $imageDir/$name-fig-$renNo.png"); +#------------------- Copy files.tex for images in default mode --------- +sub runTeX{ + my $filename = pop; + copy("$filename$ext", "$imageDir/$filename-$imgNo$ext"); + $imgNo=$imgNo+1; +} +#------------------- Create images in PDF fromat ------------------------ +sub runPSTimg() { +# Option for gs +my $opt_gs_split='-q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dBATCH '; + +# Option for pdfcrop +my $opt_pdfcrop="-margins $margins"; + +# Abrimos el directorio y creamos las imagenes en formato PDF +if ($nopreview) { +opendir(my $DIR, $imageDir); + while (readdir $DIR) { +if (/(?<nombre>$name-(fig|exa)-\d+)(?<extension>$ext)/) { +if ($xetex){ + system("xelatex -interaction=batchmode -output-directory=$imageDir $imageDir/$+{nombre}$+{extension}"); + system("pdfcrop $opt_pdfcrop -xetex $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}.pdf"); + } # close xelatex +else{ + system("latex -interaction=batchmode -output-directory=$imageDir $imageDir/$+{nombre}$+{extension}"); + system("dvips -q -P pdf -o $imageDir/$+{nombre}.ps $imageDir/$+{nombre}.dvi"); + system("ps2pdf $imageDir/$+{nombre}.ps $imageDir/$+{nombre}.pdf"); + system("pdfcrop $opt_pdfcrop $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}.pdf"); + } # close latex>dvips>ps2pdf + } # close find regex in nopreview +} # close while +closedir $DIR; +} # close $nopreview +# Cerramos y abrimos con nopreview (gs por defecto) +else{ +# Compilamos PSTexa usando gs +if (-e "$tempDir/$name-exa$ext") { +if ($xetex){ + system("xelatex -interaction=batchmode -output-directory=$imageDir $tempDir/$name-exa$ext"); + system("pdfcrop $opt_pdfcrop -xetex $imageDir/$name-exa.pdf $imageDir/$name-exa.pdf"); + } # xelatex +else{ + system("latex -interaction=batchmode -output-directory=$imageDir $tempDir/$name-exa$ext"); + system("dvips -q -Ppdf -o $imageDir/$name-exa.ps $imageDir/$name-exa.dvi"); + system("ps2pdf -dPDFSETTINGS=/prepress $imageDir/$name-exa.ps $imageDir/$name-exa.pdf"); + system("pdfcrop $opt_pdfcrop $imageDir/$name-exa.pdf $imageDir/$name-exa.pdf"); + } # close latex>dvips>ps2pdf +system("$::opt_gscmd $opt_gs_split -sOutputFile=$imageDir/$name-exa-%1d.pdf $imageDir/$name-exa.pdf"); + +# Eliminamos los fuentes +if ($clear) { + unlink "$imageDir/$name-exa.pdf"; + unlink "$tempDir/$name-exa$ext"; + } +} # close check file exist + +# Compilamos las imagenes y las separamos usando gs +if (-e "$imageDir/$name-fig-1$ext") { +if ($xetex){ + system("xelatex -interaction=batchmode -output-directory=$imageDir $tempDir/$name-pst$ext"); + system("pdfcrop $opt_pdfcrop -xetex $imageDir/$name-pst.pdf $imageDir/$name-pst.pdf"); + } # xelatex +else{ + system("latex -interaction=batchmode -output-directory=$imageDir $tempDir/$name-pst$ext"); + system("dvips -q -Ppdf -o $imageDir/$name-pst.ps $imageDir/$name-pst.dvi"); + system("ps2pdf -dPDFSETTINGS=/prepress $imageDir/$name-pst.ps $imageDir/$name-pst.pdf"); + system("pdfcrop $opt_pdfcrop $imageDir/$name-pst.pdf $imageDir/$name-pst.pdf"); + } # close latex>dvips>ps2pdf +system("$::opt_gscmd $opt_gs_split -sOutputFile=$imageDir/$name-fig-%1d.pdf $imageDir/$name-pst.pdf"); +if ($clear) { +unlink "$imageDir/$name-pst.pdf"; +unlink "$tempDir/$name-pst$ext"; +unlink "$tempDir/$name-fig$ext"; + } # end clear + } # close check file exist +} # close !nopreview (ghostscript) +#--------------------------- Clear aux files --------------------------- +if ($clear) { +my @del_tmp; +find(\&del_aux_tex, $imageDir); +sub del_aux_tex{ +my $auximgfile = $_; + +# search .(aux|dvi|log|ps) +if(-f $auximgfile && $auximgfile =~ /\.(aux|dvi|log|ps)$/){ +push @del_tmp, $File::Find::name; + } +} +unlink @del_tmp; +}# end clear aux + +# Create xpdfrc conf for silent output pdftops/pdftoppm mesagge +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + +if ($eps or $ppm) { +open my $ppmconf, '>', "$tempDir/xpd"; +print $ppmconf <<'EOH'; +errQuiet yes +EOH +close $ppmconf; + } +}# end fix for windows + +# options for other images type using ghostscript +my $opt_gs_raw='-dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -dBATCH '; + +# Creamos las imagenes en todos los formatos distintos a PDF +opendir(my $DIR, $imageDir); +while (readdir $DIR) { +if (/(?<nombre>$name-(fig|exa)-\d+)(?<extension>\.pdf)/) { + +# PNG format +if ($png) { +system("$::opt_gscmd -q -sDEVICE=pngalpha -r$DPI $opt_gs_raw -sOutputFile=$imageDir/$+{nombre}.png $imageDir/$+{nombre}.pdf"); + } + +# JPEG format +if ($jpg) { +system("$::opt_gscmd -q -sDEVICE=jpeg -r$DPI -dJPEGQ=100 $opt_gs_raw -sOutputFile=$imageDir/$+{nombre}.jpg $imageDir/$+{nombre}.pdf"); + } + +# SVG format +if ($svg) { + system("pdf2svg $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}.svg"); + } + +# EPS format +if ($eps) { + if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftops -cfg $tempDir/xpd -q -level3 -eps $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}.eps"); + }else{ + system("pdftops -q -level3 -eps $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}.eps"); } + } # close EPS + +# PPM format +if ($ppm) { + if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ + system("pdftoppm -cfg $tempDir/xpd -q -r $DPI $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}"); + }else{ + system("pdftoppm -q -r $DPI $imageDir/$+{nombre}.pdf $imageDir/$+{nombre}"); } + } # close PPM + } # close finde regex +} # close while +closedir $DIR; #close dir + +## Renombramos los ppm +if ($ppm) { +if (opendir(DIR,$dir)) { # abro el directorio + while (my $oldname = readdir DIR) { # lo recorro + # el nuevo nombre es fruto de una sustitución + my $newname = $oldname =~ s/^($name-(fig|exa)-\d+)(-\d+).ppm$/$1 . ".ppm"/re; + + if ($oldname ne $newname) { # comprobación + rename("$dir/$oldname", "$dir/$newname"); # renombro } - } -closedir DIR; - if($clear){ - unlink <$imageDir/*.ppm>; - } -}# end renaming ppm + } + closedir DIR; + } # close rename ppm + } # close ppm +} # cerramos runPSTimg -#------------------ Replace pst enviroment for images--------- +#--------------------- Replace PST enviroment for images---------------- sub runpdfTeX() { my ($name,$pdfname) = @_; - open my $PDF,'>',"$tempDir/$pdfname-pdf.tex"; - open my $FILE,'<',"$name.tex"; + open my $PDF,'>',"$tempDir/$pdfname-pdf$ext"; + open my $FILE,'<',"$tempDir/$name-tmp$ext"; my $ignore = 0; my $IMGno = 1; my $depth = -1; my $type = -1; my $EndDocument = 0; # ignore all after \end{document} my $iVerb = 0; - while (<$FILE>) { # scan the input file + while (<$FILE>) { # scan the input file if ( !$iVerb ) { - $iVerb = ((index($_,"begin{verbatim}") > 0) - or (index($_,"begin{lstlisting}") > 0) - or (index($_,"begin{Verbatim}") > 0) - or (index($_,"begin{verbatim*}") > 0)); + $iVerb = ((index($_,"begin{verbatim}") > 0) or ( index($_,"begin{lstlisting}") > 0)); } # do nothing until \end{verbatim}|| \end{lstlisting} if ( !$iVerb ) { my $i = index($_,"end{document}"); @@ -514,7 +1062,7 @@ sub runpdfTeX() { $type = 2; $ignore = 1; if ($iPS > 1) { print $PDF substr($_,0,--$iPS); } # add preceeding text - print $PDF "\\includegraphics[scale=$Iscale]{$pdfname-fig-$IMGno}"; # use pdfname + print $PDF "\\includegraphics[scale=1]{$pdfname-fig-$IMGno}"; # use pdfname $IMGno=$IMGno+1; } # postscript env if ( $type < 2 ) { @@ -528,7 +1076,7 @@ sub runpdfTeX() { LOG("Increase depth: $depth"); if ( $depth == 0 ) { if ($iPST > 1) { print $PDF substr($_,0,--$iPST); } # add preceeding text - print $PDF "\\includegraphics[scale=$Iscale]{$pdfname-fig-$IMGno}"; # use \graphicspath + print $PDF "\\includegraphics[scale=1]{$pdfname-fig-$IMGno}"; # use \graphicspath $IMGno=$IMGno+1; LOG("Increase Image counter: $IMGno"); } @@ -538,16 +1086,16 @@ sub runpdfTeX() { if ( $type == 2 ) { # postscript env my $iPS = index($_,"end{postscript}"); if ($iPS > 0) { - print $PDF substr($_,$iPS+15); # rest of line + print $PDF substr($_,$iPS+15); # rest of line $ignore = 0; $type=-1; } # end Scan } - elsif ( $type == 1 ) { # pspicture env + elsif ( $type == 1 ) { # pspicture env my $iPST = index($_,"end{pspicture*}"); if ($iPST < 0) { $iPST = index($_,"end{pspicture}"); } # alternative ... - if ($iPST < 0) { $iPST = index($_,"endpspicture"); } # alternative \endpspicture... - if ($iPST > 0) { # end Scan + if ($iPST < 0) { $iPST = index($_,"endpspicture"); } # alternative \endpspicture... + if ($iPST > 0) { # end Scan if (index($_,"endpspicture") > 0) # add rest of line, depends to type { print $PDF substr($_,$iPST+12); } # \endpspicture elsif (index($_,"pspicture*") > 0) @@ -559,172 +1107,202 @@ sub runpdfTeX() { } } } # if ( !$EndDocument ) - } - else { print $PDF $_; } # if ( $iVerb ) - if (( index($_,"end{verbatim}") > 0 ) - or ( index($_,"end{lstlisting}") > 0 ) - or ( index($_,"end{Verbatim}") > 0 ) - or ( index($_,"end{verbatim*}") > 0 )) { $iVerb = 0; } + } else { print $PDF $_; } # if ( $iVerb ) + if (( index($_,"end{verbatim}") > 0 ) or ( index($_,"end{lstlisting}") > 0 )) { $iVerb = 0; } } # while (<$FILE>) close $FILE; close $PDF; -# ------------- Create one file contain all pst (default mode) ---------------- -if (!$single==!$noImages){ -my ($name,$pdfname) = @_; -my @PSTarray = searchPS(); -my @pstfiles = glob("$imageDir/*.tex"); -@pstfiles = - map { $_->[1] } - sort { $a->[0] <=> $b->[0] } - map { [ ($_ =~ /(\d+)\.tex$/), $_ ] } - @pstfiles; -my @container; -for my $archivo (@pstfiles) { - - open my $FH, '<:crlf', $archivo; # EOL - my $tex = join q{}, <$FH>; # - close $FH; - my($pstimg) = $tex =~ m/\\begin\{document\}\n(.+?)\n\\end\{document\}/sm; - push @container, $pstimg if $pstimg; -} -open my $FILE,'<',"$tempDir/$name.preamble"; -open my $OUTPST,'>',"$tempDir/$name-pst.tex"; - while (<$FILE>) {print $OUTPST $_; } - print $OUTPST "\\newenvironment{postscript}{}{}\n"; - print $OUTPST "\\pagestyle{empty}\n"; - print $OUTPST "\\begin{document}\n"; -my $fig = 1; -for my $item (@container) { - print $OUTPST $item; - print $OUTPST "\n%fig" . "$fig\n"; - print $OUTPST "\\newpage\n"; - $fig++; +## Close generate file +if ($clear) { +unlink "$tempDir/$pdfname-tmp$ext"; +#unlink "$tempDir/$pdfname-fig$ext"; } - print $OUTPST "\\end{document}"; - close $OUTPST; - close $FILE; -# close all -# -------------------- Compiling File using pdftk ---------------------- -my ($name,$pdfname) = @_; -if ($xetex){ - system("xelatex -interaction=batchmode $tempDir/$pdfname-pst.tex"); - system("pdfcrop -xetex $tempDir/$name-pst.pdf $tempDir/$pdfname-pst.pdf"); - } +#------------------- Clean pstpack, reverse changes -------------------- +## Leer archivo +open my $INFILE, '<', "$tempDir/$pdfname-pdf$ext"; +my $IPDF; +{ + local $/; + $IPDF = <$INFILE>; +} +close $INFILE; + +## Constantes +my $BEGINDOC = quotemeta('\begin{document}'); +my $USEPACK = quotemeta('\usepackage'); +my $GRAPHICX = quotemeta('{graphicx}'); + +## Exp. Reg. + +my $CORCHETES = qr/\[ [^]]*? \]/x; +my $PALABRAS = qr/\b (?: pst-\w+ | pstricks (?: -add )? | psfrag |psgo |vaucanson-g| auto-pst-pdf | graphicx )/x; +my $FAMILIA = qr/\{ \s* $PALABRAS (?: \s* [,] \s* $PALABRAS )* \s* \}/x; + +## Dividir el archivo +my($cabeza, $cuerpo) = $IPDF =~ m/\A (.+?) ($BEGINDOC .+?) \z/msx; + +## Revisamos si esta cargado pst-exa +my $pstTcbload = 0; # Buscamos si esta cargado \usepackage[...]{pst-exa} +$pstTcbload = index($cabeza,"usepackage[tcb]{pst-exa}"); + +## Filtrado +# comentar +$cabeza =~ s/ ^ ($USEPACK $CORCHETES $GRAPHICX) /%$1/msxg; + +# eliminar líneas enteras +$cabeza =~ s/ ^ $USEPACK (?: $CORCHETES )? $FAMILIA \n//msxg; + +# eliminar palabras sueltas +$cabeza =~ s/ (?: ^ $USEPACK \{ | \G) [^}]*? \K (,?) \s* $PALABRAS (\s*) (,?) /$1 and $3 ? ',' : $1 ? $2 : ''/gemsx; + +## Añadir + +$cabeza .= <<"EXTRA"; +\\usepackage{graphicx} +\\graphicspath{{$imageDir/}} +\\usepackage{grfext} +\\PrependGraphicsExtensions*{.pdf} +EXTRA + +## Verificamos que exista el archivo +if (-e "$imageDir/$name-exa-1$ext") { +if ($pstTcbload > 1) { +# Cambiamos de swpl a tcb con una expresion regular +$cuerpo =~ s/(graphic=\{)\[(scale=\d*)\]($imageDir\/$pdfname-exa-\d*)\}/$1$2\}\{$3\}/gsmx; + +# Se añade la opción [tcb] al paquete pst-exa +$cabeza .= <<"EXTRA"; +\\usepackage[pdf,tcb]{pst-exa} +EXTRA +} # close if else{ - system("latex -interaction=batchmode $tempDir/$pdfname-pst"); - system("dvips -q -Ppdf $tempDir/$pdfname-pst"); - system("ps2pdf $PS2 $tempDir/$pdfname-pst.ps $tempDir/$pdfname-pst.pdf"); - system("pdfcrop -margins 1 $tempDir/$pdfname-pst.pdf $tempDir/$pdfname-pst.pdf"); +# print "Se añade la opción swpl al paquete pst-exa\n"; +$cabeza .= <<"EXTRA"; +\\usepackage[swpl]{pst-exa} +EXTRA + } +} # close regex for pst-exa pack + +### Clear PST content in preamble +$cabeza =~ s/\\usepackage\{\}/%delete by pst2pdf/gmsx; +$cabeza =~ s/^\\psset\{.+?\}/%\\psset delete by pst2pdf/gmsx; +$cabeza =~ s/\\SpecialCoor/%\\SpecialCoor delete by pst2pdf/gmsx; +$cabeza =~ s/^%CleanPST .+? %CleanPST/% Clean PST by pst2pdf/gmsx; + +### Delete extra psset{..} in body +$cuerpo =~ s/\\psset\{[^\}]+\}(\s*\\includegraphics\[scale=1\]\{$pdfname-fig-\d*\})/$1/gms; + +### Back +my %cambios = ( + '\TRICKS' => '\pspicture', + '\ENDTRICKS' => '\endpspicture', + '\begin{PSTEXAMPLE' => '\begin{PSTexample', + '\end{PSTEXAMPLE' => '\end{PSTexample', + '\begin{TRICKS' => '\begin{pspicture', + '\end{TRICKS' => '\end{pspicture', + '\begin{POSTRICKS}' => '\begin{postscript}' , + '\end{POSTRICKS}' => '\end{postscript}' , + '\begin{DOCTRICKS}' => '\begin{document}' , + '\end{DOCTRICKS}' => '\end{document}' +); + +## Recorremos el archivo y realizamos los cambios +while (my($busco, $cambio) = each %cambios) { + $cabeza =~ s/\Q$busco\E/$cambio/g; + $cuerpo =~ s/\Q$busco\E/$cambio/g; + } + +## Escribimos en el mismo archivo +open my $SALIDA, '>', "$tempDir/$pdfname-pdf$ext"; +print $SALIDA "$cabeza$cuerpo"; +close $SALIDA; +# + +my $runAgain = 0; + +if($xetex){ # xelatex mode +if ($noImages){ + print "The file $pdfname-pdf$ext are created (Xe)LaTeX\n"; } - system("pdftk $tempDir/$pdfname-pst.pdf burst output $imageDir/$pdfname-fig-\%1d.pdf"); -if ($eps){ -for my $fichero_pdf (<$imageDir/*.pdf>) { - (my $fichero_eps = $fichero_pdf) = s/ppm$/png/i; - if ($^O eq 'MSWin32'){ - system("pdftops -cfg xpd -q -level3 -eps $fichero_pdf $fichero_eps"); # conversión - } - else{ - system("pdftops -q -level3 -eps $fichero_pdf $fichero_eps"); # conversión - } - } +else{ + system("xelatex -interaction=batchmode $tempDir/$pdfname-pdf"); + print "Done, compiled $pdfname-pdf$ext using (Xe)LaTeX\n"; + } + } +else{ #pdflatex mode +if ($noImages){ + print "The file $pdfname-pdf$ext are created (pdf)LaTeX\n"; + } +else{ + system("pdflatex -interaction=batchmode $tempDir/$pdfname-pdf$ext"); + print "Done, compiled $pdfname-pdf$ext using (pdf)LaTeX\n"; + } } -if ($ppm){ - if ($^O eq 'MSWin32'){ - system("pdftoppm -cfg xpd -q -r $DPI $tempDir/$pdfname-pst.pdf $imageDir/$pdfname-fig"); + +if (-e "$tempDir/$pdfname-pdf.idx") { + system("makeindex $tempDir/$pdfname-pdf.idx"); + $runAgain++; + } +if ($runBibTeX && -e "$tempDir/$pdfname-pdf.aux") { + system("bibtex $tempDir/$pdfname-pdf"); + $runAgain++; + } +if ($runBiber && -e "$tempDir/$pdfname-pdf.bcf") { + system("biber $tempDir/$pdfname-pdf"); + $runAgain++; } - else{ - system("pdftoppm -q -r $DPI $tempDir/$pdfname-pst.pdf $imageDir/$pdfname-fig"); +if ($runAgain){ + if($xetex){ + system("xelatex -interaction=batchmode $tempDir/$pdfname-pdf"); + } + else{ + system("pdflatex -interaction=batchmode $tempDir/$pdfname-pdf"); } } +} #close sub run pdfTEX + +#----------------------------- Write LOG file -------------------------- +sub LOG() { + if ( $Verbose ) { print $LOGfile "@_\n"; } } +#-------------------------- Clear all tmp files ------------------------ +if ($clear) { -#---------------- Coment pst-package in file-pdf.tex for (pdf/Xe)LaTeX ---------------- - open my $IPDF,'<', "$tempDir/$pdfname-pdf.tex"; - undef $/; # read all file - my ($uno,$dos) = split(/\\begin\{document\}/,<$IPDF>,2); - close $IPDF; - - my @coment = split /\n/, $uno; # split in two - my @preamb; - - foreach my $line (@coment) { - chomp($line); - if(!$xetex){ - $line =~ s/\\usepackage(?:\[.+?\])?\{pst.+?}//g; # delete - $line =~ s/\\usepackage(?:\[.+?\])?\{psfr.+?}//g; # delete - $line =~ s/(\\usepackage(?:\[.+?\])?)\{auto-pst.+?}//g; # delete - $line =~ s/(\\usepackage(?:\[.+?\])?)\{vaucanson-.+?}//g; # delete - $line =~ s/(\\usepackage(?:\[.+?\])?)\{psgo}//g; # delete - } - $line =~ s/(\\usepackage(?:\[.+?\])?)\{graph/\%$1\{graph/g; # comment - next if $line =~ m/^\s*$/; - push(@preamb,$line);} # adding changes - -my $clean = join("\n", @preamb, "\\usepackage{grfext}\n\\\PrependGraphicsExtensions*{$Iext}\n\\usepackage{graphicx}\n\\graphicspath{{$imageDir/}}\n\\begin{document}". $dos); - - open my $OPDF,'>',"$tempDir/$pdfname-pdf.tex"; # write changes - print $OPDF $clean; - close $OPDF; +if (-e "$tempDir/$name-pst$ext") { +unlink "$tempDir/$name-pst$ext"; +} + my @del_pdf_tmp; + find(\&del_pdf_aux, $tempDir); + sub del_pdf_aux{ + my $auximgfile = $_; + if(-f $auximgfile && $auximgfile =~ /\.(aux|dvi|log|ps|idx|bfc|bib|preamble)$/){ + push @del_pdf_tmp, $File::Find::name; + } + } # close sub +unlink @del_pdf_tmp; # delte files -my $runAgain = 0; - - if($xetex){ # xelatex mode - if ($noImages){print "The file $pdfname-pdf.tex are created (Xe)LaTeX\n";} - else{ - system("xelatex -interaction=batchmode $tempDir/$pdfname-pdf"); - print "Done, compiled $pdfname-pdf.tex using (Xe)LaTeX\n";}} - else{ #pdflatex mode - if ($noImages){ - print "The file $pdfname-pdf.tex are created (pdf)LaTeX\n";} - else{ - system("pdflatex -interaction=batchmode $tempDir/$pdfname-pdf.tex"); - print "Done, compiled $pdfname-pdf.tex using (pdf)LaTeX\n";} - } - - if (-e "$tempDir/$pdfname-pdf.idx") { - system("makeindex $tempDir/$pdfname-pdf.idx"); $runAgain++;} - if ($runBibTeX && -e "$tempDir/$pdfname-pdf.aux") { - system("bibtex $tempDir/$pdfname-pdf"); $runAgain++; } - if ($runBiber && -e "$tempDir/$pdfname-pdf.bcf") { - system("biber $tempDir/$pdfname-pdf"); $runAgain++; } - if ($runAgain){ - if($xetex){ - system("xelatex -interaction=batchmode $tempDir/$pdfname-pdf");} - else{ - system("pdflatex -interaction=batchmode $tempDir/$pdfname-pdf");} - } - - if ($clear) { - unlink "$tempDir/$name.preamble"; - unlink "$tempDir/$name-pdf.aux"; - unlink "$tempDir/$name-pdf.log"; - unlink "$tempDir/$name-fig.tex"; - if ($eps or $ppm){ - if ($^O eq 'MSWin32'){unlink "$tempDir/xpd";} - } - if(!$verbose) {unlink "$tempDir/$name.plog";} - if ($single) {#comon - unlink "$tempDir/$name-fig.pdf"; - unlink "$tempDir/$name-fig.aux"; - unlink "$tempDir/$name-fig.log"; - if($xetex){ } - else{ - unlink "$tempDir/$name-fig.dvi"; - unlink "$tempDir/$name-fig.ps";} - } - else{ #clean for pdftk mode - unlink "$tempDir/$name-pst.log"; - unlink "$tempDir/$name-pst.pdf"; - unlink "$tempDir/$name-pst.aux"; - if($xetex){ } - else{ - unlink "$tempDir/$name-pst.dvi"; - unlink "$tempDir/$name-pst.ps"; - } +if ($^O eq 'MSWin32' || $^O eq 'MSWin64'){ +if ($eps or $ppm){ + unlink "$tempDir/xpd"; } } -} -sub LOG() { - if ( $verbose ) { print $LOGfile "@_\n"; } +if(!$Verbose) { + unlink "$tempDir/$name.plog"; + } +} # close clear + +# Clear source files +if ($noSource) { +my @del_src; +find(\&del_src_tex, $imageDir); +sub del_src_tex{ +my $srcimg = $_; +# search image file source +if(-f $srcimg && $srcimg =~ /($name-(fig|exa)-\d+)$ext/){ +push @del_src, $File::Find::name; } +} +unlink @del_src; +}# end source clear + __END__ |