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.
