summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pst2pdf/pst2pdf-doc.tex
blob: a89995f74b827b1961e4840d9c72b80ddda91650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
\documentclass[10pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,smallheadings
    headexclude,footexclude,oneside]{pst-doc}
\usepackage[utf8]{inputenc}
\RequirePackage{xspace}
\usepackage{pst-text,pst-grad}
\let\pstFV\fileversion
\DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{4cm}
\renewcommand\bgImage{\pscharpath[fillstyle=gradient,
  gradbegin=red,gradend=blue,gradangle=-90]{\RM pst2pdf}}

\lstset{language=PSTricks,basicstyle=\footnotesize\ttfamily}
\def\DVI{\textsc{DVI}}
\def\PDF{\textsc{PDF}}
\def\gs{\textsc{Ghostscript}}
%
\begin{document}

\title{\texttt{pst2pdf}}
\subtitle{Running a PSTricks document with pdflatex;\\  \small v. 0.15}
\author{Herbert Vo\ss  \\ Pablo Gonz\'{a}lez Luengo}
\docauthor{}
\date{\today}
\maketitle

\tableofcontents

\clearpage

\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 \Lprog{perl} \emph{script} \Lprog{pst2pdf}, it extracts
all \PST\ related code into single documents with the same preamble as the original
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
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}).

\subsection{Preparating file}
The script scan the file for \Lenv{pspicture} and \Lenv{postscript} environments,
which are then taken with its contents from the main file to create stand alone documents
with the same preamble as the main document. The \Lenv{pspicture} environment can be nested,
the \Lenv{postscript} one not! But it can contain an environment \Lenv{pspicture}, but not vice versa.
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.

This is an example of environments that support for \nxLprog{pst2pdf}:

\vspace{10pt}
\begin{minipage}[c]{0.25\textwidth}
\begin{verbatim}
\pspicture*
\psset{...}
pstricks code	
\endpspicture
\end{verbatim}
\end{minipage}
\begin{minipage}[c]{0.25\textwidth}
\begin{verbatim}
\begin{pspicture}
\psset{...}
pstricks code	
\end{pspicture}
\end{verbatim}
\end{minipage}
\begin{minipage}[c]{0.25\textwidth}
\begin{verbatim}
\begin{pspicture*}
\psset{...}
pstricks code	
\end{pspicture*}
\end{verbatim}
\end{minipage}
\begin{minipage}[c]{0.25\textwidth}
\begin{verbatim}
\begin{postscript}
\psset{...}
pstricks code	
\end{postscript}
\end{verbatim}
\end{minipage}

\section{Running the script}
\subsection{Default mode}
The general syntax for the \Lprog{perl} \emph{script} is simple:

\begin{BDef}
\nxLprog{perl} \nxLprog{pst2pdf} \Larg{file.tex} \OptArg*{--options}
\end{BDef}

For \TeX Live users:

\begin{BDef}
\nxLprog{pst2pdf} \Larg{file.tex} \OptArg*{--options}
\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}.
\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:

\begin{BDef}
\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}).

\section{Options}
\label{options}
The options listed in Table~\ref{perloptions} refer only to the \emph{script} and not the \LaTeX\ file.

\begin{table}[htp]
\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
\end{tabularx}
\end{table}

For Help in command line use:

\begin{BDef}
\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:\\

\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}
\bgroup
\raggedright
\nocite{*}
\bibliographystyle{plain}
\bibliography{pst2pdf-doc}
\egroup
\printindex
\end{document}