Re: [NTG-context] Struggling with ConTeXt

2012-08-22 Thread Olivier Binda

Thank you for the tips.

Here, I cleaned up the code some more (sorry to have left stuff over 
last time),.


I added some explanations to make my issue clearer


\startusableMPgraphic{myFrame}
   draw OverlayBox withpen pencircle scaled 1pt withcolor green;
   draw (currentpicture enlarged 2cm) withcolor red withpen pencircle 
scaled 2pt;

\stopusableMPgraphic

\defineoverlay[myOverlay][\useMPgraphic{myFrame}]
\defineframedtext[myStatement][frame=off]
\setupframedtexts[myStatement][background=myOverlay,offset=overlay,autowidth=force]
\starttext
\framed[strut=no]{\startmyStatement FIRST TEST\stopmyStatement}
In the first test, I would like the black box to have the dimensions of 
the red box.


\blank[big,big,big,big,big,big,big,big,big,big]

\placefigure[left,none]{}{\startmyStatement SECOND TEST\stopmyStatement}
In the second test, I'm going to demonstrate the issue by flowing text 
around the framed text, the green color {\em and the red color} 
shouldn't touch the flowing text as I want the float box to include the 
text box {\em and the overlay box.}



Best regards,
Olivier
___
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] Struggling with ConTeXt

2012-08-22 Thread Aditya Mahajan

On Wed, 22 Aug 2012, Olivier Binda wrote:


Thank you for the tips.

Here, I cleaned up the code some more (sorry to have left stuff over last 
time),.


I added some explanations to make my issue clearer


\startusableMPgraphic{myFrame}
  draw OverlayBox withpen pencircle scaled 1pt withcolor green;
  draw (currentpicture enlarged 2cm) withcolor red withpen pencircle scaled 
2pt;

\stopusableMPgraphic

\defineoverlay[myOverlay][\useMPgraphic{myFrame}]
\defineframedtext[myStatement][frame=off]
\setupframedtexts[myStatement][background=myOverlay,offset=overlay,autowidth=force]
\starttext
\framed[strut=no]{\startmyStatement FIRST TEST\stopmyStatement}
In the first test, I would like the black box to have the dimensions of the 
red box.


\defineframed[myStatement][background=myOverlay, offset=overlay,width=fit]
\dontleavehmode\framed[strut=no, offset=2cm]{\myStatement{FIRST TEST}}
In the first test, I would like the black box to have the dimensions of 
the red box.



\blank[big,big,big,big,big,big,big,big,big,big]

\placefigure[left,none]{}{\startmyStatement SECOND TEST\stopmyStatement}
In the second test, I'm going to demonstrate the issue by flowing text around 
the framed text, the green color {\em and the red color} shouldn't touch the 
flowing text as I want the float box to include the text box {\em and the 
overlay box.}


\placefigure[left,none]{}{\framed[strut=no,offset=2cm]{\myStatement{SECOND 
TEST}}}



If needed, you can hide this behind macros:

\def\startmyStatement
{\framed[struct=no, offset=2cm]\bgroup\myStatement\bgroup}

\def\stopmyStatement
   {\egroup\egroup}

Aditya
___
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] Struggling with ConTeXt

2012-08-22 Thread Olivier Binda

On 22/08/2012 10:42, Aditya Mahajan wrote:

On Wed, 22 Aug 2012, Olivier Binda wrote:


Thank you for the tips.

Here, I cleaned up the code some more (sorry to have left stuff over 
last time),.


I added some explanations to make my issue clearer


\startusableMPgraphic{myFrame}
  draw OverlayBox withpen pencircle scaled 1pt withcolor green;
  draw (currentpicture enlarged 2cm) withcolor red withpen pencircle 
scaled 2pt;

\stopusableMPgraphic

\defineoverlay[myOverlay][\useMPgraphic{myFrame}]
\defineframedtext[myStatement][frame=off]
\setupframedtexts[myStatement][background=myOverlay,offset=overlay,autowidth=force] 


\starttext
\framed[strut=no]{\startmyStatement FIRST TEST\stopmyStatement}
In the first test, I would like the black box to have the dimensions 
of the red box.


\defineframed[myStatement][background=myOverlay, 
offset=overlay,width=fit]

\dontleavehmode\framed[strut=no, offset=2cm]{\myStatement{FIRST TEST}}
In the first test, I would like the black box to have the dimensions 
of the red box.



\blank[big,big,big,big,big,big,big,big,big,big]

\placefigure[left,none]{}{\startmyStatement SECOND TEST\stopmyStatement}
In the second test, I'm going to demonstrate the issue by flowing 
text around the framed text, the green color {\em and the red color} 
shouldn't touch the flowing text as I want the float box to include 
the text box {\em and the overlay box.}


\placefigure[left,none]{}{\framed[strut=no,




offset=2cm


Thanks for the help. But I'm affraid that this won't do as I won't 
know/I am not supposed to know the dimensions of the bounding box of the 
overlay I'll use.

:/

For the sake of the minimal example, I only enlarged the picture by 2cm, 
but in real production situations,
the bounding box is going to be enlarged by random offset, because the 
overlay will have various parts with weird shapes (super ellipse, 
squeezed rectangles) that go beyond the original text boundaries (like 
in the Zapf frametext example of the Context manual : the title is 
protruding out of the main box and if you put weird stuff in there, you 
won't know the dimensions).


I don't want to manually calculate those offsets, I would like metapost 
to pass it's bounding box dimensions for the overlay to context so that 
it automatically applies the correct offset to the text+overlay






]{\myStatement{SECOND TEST}}}


If needed, you can hide this behind macros:

\def\startmyStatement
{\framed[struct=no, offset=2cm]\bgroup\myStatement\bgroup}

\def\stopmyStatement
   {\egroup\egroup}

Aditya
___ 

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
___ 





___
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] Struggling with ConTeXt

2012-08-21 Thread Aditya Mahajan

On Tue, 21 Aug 2012, Olivier Binda wrote:

3) I'm flowing text around mathematical text with graphic ornaments (overlay) 
but the bounding box from metapost (red) and from TeX (black) on the 
following minimal example aren't the same which produce all kinds of flowing 
text issues.
is there a way/an option for framedtexts with overlay to get the max 
width/height size of the main content + overlays ?


Can you create a minimal example showing what you are trying to do? The 
following example is a bit confusing (where is \MPstring{Content} set? Why 
use framedtext instead of framed? What is \framed[fit] supposed to do? 
etc).



\startusableMPgraphic{myFrame}
 numeric o, l, m ; path a, b ; pair c ;
 picture d; d = textext.rt(\MPstring{Content}) ;
 draw (unitsquare xyscaled (OverlayWidth,OverlayHeight) shifted 
(-OverlayWidth/2,-OverlayHeight/2)) withpen pencircle scaled 1pt withcolor 
green;


You could also use

   draw OverlayBox withpen ...


  draw (d enlarged 2cm) withcolor red withpen pencircle scaled 2pt;
  draw boundingbox currentpicture withpen pencircle scaled .1mm dashed 
evenly withcolor blue ;

\stopusableMPgraphic

\defineoverlay[myOverlay][\useMPgraphic{myFrame}]
\defineframedtext[myStatement][frame=off]
\setupframedtexts[myStatement][backgroundcolor=lightgray,background=myOverlay,width=\textwidth,autowidth=force]
\starttext
\framed[fit]{\startmyStatement
TEST
\stopmyStatement}
\stoptext


You can try \framed[strut=no]{...} and add 
\setupframedtext[...][offset=overlay]. See 
http://wiki.contextgarden.net/Command/setupframed for details.


Aditya


___
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] Struggling with ConTeXt

2012-08-20 Thread Olivier Binda

Many thanks for the enlightening answers.

The explanations about xml solved question 1 and \startmatrix\stopmatrix 
solved question 4.


I'm now crunching xml input and handling it half in lua and half in tex 
(and I'm verry happy about it).


I'm still struggling with a few points though (with context standalone 
beta on ubuntu):


3) I'm flowing text around mathematical text with graphic ornaments 
(overlay) but the bounding box from metapost (red) and from TeX (black) 
on the following minimal example aren't the same which produce all kinds 
of flowing text issues.
is there a way/an option for framedtexts with overlay to get the max 
width/height size of the main content + overlays ?



\startusableMPgraphic{myFrame}
  numeric o, l, m ; path a, b ; pair c ;
  picture d; d = textext.rt(\MPstring{Content}) ;
  draw (unitsquare xyscaled (OverlayWidth,OverlayHeight) shifted 
(-OverlayWidth/2,-OverlayHeight/2)) withpen pencircle scaled 1pt 
withcolor green;

  draw (d enlarged 2cm) withcolor red withpen pencircle scaled 2pt;
   draw boundingbox currentpicture withpen pencircle scaled .1mm dashed 
evenly withcolor blue ;

\stopusableMPgraphic

\defineoverlay[myOverlay][\useMPgraphic{myFrame}]
\defineframedtext[myStatement][frame=off]
\setupframedtexts[myStatement][backgroundcolor=lightgray,background=myOverlay,width=\textwidth,autowidth=force]
\starttext
\framed[fit]{\startmyStatement
TEST
\stopmyStatement}
\stoptext


3b) I found a dirty workaround by making metapost draw the texts and the 
graphics (through mpstring) but then, i can't embed graphics in my 
Tex-text.

Is there a way to have graphics inside MPstrings that goes inside metapost ?



About question 2, Context doesn't produce svg okey...but tikz and 
metapost can produce svg.
So, is there a ConteXt setup/systems calls/a  (simple or not) workaround 
to make metapost/tikz produce svg files ?

Like some script that I could run on my snipets ?

I would really like to produce svg from my metapost/tikz pictures



Best regards,
Olivier

___
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] Struggling with ConTeXt

2012-08-05 Thread Thomas A. Schmitz

On 08/03/2012 04:50 PM, Sietse Brouwer wrote:

I'm looking for a place to put it, but I'm handicapped by the fact
that I know nothing about ConTeXt's XML handling. I don't even know
whether the question+answer is about general lxml.att usage, or a
howto for some specific result. Can somebody tell me:

Is the lxml namespace common and populated enough that it would be
worth creating
http://wiki.contextgarden.net/XML_manipulation  to document the lxml.*
functions, much like
http://wiki.contextgarden.net/String_Manipulation  documents string.*
and lpeg.*, and
[[table_manipulation]] documents table.*, and
[[Extensions_to_the_Lua_I/O_library]] documents io.*. (Consistent page
names? Maybe for Christmas (or St. Nicholas), if you're very good.)

Or is there a more suitable page among the links on
http://wiki.contextgarden.net/XML?

Cheers,

Sietse
___


Hi Sietse,

I have reorganized the XML page on the wiki a bit. The separation 
between mkii and mkiv wasn't visible enough, I think. It would now make 
sense to add a category manipulating xml in lua code (or something to 
that effect) under the mkiv heading and then add the lxml code.


All best

Thomas

--
Prof. Dr. Thomas A. Schmitz
Abteilung für Griechische und Lateinische Philologie
Universität Bonn
Am Hof 1e
53113 Bonn
http://www.philologie.uni-bonn.de/personal/schmitz
___
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] Struggling with ConTeXt

2012-08-03 Thread Olivier Binda

On 02/08/2012 17:43, Aditya Mahajan wrote:

On Thu, 2 Aug 2012, Olivier Binda wrote:


1) does lxml.att(#1,some tag)  really work ?


I don't know, but please provide a complete minimal example.

\startxmlsetups xml:test
\xmlsetsetup{maths}{c}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:c
\ctxlua{
title = test=..lxml.att(#1,title)
context(title)}%
\stopxmlsetups

\starttext
test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c 
title=My title/c} {}

\stoptext
\endinput

Context gives  the can't concatenate with a nil value Luatex error 
when processing this snipet...but if I ignore the error, the pdf output 
is okey

___
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] Struggling with ConTeXt

2012-08-03 Thread Hans Hagen

On 3-8-2012 08:35, Olivier Binda wrote:

On 02/08/2012 17:43, Aditya Mahajan wrote:

On Thu, 2 Aug 2012, Olivier Binda wrote:


1) does lxml.att(#1,some tag)  really work ?


I don't know, but please provide a complete minimal example.

\startxmlsetups xml:test
\xmlsetsetup{maths}{c}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:c
\ctxlua{
title = test=..lxml.att(#1,title)
context(title)}%
\stopxmlsetups

\starttext
test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c
title=My title/c} {}
\stoptext
\endinput

Context gives  the can't concatenate with a nil value Luatex error
when processing this snipet...but if I ignore the error, the pdf output
is okey


the functions in the lxml namespace already print to context and return 
no value so you effectively appends nil which is invalid


also, when used in a context run the default serializer is also piping 
to context so if you want otherwise you need to prefix with xml:// 
(which is an indication that in principle there can be many variants)


here are some valid solutions (whatch the lxml.id):

\startxmlsetups xml:test
\xmlsetsetup{#1}{c}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:test}

\startxmlsetups xml:c
\ctxlua{title = test= .. 
xml.filter(lxml.id(#1),xml://./attribute(title)) context(title)}

\par
\ctxlua{context(test=) 
xml.filter(lxml.id(#1),./attribute(title))}

\par
\ctxlua{context(test=) lxml.att(#1,title)}
\stopxmlsetups

\starttext

\xmlprocessdata
  {maths}
  {?xml version='1.0' standalone='yes?c title=My title/c}
  {}

\stoptext

You can wikify this ...

Hans


-
  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] Struggling with ConTeXt

2012-08-03 Thread Sietse Brouwer
Olivier Binda wrote:
 1) does lxml.att(#1,some tag)  really work ?

Hans Hagen wrote:
[various solutions]
 You can wikify this ...

I'm looking for a place to put it, but I'm handicapped by the fact
that I know nothing about ConTeXt's XML handling. I don't even know
whether the question+answer is about general lxml.att usage, or a
howto for some specific result. Can somebody tell me:

Is the lxml namespace common and populated enough that it would be
worth creating
http://wiki.contextgarden.net/XML_manipulation to document the lxml.*
functions, much like
http://wiki.contextgarden.net/String_Manipulation documents string.*
and lpeg.*, and
[[table_manipulation]] documents table.*, and
[[Extensions_to_the_Lua_I/O_library]] documents io.*. (Consistent page
names? Maybe for Christmas (or St. Nicholas), if you're very good.)

Or is there a more suitable page among the links on
http://wiki.contextgarden.net/XML?

Cheers,

Sietse
___
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] Struggling with ConTeXt

2012-08-03 Thread Hans Hagen

On 3-8-2012 16:50, Sietse Brouwer wrote:

Olivier Binda wrote:

1) does lxml.att(#1,some tag)  really work ?


Hans Hagen wrote:
[various solutions]

You can wikify this ...


I'm looking for a place to put it, but I'm handicapped by the fact
that I know nothing about ConTeXt's XML handling. I don't even know
whether the question+answer is about general lxml.att usage, or a
howto for some specific result. Can somebody tell me:

Is the lxml namespace common and populated enough that it would be
worth creating
http://wiki.contextgarden.net/XML_manipulation to document the lxml.*
functions, much like
http://wiki.contextgarden.net/String_Manipulation documents string.*
and lpeg.*, and
[[table_manipulation]] documents table.*, and
[[Extensions_to_the_Lua_I/O_library]] documents io.*. (Consistent page
names? Maybe for Christmas (or St. Nicholas), if you're very good.)


indeed. the lxml namespace is rather filled up and can have its own page 
(maybe Hans vd Meer can help with that as he has played alot with the code)


Hans

-
  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] Struggling with ConTeXt

2012-08-02 Thread Aditya Mahajan

On Thu, 2 Aug 2012, Olivier Binda wrote:


1) does lxml.att(#1,some tag)  really work ?


I don't know, but please provide a complete minimal example.


2) I'm trying to export to xml and have set

\setupbackend[export=yes, xhtml=yes, css=mkiv-export.css]

But
a) my Metafun/Tikz  pictures aren't exported to svg :/


Currently ConTeXt does not export Metafun/Tikz pictures to svg.

b) the exported xml has namespaces problems (like error on line 63 at column 
20: Namespace prefix m on math is not defined error on line 64 at column 22: 
Namespace prefix m on mrow is not defined)


What am I doing wrong ? (I'm compiling with context mydoc.tex)


Could it be a validator error? The 11th line of my test document contains:

document xmlns:m=http://www.w3.org/1998/Math/MathML;

which defines the 'm' namespace.

Is there some \csname tex4ht\endcsname command or some other directive that I 
should use to get my xml export right ?


ConTeXt does not use tex4ht!

Am I missing some namespace commands (there are lots of m:math and m:mrow 
mathml tags int the exported xml source, this smells like a tex4ht issue)




See above.

3) I have defined some framed text with metafun overlays (like in the Context 
manual)

and I'm trying to type something like

but it's not really satisfying. (hate to lose vertical space with wandering 
blank spaces)


Is there a better way ?


Please provide a complete minimal example.


4) I'm trying to port the following TeX code to ConTeXt

$$\eqalign{x=1\cr y=2\cr}\qquad \hbox{haha}$$

it looks like \startformula\startalign.. doesn't allow me to do that
I somehow managed to have it by typing

\startformula
\vcenter{\starttabular[|rM|lM|]
\NC x \NC =1\NC\NR
\NC y \NC =2\NC\NR
\stoptabular}\qquad\text{haha}
\stopformula

the pdf export is fine, but the xml export is awfull (because of \vcenter I 
guess)


a) Is there a way to use tables inside math mode alongside other stuff (would 
be handy) ?
b) what is the correct way to type the previous text, so the pdf and xml are 
fine in Context ?


Why not use \startmathalign etc. See:

http://dl.contextgarden.net/myway/mathalign.pdf

Aditya
___
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] Struggling with ConTeXt

2012-08-02 Thread Aditya Mahajan

On Thu, 2 Aug 2012, Aditya Mahajan wrote:


4) I'm trying to port the following TeX code to ConTeXt

$$\eqalign{x=1\cr y=2\cr}\qquad \hbox{haha}$$

it looks like \startformula\startalign.. doesn't allow me to do that
I somehow managed to have it by typing

\startformula
\vcenter{\starttabular[|rM|lM|]
\NC x \NC =1\NC\NR
\NC y \NC =2\NC\NR
\stoptabular}\qquad\text{haha}
\stopformula

the pdf export is fine, but the xml export is awfull (because of \vcenter I 
guess)


a) Is there a way to use tables inside math mode alongside other stuff 
(would be handy) ?
b) what is the correct way to type the previous text, so the pdf and xml 
are fine in Context ?


Why not use \startmathalign etc. See:

http://dl.contextgarden.net/myway/mathalign.pdf


Sorry, I meant, \startmathmatrix (or \startmatrix) etc.

Aditya
___
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
___