From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/6209 Path: main.gmane.org!not-for-mail From: Jose Luis Diaz Newsgroups: gmane.comp.tex.context Subject: Re[2]: MetaPost question Date: Sun, 18 Nov 2001 14:17:49 +0100 Sender: owner-ntg-context@let.uu.nl Message-ID: <73176231754.20011118141749@telecable.es> References: <190113640906.20011117205442@telecable.es> <20011118125734.B20785@bar.loria.fr> Reply-To: Jose Luis Diaz NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035396750 8512 80.91.224.250 (23 Oct 2002 18:12:30 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 18:12:30 +0000 (UTC) Cc: ConTeXt Mailing List Original-To: "Denis B. Roegel" In-Reply-To: <20011118125734.B20785@bar.loria.fr> Xref: main.gmane.org gmane.comp.tex.context:6209 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:6209 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