File: Examples.txt

package info (click to toggle)
dpic 2023.06.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,868 kB
  • sloc: ansic: 10,262; yacc: 5,827; makefile: 286; sh: 156; awk: 129; sed: 32
file content (393 lines) | stat: -rw-r--r-- 9,728 bytes parent folder | download
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
This file contains minimal examples of simple diagrams generated by the
output options of dpic.  In each case except the last two, a postscript
or pdf file is produced that can be viewed using a viewer such as gsview
or okular.  Example 13 produces an svg file that can be viewed by most
web browsers. Consult the appropriate manual for processing mfpic, PStricks,
MetaPost, TikZ-PGP, or psfrag output.

========================================================================
Example 1: LaTeX Picture Commands:  LaTeX provides a primitive drawing
  capability by placing characters from special fonts.  Dpic automates
  the tedious coordinate calculations, but drawings are still limited to
  the boxes, ovals, and lines of restricted slope provided by the fonts.

Diagram source file diag.pic:
.PS
  arrow "$u$" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "$G(s)$"
  arrow "$y$" above
  line down G.ht from last arrow then left last arrow.c.x-S.x
  arrow to S.s
  "$-\;$" below rjust
.PE

LaTeX file tst.tex:
   \documentclass{article}
   \begin{document}
   \input diag
   \end{document}

Commands:
  dpic diag.pic > diag.tex
  latex tst
  dvips -Ppdf tst.dvi

Result: tst.ps

========================================================================
Example 2: LaTeX Picture Commands with epic and eepicemu:

Diagram source file diag.pic:
.PS
  arrow "$u$" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "$G(s)$"
  arrow "$y$" above
  line dotted down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  "$-\;$" below rjust
  arrow <- down arrowht from S.s
.PE

LaTeX file tst.tex:
\documentclass{article}
\usepackage{epic,eepicemu}
\begin{document}
\input diag
\end{document}

Commands:
  dpic -t diag.pic > diag.tex
  latex tst
  dvips -Ppdf tst.dvi

Result: tst.ps

The feedback path has been dotted in this example, requiring the explicit
arrowhead below the circle.

========================================================================
Example 3: PSTricks output.

Diagram source file diag.pic:
.PS
  arrow "$u$" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "$G(s)$"
  arrow "$y$" above
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  "$-\;$" below rjust
.PE

LaTeX file tst.tex:
c\documentclass{article}
\usepackage{pstricks}
\begin{document}
\input diag
\end{document}

Commands:
  dpic -p diag.pic > diag.tex
  latex tst
  dvips -Ppdf tst.dvi

The labels are in math mode.

========================================================================
Example 4: TikZ-PGF output to produce either postscript or pdf.

Diagram source file diag.pic:
.PS
  arrow "$u$" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "$G(s)$"
  arrow "$y$" above
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  "$-\;$" below rjust
.PE

LaTeX file tst.tex:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\input diag
\end{document}

Commands to produce tst.ps:
  dpic -g diag.pic > diag.tex
  latex tst
  dvips -Ppdf tst.dvi

Commands to produce tst.pdf:
  dpic -g diag.pic > diag.tex
  pdflatex tst

========================================================================
Example 5: Mfpic output.

Diagram source file as above.

LaTeX file tst.tex:
\documentclass{article}
\usepackage{mfpic}
\begin{document}
\opengraphsfile{tst-mfpic}
\input diag
\closegraphsfile
\end{document}

Commands:
  dpic -m diag.pic > diag.tex
  latex tst
  mf tst-mfpic
  gftopk *gf tst-mfpic.pk
  latex tst
  dvips tst.dvi

The mf command creates a new font tst-mfpic, containing
one character in this example.  To see the font characters,
type "tex testfont" and at the prompts, type "tst-mfpic",
"\table", and "\end".  Then "dvips testfont" creates
testfont.ps.  The font character contains the lines of
the diagram but not the labels.

========================================================================
Example 6: Postscript output with psfrag strings.

Diagram source file as above.

LaTeX file tst.tex:
\documentclass{article}
\usepackage{graphicx}
\usepackage[scanall]{psfrag}
\begin{document}
\includegraphics{diag}
\end{document}

Commands:
  dpic -f diag.pic > diag.eps
  latex tst
  dvips -Ppdf tst


========================================================================
Example 7: Raw postscript output

Diagram source file diag.pic:
.PS
  command "/Times-Italic findfont 11 scalefont setfont"
  arrow "u" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "G(s)"
  arrow "y" above
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  move down 0.05 left 0.15 ""
  command "(\261) show"
.PE

LaTeX file tst.tex:
  \documentclass{article}
  \usepackage{graphicx}
  \begin{document}
  \includegraphics{diag}
  \end{document}

Commands:
  dpic -r diag.pic > diag.eps
  latex tst
  dvips -Ppdf tst

Postscript code to select the font and to position and print the minus
sign have been manually inserted using "command", since diag.eps is
produced without any automatic text formatting. This is not practical
for complicated labels.

========================================================================
Example 8: Raw postscript output with overlaid labels

Diagram source file diagA.pic containing no labels:
.PS
  arrow
S: circle rad 10/72.27
  line right 0.35
G: box
  arrow
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  arrow <- down arrowht from S.s
.PE

Diagram source file diagB.pic containing only labels:
.PS
B: "\includegraphics{diagA.eps}" wid 173/72 ht 58/72
  "$u$" at B.sw + (0.25,0.6)
  "$G(s)$" at B.sw + (1.5,0.5)
  "$y$" at B.sw + (2.13,0.6)
  "$-$" at B.sw + (0.55,0.6-0.30)
.PE

LaTeX file tst.tex:
  \documentclass{article}
  \usepackage{pstricks,graphicx}
  \begin{document}
  \input diag
  \end{document}

Commands:
  dpic -r diagA.pic > diagA.eps
  dpic -p diagB.pic > diag.tex
  latex tst
  dvips -Ppdf tst.dvi

The .eps file contains no text strings but contains the line
%%BoundingBox: 0 0 173 58
from which its width is 173-0 pt and its height is 58-0=58 pt.
The locations of the labels have to be known in diagB.pic but
they can be calculated automatically as well as manually in this
simple example.

========================================================================
Example 9: Raw PDF output

Diagram source file diag.pic:
.PS
  textht = 12/72        # 12 pt text
  arrow "u" above
S: circle rad 10/72.27  # 10 pt
  line right 0.35
G: box "G(s)"
  arrow "y" above
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
  move down 0.1 left 0.15 "-"
.PE

LaTeX file tst.tex:
  \documentclass{article}
  \usepackage{graphicx}
  \begin{document}
  \includegraphics{diag}
  \end{document}

Commands:
  dpic -d diag.pic > diag.pdf
  pdflatex tst

By default, the Courier font is used, since its fixed width allows the
width of text strings to be calculated.  The font size can be adjusted
by setting the pic environment variable, e.g.: textht = 12/72

========================================================================
Example 10: Raw PDF output with overlaid labels

Diagram source file diagA.pic containing no labels:
.PS
  arrow
S: circle rad 10/72.27
  line right 0.35
G: box
  arrow
  arrow down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
.PE

Diagram source file diagC.pic containing only labels:
.PS
B: "\includegraphics{diagA.pdf}" wid 173/72 ht 58/72
  "$u$" at B.sw + (0.25,0.6)
  "$G(s)$" at B.sw + (1.5,0.5)
  "$y$" at B.sw + (2.13,0.6)
  "$-$" at B.sw + (0.55,0.6-0.30)
.PE

LaTeX file tst.tex:
  \documentclass{article}
  \usepackage{tikz,graphicx}
  \begin{document}
  \input diag
  \end{document}

Commands:
  dpic -d diagA.pic > diagA.pdf
  dpic -g diagC.pic > diag.tex
  pdflatex tst

The diagA.pdf file includes no text strings but contains the line
 /MediaBox [     0     0   173    58 ]
fom which the diagram width is 173 bp and its height is 58 bp.
The size of the included pdf and the locations of the labels have to be
known in diagC.pic.
The labels are in math mode.

========================================================================
Example 11: MetaPost output:

Diagram source file diag.pic:
  verbatimtex
  \documentclass[11pt]{article}
  \usepackage{times}
  \begin{document} etex
  .PS
    arrow "$u$" above
  S: circle rad 10/72.27  # 10 pt
    line right 0.35
  G: box "$G(s)$"
    arrow "$y$" above
    line down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
    "$-\;$" below rjust
    arrow <- down arrowht from S.s
  .PE
  end

LaTeX file tst.tex:
  \documentclass{article}
  \usepackage{graphicx}
  \begin{document}
  \includegraphics{diag.1}
  \end{document}

Commands:
    dpic -s diag.pic > diag.mp
    mpost --tex=latex diag.mp
    latex tst
    dvips -Ppdf tst

========================================================================
Example 12: Xfig output:

Diagram source file diag.pic:
  .PS
    arrow "u" above
  S: circle rad 10/72.27  # 10 pt
    line right 0.35
  G: box "G(s)"
    arrow "y" above
    line -> down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
    "-" below rjust
  .PE

Commands:
  dpic -x diag.pic > diag.fig

The file diag.fig can then be read by xfig version 3.2 or later.

========================================================================
Example 13: SVG output:

Diagram source file diag.pic:
  .PS
    arrow "u" above
  S: circle rad 10/72.27  # 10 pt
    line right 0.35
  G: box "G(s)"
    arrow "y" above
    line -> down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
    "-" below rjust
  .PE

Commands:
  dpic -v diag.pic > diag.svg

The file diag.svg can then be read by a browser or svg viewer plugin.