summaryrefslogtreecommitdiff
path: root/tex/generic/context/m-metapo.tex
blob: f02830a13916056c41db2534e65f457c51a57576 (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
%D \module
%D   [       file=m-metapo,
%D        version=1999.03.26,
%D          title=\LATEX\ Modules,
%D       subtitle=\METAPOST\ Inclusion,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ distribution and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D We quit when \CONTEXT\ is found and use some deep down
%D macro to trigger this:

\ifx\undefined\dodoplaceexternalfigure \else \expandafter \endinput \fi

%D \macros
%D   {includeMPgraphics}
%D
%D This rather small \LATEX\ module is dedicated to David
%D Arnold. It takes care of including the fonts used in
%D \METAPOST\ graphics in the file. This hack is needed when
%D one uses another \DVI\ driver than \DVIPS. This module
%D falls back on the generic \CONTEXT\ support module:

\ifx\undefined\includeMPfonts \input supp-mps.tex \relax \fi

%D Instead of using \type {\includegraphics}, one should use its
%D little brother \type {\includeMPgraphics}. This macro takes
%D the same arguments.

\def\includeMPgraphics#1#%
  {\leavevmode\vbox\bgroup\hbox\bgroup
     \def\includeMPgraphics##1%
       {\includeMPfonts{##1}%
        \includegraphics#1{##1}%
        \egroup\egroup}%
     \includeMPgraphics}

%D An example of using this module is given below:
%D
%D \starttyping
%D \documentclass[10pt]{article}
%D
%D \usepackage{graphicx}
%D \usepackage{m-metapo}
%D
%D \begin{document}
%D   \includeMPgraphics{somefile.1}
%D   \includeMPgraphics[angle=90]{somefile.2}
%D \end{document}
%D \stoptyping
%D
%D This module needs \type {supp-mps} and \type {supp-mis},
%D that both are present in the \CONTEXT\ path.
%D
%D Please do not forget to say \type {prologues:=1} at the
%D top of the metapost file!
%D
%D For non \LATEX\ (and \CONTEXT) users we provide an
%D alternative inclusion macro. This one has no optional
%D arguments.

\ifx\includegraphics\undefined

  \ifx\undefined\dogetEPSboundingbox \input supp-eps.tex \relax \fi

  \def\includeMPgraphics#1%
    {\hbox\bgroup
     \includeMPfonts{#1}%
     \dogetEPSboundingbox{#1}{\dimen2}{\dimen4}{\dimen6}{\dimen8}%
     \vbox to \dimen8
       {\forgetall
        \hsize\dimen6
        \vfill
        \hbox to \hsize
          {\special
             {PSfile="#1"\space
              llx=\EPSllx\space
              lly=\EPSlly\space
              urx=\EPSurx\space
              ury=\EPSury\space}}}%
     \egroup}

\fi

\endinput