Debian Codegraph @

texmf-dist/doc/metapost/base/source-tutorial/label.mp

raw
1 prologues:=3;
2
3 if scantokens(mpversion) > 1.005:
4 outputtemplate :=
5 else:
6 filenametemplate
7 fi
8 "%j-%c.mps";
9
10 verbatimtex
11 %&latex
12 \documentclass[11pt]{article}
13 \usepackage[charter]{mathdesign}
14 \usepackage[T1]{fontenc}
15 \renewcommand*{\ttdefault}{lmtt}
16 \begin{document}
17 etex
18
19 % Determine the size of the default font
20 w:=fontsize defaultfont;
21
22 beginfig(1);
23 % Place a "point" at (0,0)
24 fill fullcircle scaled 3;
25
26 % Draw a square around the point
27 draw (-7*w/16,-7*w/16)--(7*w/16,-7*w/16)--(7*w/16,7*w/16)--(-7*w/16,7*w/16)--cycle;
28
29 % Draw vertical and horizontal lines through the point
30 draw (0,-7*w/16)--(0,7*w/16);
31 draw (-7*w/16,0)--(7*w/16,0);
32
33 % Label the 4 positions
34 label.lft(btex \texttt{lft} etex,(-w/4,0));
35 label.rt(btex \texttt{rt} etex,(w/4,0));
36 label.bot(btex \texttt{bot} etex,(0,-w/4));
37 label.top(btex \texttt{top} etex,(0,w/4));
38
39 % Manually set the bbox
40 setbounds currentpicture to (-2*w,-2*w)--(2*w,-2*w)--(2*w,2*w)--(-2*w,2*w)--cycle;
41 endfig;
42
43 beginfig(2);
44 % Place a "point" at (0,0)
45 fill fullcircle scaled 3;
46
47 % Draw a square around the point
48 draw (-7*w/16,-7*w/16)--(7*w/16,-7*w/16)--(7*w/16,7*w/16)--(-7*w/16,7*w/16)--cycle;
49
50 % Draw diagonals of the square through the point
51 draw (-7*w/16,-7*w/16)--(7*w/16,7*w/16);
52 draw (-7*w/16,7*w/16)--(7*w/16,-7*w/16);
53
54 % Label the 4 positions
55 label.llft(btex \texttt{llft} etex,(-w/4,-w/4));
56 label.ulft(btex \texttt{ulft} etex,(-w/4,w/4));
57 label.lrt(btex \texttt{lrt} etex,(w/4,-w/4));
58 label.urt(btex \texttt{urt} etex,(w/4,w/4));
59
60 % Manually set the bbox
61 setbounds currentpicture to (-11/4*w,-2*w)--(11/4*w,-2*w)--(11/4*w,2*w)--(-11/4*w,2*w)--cycle;
62 endfig;
63 end