[NTG-context] MPenvironment
Hi, I would like to get the Metapost Abcd to be bigger then the TeX Abcd (for all Metapost graphics). I thought that the command is \startMPenvironment .. \stopMPenvironment !?!? \startMPenvironment \switchtobodyfont[16pt] \stopMPenvironment \starttext Abcd \startMPcode label.lrt(textext(Abcd), (0cm,0.5cm)); \stopMPcode \stoptext Patrick ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] MPenvironment
On 4-10-2010 12:41, Patrick Gundlach wrote: Hi, I would like to get the Metapost Abcd to be bigger then the TeX Abcd (for all Metapost graphics). I thought that the command is \startMPenvironment .. \stopMPenvironment !?!? \startMPenvironment \switchtobodyfont[16pt] \stopMPenvironment \starttext Abcd \startMPcode label.lrt(textext(Abcd), (0cm,0.5cm)); label.lrt(textext(\tfa Abcd), (0cm,0.5cm)); \stopMPcode \stoptext Patrick ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] MPenvironment \def gives Parameters must be numbered consecutively
never try to do tricky stuff like definitions inside MPenvironement, because it is parsed and changed slightly. I'm learning that lesson too. Another one: don't use btex..etex instead use \sometxt. So I now try to use the MPenvironment only for font and size switching (e.g. if I want the figures to be in a smaller font). I wikified a small example of converting to \sometxt: http://wiki.contextgarden.net/Mpgraphic#startMPenvironment. It's probably not in the right place on the wiki though. \def\a{abc} \starttext \startMPcode label(\sometxt{\a},origin); \stopMPcode \stoptext Would that kind of approach satisfy your needs? It would. I've used this sed script to help me convert my standalone metapost files: sed 's/btex (.*) etex/\\sometxt{\1}/' standalone.mp But for the next chapter's figures, I'll write a python script that will do the other transformations: e.g. turn each beginfig into \startstaticMPfigure -- or is it \startstaticMPgraphic? I always have to check, hence I'll put it in a script and have *it* remember. I know that metafun was made for integrating backgrounds and the like, not for standalone figures, so it may seem strange to convert all of one's standalone figures into metafun figures and place them in the .tex source file. But I like having the source for the standalone figures in the same file near their use: it's figure--text integration (one theme of Tufte's books), done in the source file. -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1. ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] MPenvironment \def gives Parameters must be numbered consecutively
works ok ; maybe i should add that command to the core but anyhow you can wikify it Using btex..etex is becoming complex with all the interactions, so instead I wikified an example of converting from btex..etex to \sometxt -- preaching what I am trying to practice. Instead I'll use the MPenvironment just for font and size switching (e.g. to use a different size for figures than for main text). (i didn't expect users to cook up all kind of commands in environments; when i have to do that, I normally put them in an environment and load that in the mp graphic (since one loads tex files there) I hadn't thought of that. Do you mean something like (which I couldn't get to compile): \starttext \startreusableMPgraphic{fig} \def\hello{hhh} % perhaps in an environment file label(\sometxt{\hello}, origin); \stopreusableMPgraphic \reuseMPgraphic{fig} \stoptext -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1. ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] MPenvironment \def gives Parameters must be numbered consecutively
Sanjoy Mahajan wrote: This test file (beta 2006.09.28): 1.tex \starttext \startMPenvironment \def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}} \stopMPenvironment \startreusableMPgraphic{fig} label(btex sun etex, origin); \stopreusableMPgraphic \reuseMPgraphic{fig} \stoptext fails with the error: ! Parameters must be numbered consecutively. to be read again ## l.44 \global \loadfontfileoncetrue \def \2## 1##2{\vbox {\halign {\hfil \... 1-mpgraph.mp gets this figure definition: beginfig(1); verbatimtex \global \loadfontfileoncetrue \def \2##1##2{\vbox {\halign {\hfil \hfil \cr ##1\cr ##2\cr }}} etex; label(btex sun etex , origin); ; endfig; environments are saved in macros, therefore you end up in an argument mess \starttext \startbuffer[mp] \def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}} \stopbuffer \def\useMPenvironmentbuffer[#1]% {\expanded{\startMPenvironment\noexpand\readfile{\TEXbufferfile{\jobname}}{}{}}\stopMPenvironment} \useMPenvironmentbuffer[mp] \startreusableMPgraphic{fig} label(btex sun etex, origin); \stopreusableMPgraphic \reuseMPgraphic{fig} \stoptext works ok ; maybe i should add that command to the core but anyhow you can wikify it So the parameters in the definition are being doubled up by one of the transformations that inserts the verbatimtex..etex block. By the way, should the verbatimtex..etex block go outside the beginfig..endfig, as it would in a standalone MP file? If only for efficiency rather than MP reparsing it with each beginfig. depends, if you process them runtime, it does not matter, if you process graphics between runs, they may be some cary over effects, although the btex/etex snippets are grouped Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] MPenvironment ignored for btex..etex (or should I use sometxt)?
Sanjoy Mahajan wrote: Oh, wait, if metapost is fine with the file but ConTeXt isn't, then the error above must be from ConTeXt parsing the metapost code and seeing the \2, then complaining. So am I supposed to use the global option to \startMPenvironment? If it's needed in this case, I think it would be needed in every case (ConTeXt would see all the metapost uses of the definition). Or is btex deprecated and I should use \sometxt (except in loops)? Or am I just confused?! indeed commands in an mp environment are not expanded when writing an mp graphic to file; it's always a bit of a trade of (i didn't expect users to cook up all kind of commands in environments; when i have to do that, inormally put them in an environment and load that in the mp graphic (since one load tex files there) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] MPenvironment \def gives Parameters must be numbered consecutively
On 9/29/06, Sanjoy Mahajan wrote: This test file (beta 2006.09.28): 1.tex \starttext \startMPenvironment \def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}} \stopMPenvironment A lesson that I learned while trying to implement a few functions for gnuplot: never try to do tricky stuff like definitions inside MPenvironement, because it is parsed and changed slightly. I would also prefer if definitions and other commands inside MPenvironement would work as they were supposed to, but exactly this was one reason more why I like \sometxt so much now. You can create a definition anywhere in your TeX document and then use it inside \sometxt: \def\a{abc} \starttext \startMPcode label(\sometxt{\a},origin); \stopMPcode \stoptext Would that kind of approach satisfy your needs? (that being just another point of view from what Hans pointed out; Hans's approach might also be useful; although I admit that I will soon start mixing up all the different MP commands: MPinclusions, MPextensions, preambles, environment ... ) Mojca PS: that should go into another thread and is not that urgent since I found an ugly workaround, but anyway: is there a chance to access dimensions such as PageWidth, OverlayWidth ... and others inside MPextensions/inclusions? OverlayWidth is defined just behind the extensions/inclusions, which basically means that I can use it inside a graphic, but not inside macros defined in MPextensions. Any remedy for that? ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
[NTG-context] MPenvironment ignored for btex..etex (or should I use sometxt)?
I'm not sure what's going on here, but this file fails (2006.09.28 beta): [well I have a better idea now after writing out the whole email, see the end...] === 3.tex = \starttext \startMPenvironment \def\2{hello} \stopMPenvironment \startreusableMPgraphic{fig} label(btex \2 etex, origin); \stopreusableMPgraphic \reuseMPgraphic{fig} \stoptext = The error is (from 3.log): == error snippet === systems : begin file 3 at line 1 color : currentcolor (def) is not defined \openout7 = `3-mpgraph.mp'. ! Undefined control sequence. argument label(btex \2 etex, origin); \writecheckedMPgraphic ...icfalse \edef \ascii {#1 }\convertcommand \ascii \t... \startMPgraphic ...hic \writecheckedMPgraphic {#1} \stopwritingMPgraphic \handlereusableMPgraphic ...phic #3\stopMPgraphic \doifobjectssupportedelse ... \douseMPgraphic ...s [#1][#2]\getvalue {\@@MPG #1} {}\elabelgroup to be read again l.10 \reuseMPgraphic{fig} ? R etc. == error snippet === But 3-mpgraph.mp (produced after giving 'R' to enter nonstopmode) looks fine: === 3-mpgraph.mp lots of stuff beginfig(1); verbatimtex \global \loadfontfileoncetrue \def \2{hello} etex; label(btex \2 etex , origin); ; endfig; let end=mprunend; end. === 3-mpgraph.mp It processes by hand fine: $ mpost -mem=metafun 3-mpgraph ... 1 output file written: 3-mpgraph.1 (or by using the system(texmfstart ...) command in 3.log) Oh, wait, if metapost is fine with the file but ConTeXt isn't, then the error above must be from ConTeXt parsing the metapost code and seeing the \2, then complaining. So am I supposed to use the global option to \startMPenvironment? If it's needed in this case, I think it would be needed in every case (ConTeXt would see all the metapost uses of the definition). Or is btex deprecated and I should use \sometxt (except in loops)? Or am I just confused?! -Sanjoy `A society of sheep must in time beget a government of wolves.' -- Bertrand de Jouvenal ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
[NTG-context] MPenvironment \def gives Parameters must be numbered consecutively
This test file (beta 2006.09.28): 1.tex \starttext \startMPenvironment \def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}} \stopMPenvironment \startreusableMPgraphic{fig} label(btex sun etex, origin); \stopreusableMPgraphic \reuseMPgraphic{fig} \stoptext fails with the error: ! Parameters must be numbered consecutively. to be read again ## l.44 \global \loadfontfileoncetrue \def \2## 1##2{\vbox {\halign {\hfil \... 1-mpgraph.mp gets this figure definition: beginfig(1); verbatimtex \global \loadfontfileoncetrue \def \2##1##2{\vbox {\halign {\hfil \hfil \cr ##1\cr ##2\cr }}} etex; label(btex sun etex , origin); ; endfig; So the parameters in the definition are being doubled up by one of the transformations that inserts the verbatimtex..etex block. By the way, should the verbatimtex..etex block go outside the beginfig..endfig, as it would in a standalone MP file? If only for efficiency rather than MP reparsing it with each beginfig. -Sanjoy `A society of sheep must in time beget a government of wolves.' -- Bertrand de Jouvenal ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context