[metapost] Positioning labels at a vertex

Yasir Malik ymalik at stevens.edu
Wed Nov 17 16:16:32 CET 2010


Hi Troy,

Thanks for the reply.  I should have included an example along my 
question.  Consider the following:

beginfig(1);

u = 1cm;

pair a, b, c, d, v;

a = (0, 0);
b = 5u*dir(40) + a;
c = (0, 1u);
d = (5u, 1u);

draw a--b;
draw c--d;

v = (a--b) intersectionpoint (c--d);

% the label intersects with a line using these two commands
%label.llft(btex $40^\circ$ etex, v);
%label.lft(btex $40^\circ$ etex, v);

% this displays properly but it took at least 5 tries
label(btex $40^\circ$ etex, v + (-.4u, -.15u));

endfig;
end

As I note in the comments, the label intersects with one of the lines 
using the first two label calls.  The third label looks right, but it was 
frustrating getting it right.  If I change the angle, I'll have to spend 
more time repositioning the label.

I've found topics regarding the difficulty of positioning labels, but none 
are about automating this process.  Is there a macro that could take care 
of this?  It would also be nice if it had the option to position the label 
correctly if there was an angle mark.

Thanks,
Yasir


More information about the metapost mailing list