Debian Codegraph @

texmf-dist/doc/latex/pst-exa/pst-exa-doc.tex

raw
1 % arara: latex: {draft: yes}
2 % arara: latex
3 % arara: biber
4 % arara: makeindex
5 % arara: latex: {draft: yes}
6 % arara: latex
7 % arara: dvips
8 % arara: ps2pdf
9 % arara: clean: { files:[pst-exa-doc.out, pst-exa-doc.ps, pst-exa-doc.toc,pst-exa-doc.log,pst-exa-doc.ind,pst-exa-doc.aux, pst-exa-doc.bbl, pst-exa-doc.bcf, pst-exa-doc.blg,pst-exa-doc.dvi,pst-exa-doc.idx,pst-exa-doc.ilg,pst-exa-doc.run.xml] }
10 \documentclass[11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small,
11 headinclude=false,footinclude=false,twoside]{scrartcl}
12 \usepackage[utf8]{inputenc}
13 \usepackage[T1]{fontenc}
14 \usepackage{libertine}
15 \usepackage[scaled=0.88]{beramono}
16 \usepackage{babel}
17 \usepackage{makeidx}\makeindex
18 \input{\jobname.inc}
19 \listfiles
20 \let\Lfile\LFile
21 \usepackage{pst-node}
22 \usepackage{biblatex}
23
24 \addbibresource{\jobname.bib}
25
26 \usepackage{xspace,showexpl}
27 \usepackage{pst-text,pst-grad}
28 \usepackage[tcb]{pst-exa}
29 \let\pstFV\fileversion
30
31 %\DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{4cm}
32 %\renewcommand\bgImage{\pscharpath[fillstyle=gradient,
33 % gradbegin=red,gradend=blue,gradangle=-90]{\RM pst-exa}}
34
35 \lstset{language=PSTricks,basicstyle=\footnotesize\ttfamily}
36 \def\DVI{\textsc{DVI}}
37 \def\PDF{\textsc{PDF}}
38 \def\gs{\textsc{Ghostscript}}
39 %
40 \begin{document}
41 \title{\texttt{pst-exa}\\
42 Generate examples for PSTricks environments (with pdflatex);\\ \small v. 0.06}
43 \author{Herbert Vo\ss \\ Pablo Gonz\'{a}lez Luengo}
44 %\docauthor{}
45 \date{\today}
46 \maketitle
47
48 \tableofcontents
49
50 \clearpage
51
52 \section{Introduction}
53
54 The package \LPack{pst-exa} was created to realize examples with printed
55 code and output side by side or on top of each other. The package
56 looks in the image directory for the source code of the examples
57 and inserts only the image for code environment
58
59 However, creating a \PDF\ file in a direct way with \Lprog{pst2pdf} or \Lprog{ltximg} is
60 possible and the compiles whits \Lprog{pdflatex}.
61
62 \PST\ as \PS\ related package uses the programming language \PS\ for internal
63 calculations. This is an important advantage, because floating point arithmetic is no
64 problem. Nearly all mathematical calculation can be done when running the \DVI-file
65 with \gs.
66
67 \section{Loading the package}
68
69 The package \LPack{pst-exa} must be loaded with one of the following options in the preamble of the document:
70
71 \begin{verbatim}
72 \usepackage[swpl]{pst-exa}
73 \end{verbatim}
74
75 automatically load \LPack{showexpl} package.
76
77 \begin{verbatim}
78 \usepackage[tcb]{pst-exa}
79 \end{verbatim}
80
81 automatically load \LPack{tcolorbox} package.
82
83 \section{Environments}
84 The package \LPack{pst-exa} provides two environments:
85
86 \Lenv{PSTcode} to write only code that does not generate
87 an image, this is necessary to not interrupt the order in which the images are copied by the script in the process
88 of conversion to pdf.
89
90 \Lenv{PSTexample} environment,
91 to write only code that generates an image, keep in mind that the script that performs the extraction process
92 does not distinguish the format given to the lines in this environment (only reads plain text) the idea is to
93 concentrate on the image you want to extrare and then in the format of the text.
94
95 \section{Programs needed}
96 You need \nxLprog{pst2pdf} (or \Lprog{ltximg}) whit a latest version of \Lprog{Ghostscript} (9.14),
97 \Lprog{perl} (>=5.18), \Lprog{pdf2svg}, \Lprog{pdftoppm} and \Lprog{pdftops}
98 (from \Lprog{poppler-utils} or \Lprog{xpdf-utils}) for the process file.
99
100 The general syntax for the \emph{script} is simple:
101
102 \begin{BDef}
103 \nxLprog{perl} \nxLprog{pst2pdf} \Larg{file.tex} \Largs{--options}
104 \end{BDef}
105
106 For \TeX Live users:
107
108 \begin{BDef}
109 \nxLprog{pst2pdf} \Larg{file.tex} \Largs{--options}
110 \end{BDef}
111
112 this create file-pdf-exa.pdf and file-fig-exa-1.pdf, file-fig-exa-2.pdf, file-fig-exa-\dots.pdf
113
114 \section{Examples with option \texttt{tcb}}
115
116 \verb|\begin{pspicture}| o \tcboxverb{\begin{pspicture}[showgrid](4,4)}
117
118 \begin{pspicture}[showgrid](4,4)
119 \psRing(2,2){0.3}{0.8}
120 \psRing*[opacity=0.5](2,2){1}{2}
121 \psdot(2,2)
122 \end{pspicture}
123
124 %\mint[hola]{algo}$\begin{pspicture} o \begin{pspicture*}$ no problem whit inline verb :)
125 \section{Test PSTexample}
126 % numbers=none
127 \begin{PSTexample}[pos=t,numbers=fancy,title=First example]
128 \pstVerb{ 1234321 srand }
129 \begin{pspicture}[showgrid](-2,-2)(2,2)
130 \psframe*[linecolor=blue,opacity=!Rand](2,2)
131 \psframe*[linecolor=red,opacity=!Rand](-1,-1)(1,1)
132 \psframe*[linecolor=green,opacity=!Rand](-2,-2)(0,0)
133 \end{pspicture}
134 \end{PSTexample}
135 \vspace{20pt}
136 \begin{PSTexample}[hwidth=5cm]
137 \begin{pspicture}[showgrid](4,4)
138 \psRing(2,2){0.3}{0.8}
139 \psRing*[opacity=0.5](2,2){1}{2}
140 \psdot(2,2)
141 \end{pspicture}
142 \end{PSTexample}
143 % ned
144 \section{Test PSTcode}
145 \begin{PSTcode}
146 \pstVerb{ 1234321 srand }
147 \begin{pspicture}[showgrid](-2,-2)(2,2)
148 \psframe*[linecolor=blue,opacity=!Rand](2,2)
149 \psframe*[linecolor=red,opacity=!Rand](-1,-1)(1,1)
150 \psframe*[linecolor=green,opacity=!Rand](-2,-2)(0,0)
151 \end{pspicture}
152 \end{PSTcode}
153
154 \begin{PSTcode}
155 \begin{pspicture}[showgrid](4,4)
156 \psRing(2,2){0.3}{0.8}
157 \psRing*[opacity=0.5](2,2){1}{2}
158 \psdot(2,2)
159 \end{pspicture}
160 \end{PSTcode}
161
162
163 \section{Examples with option \texttt{swpl}}
164
165 \makeatletter
166 \pstexa@swpltrue
167 % Star code for swpl option
168 % Environment for code
169 \let\PSTcode\relax
170 \let\endPSTcode\relax
171 \lstnewenvironment{PSTcode}
172 {%
173 \lstset{
174 language=PSTexa,%
175 frame=single,%
176 numbers=left,%
177 numbersep=1em,%
178 numberstyle=\tiny\color{black!75}\noaccsupp,%
179 rulecolor=\color{black!67},%
180 framesep=\fboxsep,%
181 framerule=\fboxrule,%
182 xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,%
183 xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,%
184 backgroundcolor=\color[rgb]{1,1,0.8},%
185 % literateee
186 literate=*{\{}{{\textcolor{blue}{\{}}}{1}
187 {\}}{{\textcolor{blue}{\}}}}{1}
188 {[}{{\textcolor{blue}{[}}}{1}
189 {]}{{\textcolor{blue}{]}}}{1}
190 {(}{{\textcolor{blue}{(}}}{1}
191 {)}{{\textcolor{blue}{)}}}{1}
192 {\$}{{\textcolor{red}{\$}}}{1}
193 {\#}{{\textcolor{red}{\#}}}{1}%,
194 }% close lstset
195 }%
196 {}% close PSTcode
197
198 % Change position for images
199 \renewcommand*\SX@resultInput{%
200 \ifx\SX@graphicname\@empty
201 \begingroup
202 \MakePercentComment\makeatother\catcode`\^^M=5\relax
203 \SX@@preset\SX@preset
204 \if@SX@rangeaccept
205 \let\SX@tempa=\SX@input
206 \else
207 \let\SX@tempa=\input
208 \fi
209 \SX@tempa{\SX@codefile}\par%
210 \endgroup
211 \else
212 \begin{center}
213 \expandafter\includegraphics\expandafter[\SX@graphicparam]{\SX@graphicname}
214 \end{center}
215 \fi
216 }% end change postition
217 % PSTexample definition in swpl
218 \let\PSTexample\relax
219 \let\endPSTexample\relax
220 \lstnewenvironment{PSTexample}[1][]
221 {%
222 \lstset{%
223 language=PSTexa,%
224 frame=single,%
225 numbers=left,%
226 numbersep=1em,%
227 numberstyle=\tiny\color{black!75}\noaccsupp,%
228 rulecolor=\color{black!67},%
229 framesep=\fboxsep,%
230 framerule=\fboxrule,%
231 xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,%
232 xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,%
233 backgroundcolor=\color[rgb]{1,1,0.8},%
234 % literate for swpl, need inside the explpreset
235 explpreset={
236 % literate
237 literate=*{\{}{{\textcolor{blue}{\{}}}{1}
238 {\}}{{\textcolor{blue}{\}}}}{1}
239 {[}{{\textcolor{blue}{[}}}{1}
240 {]}{{\textcolor{blue}{]}}}{1}
241 {(}{{\textcolor{blue}{(}}}{1}
242 {)}{{\textcolor{blue}{)}}}{1}
243 {\$}{{\textcolor{red}{\$}}}{1}
244 {\#}{{\textcolor{red}{\#}}}{1},%
245 codefile=\jobname.swpl,%
246 hsep=\columnsep,%
247 vsep=15pt,%
248 pos=l,%
249 wide=false,%
250 rframe={},%
251 preset=\centering,%
252 } % close explpreset
253 } % close lstset
254 \@temptokena{#1}%
255 \begingroup
256 \advance\c@ltxexample\@ne \advance\c@lstlisting\@ne
257 \expandafter\lstset\expandafter{\SX@explpreset,#1}%
258 \edef\x{\endgroup
259 \def\noexpand\SX@codefile{\SX@codefile}%
260 \def\noexpand\SX@graphicname{\SX@graphicname}%
261 \def\noexpand\SX@graphicparam{\SX@graphicparam}}%
262 \x
263 \xdef\SX@@explpreset{\the\@temptokena,codefile=\SX@codefile,
264 graphic={[\SX@graphicparam]{\SX@graphicname}}}%
265 \setbox\@tempboxa=\hbox\bgroup% Warum noetig?
266 \lst@BeginWriteFile{\SX@codefile}%
267 % Change position for images
268 }
269 {%
270 \lst@EndWriteFile\egroup
271 \SX@put@code@result
272 }% close environment
273 % end swpl code
274 \makeatother
275
276 % numbers=none
277 \begin{PSTexample}[pos=t,numbers=none]
278 \pstVerb{ 1234321 srand }
279 \begin{pspicture}[showgrid](-2,-2)(2,2)
280 \psframe*[linecolor=blue,opacity=!Rand](2,2)
281 \psframe*[linecolor=red,opacity=!Rand](-1,-1)(1,1)
282 \psframe*[linecolor=green,opacity=!Rand](-2,-2)(0,0)
283 \end{pspicture}
284 \end{PSTexample}
285 % numbers true default
286 \begin{PSTexample}[width=5cm]
287 \begin{pspicture}[showgrid](4,4)
288 \psRing(2,2){0.3}{0.8}
289 \psRing*[opacity=0.5](2,2){1}{2}
290 \psdot(2,2)
291 \end{pspicture}
292 \end{PSTexample}
293 % ned
294
295 \begin{PSTcode}
296 \pstVerb{ 1234321 srand }
297 \begin{pspicture}[showgrid](-2,-2)(2,2)
298 \psframe*[linecolor=blue,opacity=!Rand](2,2)
299 \psframe*[linecolor=red,opacity=!Rand](-1,-1)(1,1)
300 \psframe*[linecolor=green,opacity=!Rand](-2,-2)(0,0)
301 \end{pspicture}
302 \end{PSTcode}
303
304 \begin{PSTcode}
305 \begin{pspicture}[showgrid](4,4)
306 \psRing(2,2){0.3}{0.8}
307 \psRing*[opacity=0.5](2,2){1}{2}
308 \psdot(2,2)
309 \end{pspicture}
310 \end{PSTcode}
311
312 \begin{pspicture}[showgrid](4,4)
313 \psRing(2,2){0.3}{0.8}
314 \psRing*[opacity=0.5](2,2){1}{2}
315 \psdot(2,2)
316 \end{pspicture}
317
318
319
320
321 \definecolor{mygreen}{rgb}{0,0.6,0}
322 \definecolor{mygray}{rgb}{0.5,0.5,0.5}
323
324 \lstset{ %
325 basicstyle=\ttfamily\small,
326 commentstyle=\color{mygreen},
327 extendedchars=true,
328 frame={},
329 keepspaces=true,
330 keywordstyle=\color{blue},
331 numbers=left,
332 numbersep=5pt,
333 numberstyle=\tiny\color{mygray}
334 }
335 %\lstinputlisting[language=TeX]{pst-exa.sty}
336 %\newpage
337 %
338 \clearpage
339 \nocite{*}
340 \printbibliography
341
342 \printindex
343 \end{document}