Node:Labeling Points Intro, Previous:Drawing Points Intro, Up:Drawing and Labeling Points



Labeling Points

The labels in the previous examples were made by using the functions Point::label() and Point::dotlabel(), which make it possible to include TeX text in a drawing.

label() and dotlabel() take string arguments for the text of the label and the position of the label with respect to the Point. The label text is formatted using TeX, so it can contain math mode material between dollar signs. Please note that double backslashes must be used, where a single backslash would suffice in a file of MetaPost code, for example, for TeX control sequences. Alternatively, a short argument can be used for the label.

The position argument is optional, with "top" as the default. If the empty string "" is used, the label will centered about the Point itself. This will usually only make sense for label(), because it would otherwise interfere with the dot. Valid arguments for the position are the same as in MetaPost: "top", "bot" (bottom), "lft" (left), "rt" (right), "ulft" (upper left), "urt" (upper right), "llft" (lower left), and "lrt" (lower right).

     Point p0;
     Point p1(1);
     Point p2(2);
     Point p3(p0);
     Point p4(p1);
     Point p5(p2);
     p3 *= p4 *= p5.shift(0, 1);
     p0.draw(p1);
     p1.draw(p2);
     p2.draw(p5);
     p5.draw(p4);
     p4.draw(p3);
     p3.draw(p0);
     p0.label($p_0$, "");
     p1.dotlabel(1);
     p2.dotlabel("p2", "bot");
     p3.dotlabel("This is $p_3$", "lft");
     p4.label(4);
     p5.label("$\\leftarrow p_5$", "rt");
     


[Figure 8. Not displayed.]

Fig. 8.

For complete descriptions of Point::label() and Point::dotlabel(), see Points; Labelling.