From: Jose Luis Diaz <jldiaz@telecable.es>
Cc: ConTeXt Mailing List <ntg-context@ntg.nl>
Subject: Re[2]: MetaPost question
Date: Sun, 18 Nov 2001 14:17:49 +0100 [thread overview]
Message-ID: <73176231754.20011118141749@telecable.es> (raw)
In-Reply-To: <20011118125734.B20785@bar.loria.fr>
Hi Denis,
Denis> Build your string s with something like
Denis> s="$t_" & decimal(i) & "=" & decimal(t[i]) & "$";
Aha! I didn't know the decimal() operator, that is what I was looking
for. Thank you very much.
Denis> and then write
Denis> label.bot(TEX s,(0,t[i]*u))
Denis> and don't forget input TEX at the beginning of your file.
This works fine. However it has several drawbacks:
1) It doesn't work if I want to use LaTeX macros or packages for the
typeset material. I managed to work around this with a macro similar
to TEX, as follows:
vardef LATEX primary s =
write "verbatimtex" to "mptextmp.mp";
write "\documentclass[10pt]{book}" to "mptextmp.mp";
%
% write the required \usepackage here
%
write "\begin{document}" to "mptextmp.mp";
write "etex" to "mptextmp.mp";
write "btex "&s&" etex" to "mptextmp.mp";
write EOF to "mptextmp.mp";
scantokens "input mptextmp"
enddef;
2) The process for typesetting the labels is very slow. It requires
the generation and processing of an independent metapost file for
each label. And these can't be reutilized for subsequent metapost
runnings (since the same .mpx is overwritten for each label).
3) The results given by my macro LATEX or by the metapost macro TEX
are typeset, in general, in a different font than the rest of the
metapost document. For example, assume that in my main metapost file
I include some verbatimtex for changing the default fonts. I would
have to repeat this code inside the TEX/LATEX macro for achieving the
same fonts in the labels generated via these macros.
So I would like to avoid is possible the methods using the TEX macros.
I was studying the source code of "format.mp", which is used by
mpgraph for typesetting the labels for the plots. The method used by
"format.mp" does not require the TEX macro, and then it uses
consistently the same typefaces among all the figures, and it is
processed faster. However it is very tricky and not very general. It
seems to be targeted explicitly for writing numbers in scientific
notation.
I was able to adapt some of the code that format.mp used for
typesetting the exponents of the scientific notation, for my
particular case of typesetting subindexes. This is the code, just in
case someone could be interested:
%-------------------------------------------------------
input format; % For having the macro Fline_up_
vardef subindexed(expr t, i) =
% t is the text to be subindexed
% i is an integer number which will appear in the subindex
save scalesub, lowersub,fontsub, e, p;
numeric lowersub, scalesub; picture e, p; string fontsub;
e:=btex ${}_1$ etex; % Build a "sample" subindex
for p within e: % for looking up some parameters
fontsub := fontpart p; % look up the font
scalesub := xxpart p; % the scale
lowersub := ypart llcorner p; % and the baseline
exitif true;
endfor;
% Create a picture with the text for our subindex
p:=nullpicture;
addto p also (decimal i infont fontsub scaled scalesub
shifted (0,lowersub));
% Build the complete text, subindex included
Fline_up_(t,p) % This is a macro defined in format.mp which
% link together several pictures
enddef;
%-----------------------------------------------------------
Example of use:
for i=1 upto 10:
label(subindexed(btex $\beta$ etex, i), (i*1cm, i*.5cm));
endfor;
This works as expected, but is very specific and rather clumsy. Well,
I guess that there is no a better way of doing this, since "mpgraph"
itself uses this method...
Thanks again for your solution, Denis.
--
Saludos,
Jose mailto:jldiaz@telecable.es
prev parent reply other threads:[~2001-11-18 13:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-17 19:54 Jose Luis Diaz
2001-11-18 6:18 ` Johannes H?sing
2001-11-18 11:57 ` Denis B. Roegel
2001-11-18 13:17 ` Jose Luis Diaz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73176231754.20011118141749@telecable.es \
--to=jldiaz@telecable.es \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).