Value of Metapost variable as a label
Hello, First of all, Mojca thanks very much for the update about TikZ. (I could not find an option to reply in Context Garden mailing list). My new question is the following. I have the following code to generate the labels for the tick marks: for i = 0 step 5 until 45: draw (i,0)*u -- (i,-0.2)*u; label.bot(decimal(i) ,(i,-0.2)*u); endfor; As you can see I use "decimal(i)" to get the labels (0,5,10,... and so on). But the font of these numbers is not the same as when I use the "btex label_text etex" command, which I have set to palatino. How can I typeset the value of Metapost variables (such as "i" in this case), using tex commands. For example, if I had to typeset (n_{1},n{2},...,n_{100}), how could I do that. On page 63 of John Hobby's metapost manual, he talks about how this could be achieved using TEX.mp. I tried typing \input TEX before \starttext, however, I get the error "I can't find file `TEX;' If I put it within the \startuseMPgraphic and \stopuseMPgraphic, it still does not work. Do I have to download this from somewhere or does Context have another solution? Thanks very much.
On Sat, 21 Mar 2009, Curiouslearn wrote:
Hello,
First of all, Mojca thanks very much for the update about TikZ. (I could not find an option to reply in Context Garden mailing list).
My new question is the following. I have the following code to generate the labels for the tick marks:
for i = 0 step 5 until 45: draw (i,0)*u -- (i,-0.2)*u; label.bot(decimal(i) ,(i,-0.2)*u); endfor;
As you can see I use "decimal(i)" to get the labels (0,5,10,... and so on). But the font of these numbers is not the same as when I use the "btex label_text etex" command, which I have set to palatino. How can I typeset the value of Metapost variables (such as "i" in this case), using tex commands.
label.bot (textext(decimal(i)), (...)) ;
For example, if I had to typeset (n_{1},n{2},...,n_{100}), how could I do that.
label.bot (textext("$n_{" & decimal i & "}"), ... ) ; etc.
On page 63 of John Hobby's metapost manual, he talks about how this could be achieved using TEX.mp. I tried typing \input TEX before \starttext, however, I get the error "I can't find file `TEX;' If I put it within the \startuseMPgraphic and \stopuseMPgraphic, it still does not work. Do I have to download this from somewhere or does Context have another solution?
Use textext. Aditya
Curious Learn
For example, if I had to typeset (n_{1},n{2},...,n_{100}), how could I do that.
label.bot (textext("$n_{" & decimal i & "}"), ... ) ;
This however fails: k:=2; label.bot(textext("$1\over" & decimal k & "$"), (10,0)) ; with this error: 6401a0e1a39f3ee04c60209dc5/formats/cont-en-metafun.mem ! Use of \dospecialabout doesn't match its definition. l.1 \MPLIBsettext{415}{$1\dospecialabout 2 $} \processMPgraphic ...e \MPuserinclusions ;\!!es )} \global \settrue \METAFUNi...
Aditya Mahajan
This however fails: k:=2; label.bot(textext("$1\over" & decimal k & "$"), (10,0)) ;
Try with \frac instead.
Or prevent expansion of \over label.bot(textext("$1\noexpand\over" & decimal k & "$"), (10,0)) ; Why \atop or \choose do not need \noexpand? What is special about \over? Aditya Thanks, Eythan
On Mon, 23 Mar 2009, Eythan Weg wrote:
Aditya Mahajan
Sun, 22 Mar 2009 22:24:17 -0400 (EDT) On Mon, 23 Mar 2009, Mojca Miklavec wrote:
This however fails: k:=2; label.bot(textext("$1\over" & decimal k & "$"), (10,0)) ;
Try with \frac instead.
Or prevent expansion of \over
label.bot(textext("$1\noexpand\over" & decimal k & "$"), (10,0)) ;
Why \atop or \choose do not need \noexpand? What is special about \over?
It is redefined by ConTeXt to be a useful command in text mode. \starttext \section[sec:test] {Some section} See \over[sec:test] \stoptext Hans, is it OK to change the definitions in core-def to \ifnum\texengine=\luatexengine \ifx\in \undefined\else \let\normalmathin \in \unexpanded\def\in {\mathortext\normalmathin \dospecialin } \fi \ifx\at \undefined\else \let\normalmathat \at \unexpanded\def\at {\mathortext\normalmathat \dospecialat } \fi \ifx\about\undefined\else \let\normalmathabout\about \unexpanded\def\about{\mathortext\normalmathabout\dospecialabout} \fi \ifx\from \undefined\else \let\normalmathfrom \from \unexpanded\def\from {\mathortext\normalmathfrom \dospecialfrom } \fi \ifx\over \undefined\else \let\normalmathover \over \unexpanded\def\over {\mathortext\normalmathover \dospecialabout} \fi \fi (added \unexpanded). This is certainly useful for \in and \over, maybe not so much for the other three. Aditya
participants (5)
-
Aditya Mahajan
-
Curious Learn
-
Curiouslearn
-
eythanweg@gmail.com
-
Mojca Miklavec