[NTG-context] Labels in MetaPost (MetaObj)

Stefan Müller warrence.stm at gmx.de
Tue Jan 18 13:17:45 CET 2011


Hi list,

I'm having some trouble with MetaPost in general and MetaObj in 
particular. I hope someone on this list can assist me here. I'm trying 
to run the appended ConTeXt file with a quite simple object "Segment" 
(from the manual [1], section 2.1). This script works fine as it is. I 
wanted to add a simple TeX label ("\tt \overbar{E}") to the drawing 
macro, but failed.

When including the line marked with "% 1" the TeX run fails. I don't 
understand why.

The line with "% 2" is taken frome the metaobj manual (section 5.8) [1], 
but including this doesn't work either.

It would be great if someone could tell me what's wrong with the mp-code 
below and explain how to place a (TeX) label inside a metaobj object.

Thanks in advance,
Stefan.


[1] http://tex.loria.fr/prod-graph/momanual.pdf

PS: Both variants fail with mp error messages like this:

"mplib           > mp terminal: ! Inconsistent equation (off by 1).
<to be read again>
                    ;
assignObj->(SUFFIX0)=incr(nObj_);
 
iname_[(SUFFIX0)]=str(SUFFIX0);addclass_((S...

newSegment->...roup.assignObj((SUFFIX2),"Segment")
 
;ObjPoint.a,b;ObjCode"@##b...
<to be read again>
                    ;
<*> ...ar {E}") shifted n.a; enddef; newSegment.s;
                                                    s.a=origin; 
drawObj(s); ;
! Redundant equation.
<to be read again>
                    ;
assignObj->...bj_);iname_[(SUFFIX0)]=str(SUFFIX0);
 
addclass_((SUFFIX0),(EXPR1...

newSegment->...roup.assignObj((SUFFIX2),"Segment")
 
;ObjPoint.a,b;ObjCode"@##b..."


<=======================================>
\startMPinclusions
	input metaobj;
\stopMPinclusions

\startMPpage
	vardef newSegment@#=
		assignObj(@#,"Segment");
		ObjPoint a,b;
		ObjCode "@#b-@#a=(1cm,2cm)";
	enddef;

	def drawSegment(suffix n)=
		draw n.a--n.b;
%		draw btex \tt \overbar{E} etex shifted n.a; % 1
	enddef;

	newSegment.s;
%	ObjLabel.s(btex hello! etex) "labpoint(a)"; % 2
	s.a=origin;
	drawObj(s);
\stopMPpage
<=======================================>


More information about the ntg-context mailing list