ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* sometxt vs textext behaving different
@ 2006-07-16 16:41 Hans van der Meer
  2006-07-17  7:26 ` Taco Hoekwater
  2006-07-18 16:48 ` Mojca Miklavec
  0 siblings, 2 replies; 3+ messages in thread
From: Hans van der Meer @ 2006-07-16 16:41 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1678 bytes --]

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:
 >> unknown picture pic
 >> sometxt
! Equation cannot be performed (unknown picture=numeric).
<to be read again>
                    (
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




[-- Attachment #1.2: Type: text/html, Size: 4368 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sometxt vs textext behaving different
  2006-07-16 16:41 sometxt vs textext behaving different Hans van der Meer
@ 2006-07-17  7:26 ` Taco Hoekwater
  2006-07-18 16:48 ` Mojca Miklavec
  1 sibling, 0 replies; 3+ messages in thread
From: Taco Hoekwater @ 2006-07-17  7:26 UTC (permalink / raw)




Hans van der Meer wrote:
> Metapost problem: It seems that sometxt and textext behave different.

Yes, they are different. sometxt only works for TeX-only labels.
If you need a MetaPost variable in the label, you have to use textext.

Greetings, Taco

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sometxt vs textext behaving different
  2006-07-16 16:41 sometxt vs textext behaving different Hans van der Meer
  2006-07-17  7:26 ` Taco Hoekwater
@ 2006-07-18 16:48 ` Mojca Miklavec
  1 sibling, 0 replies; 3+ messages in thread
From: Mojca Miklavec @ 2006-07-18 16:48 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-18 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-16 16:41 sometxt vs textext behaving different Hans van der Meer
2006-07-17  7:26 ` Taco Hoekwater
2006-07-18 16:48 ` Mojca Miklavec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).