Metapost + metaObjet connector label on arcs
Bonjour à tous, I hope I'm not too much out of topic, but I'm trying to put a metapost figure in a context file. I use a separate file for the figure to keep it independant, (and to avoid cumul of problems :-) The objectif is to build a graph by positionning some node (for now, it is just a circle) connecting them bu some ncarc connector (using metaObj) and the put label onto these arc. I know that one can do that using tree or matrix mataObj feature, but I'd want to be flexible on the node positions, Thank you very much for any help! -- Maurice Diamantini http://www.ensta.fr/~diam %%% START SAMPLE %%%%%%%%%%%%%%%%%%%%%%% input mp-tool ; % some initializations and auxiliary macros input mp-spec ; % macros that support special features input metaobj.mp ; % suffixe non indispensable ? beginfig(1) ; numeric u; u=1cm; z0=(0u,2u); z1=(3u,4u); z2=(6u,4u); % ... % I'll have to create my one metaObj (later) % newCircle.a1("") "circmargin(0.3u)"; % label(btex $x^2$ etex, z1); newCircle.a0(btex 0 etex) "circmargin(0.1u)"; newCircle.a1(btex 1 etex) "circmargin(0.1u)"; newCircle.a2(btex 2 etex) "circmargin(0.1u)"; a0.c = z0; a1.c = z1; a2.c = z2; % Question: how can I put a label on this arc??? ncarc(a0)(a1) "name(nc01)"; % The following doesn't work ! % ObjLabel.nc01(btex 0 etex) "labpos(0.75)", % "labdir(top)"; drawObj(a0,a1,a2,a3,a4,a5,a6); endfig ; end . %%% END SAMPLE %%%%%%%%%%%%%%%%%%%%%%%
On Wed, Oct 20, 2004 at 01:57:47PM +0200, Maurice Diamantini wrote:
I hope I'm not too much out of topic, but I'm trying to put a metapost figure in a context file. I use a separate file for the figure to keep it independant, (and to avoid cumul of problems :-)
The objectif is to build a graph by positionning some node (for now, it is just a circle) connecting them bu some ncarc connector (using metaObj) and the put label onto these arc.
I know that one can do that using tree or matrix mataObj feature, but I'd want to be flexible on the node positions,
You can attach named paths to objects and then labels these. Here is my first try, seems to work: \startMPinclusions input metaobj; \stopMPinclusions \startreusableMPgraphic{labeltest} newCircle.a(btex A etex); newCircle.b(btex B etex); a.c=origin; b.c=a.c+(1cm,2cm); ncline.b(a)(b) "name(ab)"; ObjLabel.b(btex $a\rightarrow b$ etex) "labpathname(ab)", "labangle(0)"; drawObj(a,b); \stopreusableMPgraphic \starttext \reuseMPgraphic{labeltest} \stoptext For more options for labels, see page 54ff of the metaobj manual. Greetings, Eckhart
Le 22 oct. 04, à 14:24, Eckhart Guthöhrlein a écrit :
You can attach named paths to objects and then labels these. Here is my first try, seems to work:
Thank very much Eckhart, I read the metaObj manual, but I didn't realised showing that one can attached a labelObj to arbitrary objects (just for Matrix and trees). Now it works ! It is my first Metapost figure (I am switching from pstricks). As graph (in the sens nodes + arcs, not curve functions) will be frequentjy used (at least by me). I am thinking about some highlevel class (using MetaObj) - class Node for creating node - class Arc for connecting nodes. The goal is that the data (coordinate, various labels, ...) will be as simple as possible. Also it should be easy to pick the Node and Arc class, and personnalide them gor its own graph. For now, I'm trying to anderstand how the label options works, A new problem is that the label sep is to big from thes arcs, and I'm not able to ajust it. The "labshift" option doesn't seem to work with ncarc, althought it works for the nodes. P.S. is one of the Metapost lists still alive? Here is the full exemple (with only 2 nodes) I don use the inline context feature because it doesnt work for me, and I have to work on several workstation, so I still stay (for now) with the indenpendent file I'm sorry for the "latex" line on a context list, but Metafun is not clean installed (texlive 2003), I wanting for the next texlive... And I hope context will be install by default with Metafun . Thank you very much. -- Maurice Diamantini, verbatimtex % -*-latex-*- %&latex \documentclass{article} \usepackage[latin1]{inputenc} \begin{document} \sffamily etex input mp-tool ; % some initializations and auxiliary macros input mp-spec ; % macros that support special features input metaobj.mp ; % suffixe non indispensable ? beginfig(1) ; % For now node positions will be hardcoded numeric u; u=1cm; z0=(0u,2u); z1=(3u,4u); % % verbatimtex \small etex; setCurveDefaultOption("arcangle", 25); % % building nodes of the graph. Nodes are object that arc will be able to % refere to. % Later, I will have to build my own Class "Activity" with some other % parameters (labels above and under the circle, ...) % newCircle.n0(btex \large 0 etex) "circmargin(0.1u)"; ObjLabel.n0(btex b0 etex) "labshift((0, -.5u))"; ObjLabel.n0(btex u0 etex) "labshift((0, .5u))"; n0.c = z0; newCircle.n1(btex \large 1 etex) "circmargin(0.1u)"; ObjLabel.n1(btex b1 etex) "labshift((0, -.5u))"; ObjLabel.n1(btex u1 etex) "labshift((0, .5u))"; n1.c = z1; % % build some Arcs, with various label or other parameters % I'll have to make some vardef fonction for that. % For now, all arcs related stuffs are in th esame place % % - Howto reduce the label separation ? ("labshift" doen't work) ncarc.n0(n0)(n1) "name(n0_n1)"; ObjLabel.n0(btex $\times$ etex) "labpathname(n0_n1)", "labpos(0.8)"; ObjLabel.n0(btex $0\rightarrow 1$ etex) "labpathname(n0_n1)", "labpos(0.8)", "labangle(0)", "labshift((0, -0.5u))", "labdir(bot)" ; ncarc.n1(n1)(n0) "name(n1_n0)"; ObjLabel.n1(btex $\times$ etex) "labpathname(n1_n0)", "labpos(0.8)"; ObjLabel.n1(btex $1\rightarrow 0$ etex) "labpathname(n1_n0)", "labpos(0.8)", "labangle(180)", "labdir(top)" ; drawObj(n0, n1); endfig ; end .
On Fri, Oct 22, 2004 at 06:35:54PM +0200, Maurice Diamantini wrote:
A new problem is that the label sep is to big from thes arcs, and I'm not able to ajust it. The "labshift" option doesn't seem to work with ncarc, althought it works for the nodes.
Hi, this was possibly corrected in an unreleased version of metaobj: http://www.loria.fr/~roegel/metaobj.mp D. Roegel
Le 24 oct. 04, à 20:30, Denis Roegel a écrit :
A new problem is that the label sep is to big from thes arcs, and I'm not able to ajust it. The "labshift" option doesn't seem to work with ncarc, althought it works for the nodes. ... this was possibly corrected in an unreleased version of metaobj: http://www.loria.fr/~roegel/metaobj.mp
Thank very much!! 1 - firstly, T've know solved my initial problem, and I've been able to build my first non-pstrick figure (thank to this mailing help). So the next points are not criticals for me. See them just as remarks or suggestions (but any help is still welcomme :-) 2 - about the "off topic": As denis is on this list, what is the best mailing for talking about metaObj Denis? 3 - about the metaObj prerelease: I suggest that the last package (metaobj.mp and its pdf doc) are not hidden, but accessible (and refered from Metapost page) from a public directory; The MetaObj package could be as important as Metapost itself for the ex-pstricks users; so it should be easy to get the last version 4 - about ConTeXt and Metapost: What should I put in the "verbatimtex ... etex" header to be able to use ConTexT in btex..etex instead of LaTex? (I don't want use (for now ) the "inside ConTeXt document" method for the sake of environnement robustness, and for reusability) 5 - about metapost: How can I build the string to give to TeX as in string str; str = "x^2" btex \large F = <str> etex or perhaps somthing like : string str; str = "btex \large F = " & str é " etex" eval(str) 6 - about Metaobj user class I'd have build two macros (see the end of this mail): - buildActivity(xxx) % buildActivity: % name: the name of the new node % inFig; figuure to put in the circle % botFig; figuure to put under the circle % topFig; figuure to put above the circle % coord : position of the center of the circle % Example : % buildActivity(n0, btex\large 0 etex, btex b0 etex, btex u0 etex, z0); from which I think I will be able to build a new more or less generic Node class with some options and default behavior, - buildArc(xxx) % buildArc(nodeSrc, nodeDst, labshift, labangle, labelFig) which was more difficult to tune (for me, as a Metapost beginner) Also I hadn't use it for my application because of the lack of genericity. In fact, Id'like to build a new class (newArc) which could be considere as an object by itself, with its own set of options. (in particular default connector should be ncline, but easy to change to support all the metaObj connector) I think these two macros could serve as a good exemple of the power of metaObj, and would be much more readable than psTricks (i.e. TeX langage) ! Thank you very much for these tools and for any other help, Maurice, -- http://www.ensta.fr/~diam/
Maurice Diamantini wrote:
4 - about ConTeXt and Metapost: What should I put in the "verbatimtex ... etex" header to be able to use ConTexT in btex..etex instead of LaTex? (I don't want use (for now ) the "inside ConTeXt document" method for the sake of environnement robustness, and for reusability)
normally nothing has to go in there you can make stand alond graphics with context doing: \setupcolors[state=start] \starttext \startMPpage your mp code \stopMPpage \stoptext That gives you a stand alone pdf graphic that you can embed later
5 - about metapost: How can I build the string to give to TeX as in
string str; str = "x^2" btex \large F = <str> etex
or perhaps somthing like :
string str; str = "btex \large F = " & str é " etex" eval(str)
no, btex etex is parsed and handles in special ways; this is why metafun has the textext macro 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 -----------------------------------------------------------------
Le 26 oct. 04, à 13:53, Hans Hagen a écrit :
Maurice Diamantini wrote:
4 - about ConTeXt and Metapost: What should I put in the "verbatimtex ... etex" header to be able to use ConTexT in btex..etex instead of LaTex? (I don't want use (for now ) the "inside ConTeXt document" method for the sake of environnement robustness, and for reusability)
normally nothing has to go in there you can make stand alond graphics with context doing:
\setupcolors[state=start] \starttext \startMPpage your mp code \stopMPpage \stoptext
That gives you a stand alone pdf graphic that you can embed later
The problem is probably due to my installation (texlive 2003 installed in a non standard directory) Everything works well but the previous code give me a write page. (should I put mp code between beginfig..endfig ?) If I do the magic (from http://contextgarden.net/Linux_Installation) texexec --make --alone --all en nl uk metafun mptopdf After some time it give me: `texexec.pl' not found. In fact, I've never been able to make the basic exemples about Metafun working.
...
no, btex etex is parsed and handles in special ways; this is why metafun has the textext macro
That is a good raison for using context with Metafun... as soon as installation works! Maurice,
Maurice Diamantini wrote:
\setupcolors[state=start] \starttext \startMPpage your mp code \stopMPpage \stoptext
That gives you a stand alone pdf graphic that you can embed later
The problem is probably due to my installation (texlive 2003 installed in a non standard directory) Everything works well but the previous code give me a write page. (should I put mp code between beginfig..endfig ?)
no, context adds those things itself
If I do the magic (from http://contextgarden.net/Linux_Installation)
texexec --make --alone --all en nl uk metafun mptopdf
After some time it give me:
`texexec.pl' not found.
In fact, I've never been able to make the basic exemples about Metafun working.
strange is there a file 'texexec' on your disk somewhere? otherwise, copy texexec.pl to texexec (no suffix) and put it someplace in you path 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 -----------------------------------------------------------------
Le 27 oct. 04, à 09:23, Hans Hagen a écrit :
Maurice Diamantini wrote:
If I do the magic (from http://contextgarden.net/Linux_Installation) texexec --make --alone --all en nl uk metafun mptopdf After some time it give me: `texexec.pl' not found. In fact, I've never been able to make the basic exemples about Metafun working.
strange
is there a file 'texexec' on your disk somewhere? otherwise, copy texexec.pl to texexec (no suffix) and put it someplace in you path
Yes (texexec works perfectly without Metafun) I had a problem with multiple versions wich I'v not yet solved. If I am only with the texlive version, I can do the texexec --make --alone --all en nl uk metafun mptopdf (in /usr/local/pack/tex/texlive/texmf-var/web2c) And all seems ok. But I don't get basic Metafun exemple to work. So, for now, T'll stay with the (partialy) working texlive distrib, (I can do LaTeX, ConTexT and Metapost :-) but I should think to change my full latex organisation to be able to use my own context distribution, but it should not interfere with the working latex distrib. I could adopt the 70 Moctet standolone context distrib for osx + linux if I can use it near the LaTeX standard distribution. So, thank you very much for your help, but I'll have to try again later, -- Maurice
participants (4)
-
Denis Roegel
-
Eckhart Guthöhrlein
-
Hans Hagen
-
Maurice Diamantini