sometxt vs textext behaving different
unknown picture pic sometxt ! Equation cannot be performed (unknown picture=numeric). <to be read again> (
Metapost problem: It seems that sometxt and textext behave different. This is my macro: % Label with text and centerposition vardef theLabel@#(expr labeltext, pos) = save pic; picture pic; if picture labeltext: pic := labeltext; else: if labeltext = "": pic := nullpicture; else: % prevent wobbling of text boxes with uneven depth % TEXTEXT line: pic := textext("\setbox0=\hbox{"&labeltext&"}\dp0=0pt\box0"); % since ConTeXt 14-7-2006 textext => sometxt % SOMETXT line: %pic := sometxt("\setbox0=\hbox{"&labeltext&"}\dp0=0pt\box0"); fi fi % calculate labelshift from suffix save shift; pair shift; shift = ((penX/2 + labeloffset) * xpart laboff@#, (penY/2 + labeloffset) * ypart laboff@#) - (labxf@# * lrcorner pic + labyf@# * ulcorner pic + (1 - labxf@# - labyf@#) * llcorner pic); % deliver picture shifted in position pic shifted (pos + shift) enddef; With textext enabled it just works as I intend. With sometxt enabled I get: theLabel->...":pic:=nullpicture;else:pic:=sometxt( "\setbox0=\hbox{"& (EXPR3)&... l.211 Label("TEXTEXT", (w/2,h/2)) withcolor red; Thus while textext delivers a picture sometxt does not. This seems strange, because I understood that sometxt was meant as a dropin replacement for textext (except for MP loops, as Hans Hagen mentioned in a previous email). Is this correct or do I have to make more changes to switch over from textext to sometxt? Hans van der Meer
On 7/16/06, Hans van der Meer wrote:
Thus while textext delivers a picture sometxt does not. This seems strange, because I understood that sometxt was meant as a dropin replacement for textext (except for MP loops, as Hans Hagen mentioned in a previous email). Is this correct or do I have to make more changes to switch over from textext to sometxt?
I don't know if sometxt is meant to be used as a metapost command. I use it as \setupcolors[state=start] \def\nicecommand#1{nice \quotation{#1}} \starttext \startMPcode draw \sometxt{abc \color[red]{def} $\sqrt{x}$ and quote: " \nicecommand{text}}; \stopMPcode \stoptext textext had to write the text in a separate file, run its own instance of ConTeXt and include that one into metapost and consequently into the original document. It meant: - being slow - \def's don't work - you have to specify everything in MPenvironment since those labels don't see your earlier definitions in the document But with \sometxt you can't use mp variables. To some extent you can so something. See http://archive.contextgarden.net/message/20060623.224940.fa179b0b.en.html. Citing myself (from discussion about gnuplot): I love the new Hans's \sometxt feature, because: - it uses the same font as in the document without the need to specify the font separately in MP environment - no need for uncomfortable way of specifying the definitions/style in gnuplot-locals.tex (simply all the definitions from the document work, even \section-s) - no need for 'verbatimtex ... etex' or for '\def-s' inside metapost or inside MP environment (which didn't work) - external figures can be used for points (YUPI :) !!! - no problems with math and double quotes: I wasn't able to insert double quotes with textext, now it's trivial - text is still part of the graphic: can easily be positioned, colored, shrinked & stretched, ... if I would have to separate it (according to my first idea), I couldn't use metapost to control the color, size, ... but I would have to remember the color for each label separately and the outcome would be different (now I can still place graphic over text) - extremely fast - extremely efficient - extremely elegant to write Hope that it can clarify you at least some things, Mojca
participants (3)
-
Hans van der Meer
-
Mojca Miklavec
-
Taco Hoekwater