Re: [NTG-context] printing the current date

2021-01-10 Thread Fabrice L


> Le 10 janv. 2021 à 13:23, Peter Münster  a écrit :
> 
> Hi,
> 
> I would expect, that \currentdate prints the current date, but it does
> not:
> 
> --8<---cut here---start->8---
> \starttext
> \date[d=1]% first day of this month, ok
> 
> \date% again first day, last parameters are used, this is ok
> 
> \currentdate% same as \date, but I would expect the day of today...
> \stoptext
> --8<---cut here---end--->8---
> 
> How could I print the current date please?

For exemple:

 \date[][weekday,day,month,year] and \currenttime[h,{\,:\,},m] 

F.

> 
> TIA for any hints,
> -- 
>   Peter
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] MetaFun labels and xsized

2020-12-25 Thread Fabrice L
Hi,

> Le 25 déc. 2020 à 12:30, Pablo Rodriguez  a écrit :
> 
> Dear list,
> 
> I have this minimal MetaFun sample (the only one in my real document):
> 
>  \setupbodyfont[pagella]
>  \starttext
>  \startMPcode
>  pair a ; a := (1, 1) ;
>  pair b ; b := (1, 10) ;
>  pair c ; c := (10, 10) ;
>  pair d ; d := (10, 1) ;
>  draw (a--b--c--d--a) xsized .75TextWidth;
> 
>  draw thelabel.lft("α",a) ;
>  draw thelabel.lft("β",b) ;
>  draw thelabel.top("γ",c) ;
>  draw thelabel.rt("δ",d) ;
>  \stopMPcode
>  \stoptext
> 
> Is there a way to relate adapt the labels to the xsized positions used?

I’m sure somebody could find a more elegant solution, but here is a simple one:

 \setupbodyfont[pagella]
 \starttext
 \startMPcode
 pair a ; a := (1, 1) ;
 pair b ; b := (1, 10) ;
 pair c ; c := (10, 10) ;
 pair d ; d := (10, 1) ;
 path square ; 
 square := (a--b--c--d--cycle) xsized .75TextWidth ;
 
 draw square xsized .75TextWidth;

 draw thelabel.lft("α",point 0 of square) ;
 draw thelabel.lft("β",point 1 of square) ;
 draw thelabel.top("γ",point 2 of square) ;
 draw thelabel.rt("δ",point 3 of square) ;
 \stopMPcode
 \stoptext

Fabrice.

> 
> Many thanks for your help,
> 
> Pablo
> --
> http://www.ousia.tk
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Check if two paths intersect in Metafun

2020-12-25 Thread Fabrice L
Hi,

> Le 25 déc. 2020 à 08:48, Jairo A. del Rio  a écrit :
> 
> Hi, list. I've got a question about paths and intersections. The following:
> 
> \starttext 
> \startMPpage
> path p[];
> 
> p[1] = fullcircle scaled 2cm;
> p[2] = unitsquare shifted (4cm,6cm);
> 
> if (known (p[1] intersectionpoint p[2])):
> 
> draw textext("yes");
> 
> else:
> 
> draw textext("no");
> fi;
> 
> \stopMPpage
> \stoptext
> 
> yields an error message: "The paths don't intersect". Is there a way to 
> intercept this error message and trigger an action instead? Thank you in 
> advance.

Instead of using « intersectionpoint » use « Intersectiontimes », this will 
give you the « time » of the intersection of the two paths. If the paths do not 
intersect, than the value is (-1,-1). So you could do something like:

pair checkintersec ;
checkintersec := p[1] intersectiontimes p[2] ;
If xpart(checkintersec) <> -1 : 
draw textext("yes »);
else: 
draw textext(« non »);
fi;

Fabrice.

> 
> Best regards,
> 
> Jairo
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metafun: how to draw a straight line past the end points

2020-12-09 Thread Fabrice L
Hi,

> Le 9 déc. 2020 à 10:57, Otared Kavian  a écrit :
> 
> Hi,
> 
> I have a silly question: given two points in the plane
>   z1 = (1cm,3cm) ;
>   z2 = (5cm, 9cm) ;
> the command
>   draw z1 -- z2 withpen pencircle scaled .5pt ;
> draws the line segment joining z1 and z2. How could I draw the line segment 
> which goes a little further (say 1cm) than both the end points of this 
> segment (that is in this example, a point before z1 and a point after z2 on 
> the straight line) .
> Indeed it is possible to write the equation of the line and then compute by 
> hand the coordinates of the new end points, but I think there is a simpler 
> way in Metafun to do this.

The shortened operation is the solution ! See MetaFun manual section 1.18

\starttext
\startMPpage
z1 = (1cm,3cm) ;
z2 = (5cm, 9cm) ;
draw (z1--z2) shortened -1cm  withcolor blue ;
draw (z1--z2) withcolor red ;

\stopMPpage
\stoptext

Fabrice.

> 
> Thanks for any help: Otared
> 
> 
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Fabrice L
Keith,

> Le 26 nov. 2020 à 12:12, Keith McKay  a écrit :
> Thanks Fabrice and Hans.
> 
> I now see I can simplify some lines of the code:
> 
> pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); now becomes pp:= a[i];
> 
> and
> 
> pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); now becomes pp := 
> pp --- a[i +1] ;
> 
> However I still have the problem in the calculation of xcoord and ycoord 
> which are used in the creation of path pp:
>   
>   for squig = 1 step 1 until 15:
> 
>   xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
> 
>   ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
> 
>   pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
> 
>   endfor;
> 
> I'm adding a small random amount to the x and ypart of the pair a[i] to 
> produce a path that is like a squiggle (gribouiller in French, according to 
> Google). I have to use cf to convert to the x and yparts to centimeters since 
> they seem to loose the centimeter units on separation. I can't see anyway 
> round this, or am I missing something?
> 
> Thanks
> Keith McKay

First « uniformdeviate(1) - 0.5 » could be modified to « uniformdeviate(0.5)».

To add noise, you can use the randomized function of Metafun. For exemple, you 
can write:

draw pp randomized 1cm ;

Fabrice.



> 
> On 26/11/2020 15:19, Fabrice L wrote:
>> Hi keith,
>> 
>>> Le 26 nov. 2020 à 10:09, Keith McKay >> <mailto:mckaymeis...@gmail.com>> a écrit :
>>> 
>>> Hi,
>>> 
>>> I have been using xpart and ypart to extract these values from pairs of 
>>> points in a path but I wasn't getting the correct result. I was expecting:
>>> 
>>> pair (2cm, 11cm) to give xpart 2 and ypart 11
>>> 
>>> However I was getting:
>>> 
>>> pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096
>>> 
>>> After much head scratching and reading the MetaPost and MetaFun manuals, I 
>>> realised that the units of xpart or ypart are in Postcript points or Big 
>>> Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of 
>>> xpart or ypart in cm I would have to use a correction factor. I had made 
>>> the assumption that since the x and ypart in the pair was in cm that the 
>>> result would be in cm, but I see now that this is not the case. Will I have 
>>> to continue doing this or is there some magic within MetaFun which takes 
>>> account of the units in a pair and outputs the result of x and ypart in the 
>>> same units?
>>> 
>>> The MWE belows shows what I have been doing.
>>> 
>>> Thanks
>>> 
>>> Keith McKay
>>> 
>>> %%% MWE %%%
>>> \setuppapersize [A5, landscape][A4, portrait]
>>> \usecolors[crayola]
>>> \starttext
>>> \startMPpage
>>> StartPage;
>>> width := PaperWidth ; height := PaperHeight ; unit := cm ;
>>> numeric squig;
>>> pair a[]; a0 = (2cm,11cm);  a1 = (4cm,10cm);  a2 = (6cm,9cm);  a3 = 
>>> (8cm,8cm);
>>> show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
>>> applying correction factor (cf) %
>>> cf := 72/2.54; %Converts points/in to points/cm%
>>> path pp;
>>> for i = 0 step 1 until 3:
>>> pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
>>> for squig = 1 step 1 until 15:
>>> xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
>>> ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
>>> pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
>>> endfor;
>>> pp := pp --- cycle;
>>> if i < 3 :
>>> pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
>>> fi; 
>>> f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
>>> colour %
>>> draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
>>> withcolor (f[white,\MPcolor{BurntSienna}]);
>>> endfor;
>>> StopPage;
>>> \stopMPpage
>>> \stoptext
>>> %%
>>> 
>> 
>> MetaPost (MetaFun) is taking care of everything regarding units. As you ave 
>> discovered, everything is translated to a unique internal dimension. So you 
>> can write:
>> 
>>  a := (1cm,2in) ;
>> 
>> with no problem. The « cm » and « in » parts of the exp

Re: [NTG-context] Units of xpart and ypart of a pair in MetaFun

2020-11-26 Thread Fabrice L
Hi keith,

> Le 26 nov. 2020 à 10:09, Keith McKay  a écrit :
> 
> Hi,
> 
> I have been using xpart and ypart to extract these values from pairs of 
> points in a path but I wasn't getting the correct result. I was expecting:
> 
> pair (2cm, 11cm) to give xpart 2 and ypart 11
> 
> However I was getting:
> 
> pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096
> 
> After much head scratching and reading the MetaPost and MetaFun manuals, I 
> realised that the units of xpart or ypart are in Postcript points or Big 
> Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of xpart 
> or ypart in cm I would have to use a correction factor. I had made the 
> assumption that since the x and ypart in the pair was in cm that the result 
> would be in cm, but I see now that this is not the case. Will I have to 
> continue doing this or is there some magic within MetaFun which takes account 
> of the units in a pair and outputs the result of x and ypart in the same 
> units?
> 
> The MWE belows shows what I have been doing.
> 
> Thanks
> 
> Keith McKay
> 
> %%% MWE %%%
> \setuppapersize [A5, landscape][A4, portrait]
> \usecolors[crayola]
> \starttext
> \startMPpage
> StartPage;
> width := PaperWidth ; height := PaperHeight ; unit := cm ;
> numeric squig;
> pair a[]; a0 = (2cm,11cm);  a1 = (4cm,10cm);  a2 = (6cm,9cm);  a3 = (8cm,8cm);
> show xpart a[0], ypart a[0]; %Example of result from x and ypart before 
> applying correction factor (cf) %
> cf := 72/2.54; %Converts points/in to points/cm%
> path pp;
> for i = 0 step 1 until 3:
>   pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);
>   for squig = 1 step 1 until 15:
>   xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
>   ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);
>   pp := pp  .. {curl 100}(xcoord*cm, ycoord*cm);
>   endfor;
>   pp := pp --- cycle;
>   if i < 3 :
>   pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
>   fi; 
>   f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken 
> colour %
>   draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 
> withcolor (f[white,\MPcolor{BurntSienna}]);
> endfor;
> StopPage;
> \stopMPpage
> \stoptext
> %%
> 

MetaPost (MetaFun) is taking care of everything regarding units. As you ave 
discovered, everything is translated to a unique internal dimension. So you can 
write:

 a := (1cm,2in) ;

with no problem. The « cm » and « in » parts of the expression will become 
numbers to translate this number on the right unit. 
Fabrice.
> ___
> 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://context.aanhet.net 
> archive  : https://bitbucket.org/phg/context-mirror/commits/ 
> 
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] startCSV Wiki, Natural Table

2020-11-24 Thread Fabrice L


> Le 24 nov. 2020 à 13:36, Wolfgang Schuster 
>  a écrit :
> 
> Fabrice L schrieb am 24.11.2020 um 19:08:
>>> Le 24 nov. 2020 à 12:52, Wolfgang Schuster 
>>>  a écrit :
>>> 
>>> Fabrice L schrieb am 24.11.2020 um 18:44:
>>>> Hi,
>>>> I was using in the past (MKII) a snippet of code to produce (natural) 
>>>> tables from CSV. I was trying to compile my code with MKIV, but this does 
>>>> not work anymore. As a matter of fact, it doe snot work at all, nor MKII, 
>>>> nor MKIV (probably my error !).
>>>> So I came back to the wiki, where my code came from, and the code below is 
>>>> just a copy for the wiki. It is supposed to make a table with three 
>>>> columns, but there is only one column in the resulting table…  I admit I 
>>>> do not understand the code, but is there is missing \eTR somewhere ?
>>> Use the database module.
>>> 
>>> \usemodule[database]
>>> 
>>> \defineseparatedlist
>>>  [CSV]
>>>  [separator={,},
>>>  before=\bTABLE,
>>>   after=\eTABLE,
>>>   first=\bTR,
>>>last=\eTR,
>>>left=\bTD,
>>>   right=\eTD]
>>> 
>>> \starttext
>>> 
>>> \startCSV
>>> 1,2,3
>>> 3,5,6
>>> 7,8,9
>>> \stopCSV
>>> 
>>> \stoptext
>>> 
>>> Wolfgang
>> Wolfgang, thanks. I have seen the use if the database module on the wiki, 
>> but was trying to do without it, the reason is that my documents are often 
>> shared with colleagues, for which installation of modules is most often very 
>> difficult.
> 
> There is nothing to install because the database module is part of ConTeXt.

I see… wonderfull ! Thanks a lot for the help. 
> 
> Wolfgang

Fabrice.___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] startCSV Wiki, Natural Table

2020-11-24 Thread Fabrice L


> Le 24 nov. 2020 à 12:52, Wolfgang Schuster 
>  a écrit :
> 
> Fabrice L schrieb am 24.11.2020 um 18:44:
>> Hi,
>> I was using in the past (MKII) a snippet of code to produce (natural) tables 
>> from CSV. I was trying to compile my code with MKIV, but this does not work 
>> anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV 
>> (probably my error !).
>> So I came back to the wiki, where my code came from, and the code below is 
>> just a copy for the wiki. It is supposed to make a table with three columns, 
>> but there is only one column in the resulting table…  I admit I do not 
>> understand the code, but is there is missing \eTR somewhere ?
> 
> Use the database module.
> 
> \usemodule[database]
> 
> \defineseparatedlist
>  [CSV]
>  [separator={,},
>  before=\bTABLE,
>   after=\eTABLE,
>   first=\bTR,
>last=\eTR,
>left=\bTD,
>   right=\eTD]
> 
> \starttext
> 
> \startCSV
> 1,2,3
> 3,5,6
> 7,8,9
> \stopCSV
> 
> \stoptext
> 
> Wolfgang

Wolfgang, thanks. I have seen the use if the database module on the wiki, but 
was trying to do without it, the reason is that my documents are often shared 
with colleagues, for which installation of modules is most often very 
difficult. 
Anyway, I will use the database module this time, so simple ! Thanks again.

Fabrice
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] startCSV Wiki, Natural Table

2020-11-24 Thread Fabrice L
Hi,

I was using in the past (MKII) a snippet of code to produce (natural) tables 
from CSV. I was trying to compile my code with MKIV, but this does not work 
anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV 
(probably my error !). 

So I came back to the wiki, where my code came from, and the code below is just 
a copy for the wiki. It is supposed to make a table with three columns, but 
there is only one column in the resulting table…  I admit I do not understand 
the code, but is there is missing \eTR somewhere ?

Thanks for any help.
Fabrice.

Ps: in case someone is interested, I use this to produce statistical tables for 
teaching. I can share.. ! 

% --
\starttext

% Iterate over all the lines of text captured with \obeylines active
% command to call is first argument, is not called for empty lines
\bgroup
\obeylines
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%
 \doifnotempty{#2}{#1{#2}}%
 \doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%
}%
\egroup

\def\startCSV{\bgroup\obeylines\dostartCSV}

\def\TBLentry#1{\bTD#1\eTD}
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}

\def\dostartCSV#1\stopCSV{%
  \bTABLE
  \ProcessLines\TBLline{#1}%
  \eTABLE
  \egroup
}

% some additional settings for the table may be made as well
\setupTABLE[c][2][style=\tt]
\setupTABLE[c][3][align=middle]
\setupTABLE[r][1][style=bold] 

\startCSV
Name,Email,Accepted
\CONTEXT,wo...@trying.to,Yes
Hans,m...@developer.of,Yes
Bug,g...@rid.of,No
\stopCSV

\stoptext
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] MacOS+TeXlive: installation problems

2020-11-17 Thread Fabrice L
Hi,

> Le 17 nov. 2020 à 15:23, Tomas Hala  a écrit :
> 
> Hi all,
> 
> one student of mine asked me for a help with installation TeXlive 
> (from http://www.tug.org/mactex/mactex-download.html) 
> on her MacBook Air 16 with macOS Catalina.
> 
> Despite the fact that the site states 
> "All install packages are developer-signed and notarized by Apple.",
> she got:
> "Cannot be opened because its from unidentified developer, MacOS cannot 
> verify that this app is free from malware."
> 
> What could it be? 
> I have got no experience with MacOS, so I would like to ask for some hints 
> how we can fix it.

The solution is rather simple, check here:
https://support.apple.com/en-us/HT202491 

or
https://support.apple.com/en-ca/guide/mac-help/mh40616/macAfter 


> 
> Thanks in advance.
> Best wishes,
> Tomáš

Fabrice.___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Filter module for R

2020-06-15 Thread Fabrice L
Dear Aditya,

> Le 15 juin 2020 à 01:45, Aditya Mahajan  a écrit :
> 
> This is an adapted version of the code that I use for my course where I use 
> the vim module to do the typesetting:
> 
> \usemodule[filter]
> \usemodule[vim]
> 
> \definecolor  [darkblue]   [r=0.1,  g=0.11, b=0.84]
> \definecolor  [darkgreen]  [g=0.7]
> \definecolor  [lightblue]   [h=87cefa]
> \definecolor  [lightgreen]  [g=0.95,b=0.8,r=0.8]
> 
> \defineframedtext
>  [leftbartext]
>  [
>width=local,
>frame=off,
>framecolor=darkblue,
>leftframe=on,
>rulethickness=1ex,
>offset=0.25ex,
>loffset=3ex,
>background=color,
>backgroundcolor=lightblue,
>  ]
> 
> \definevimtyping
>  [RCODE]
>  [
>syntax=r,
>directory=output,
>strip=yes,
>escape=yes,
>before={\blank[quarterline]\startleftbartext},
>after={\stopleftbartext},
>  ]
> 
> \define[1]\ShowOutput
>{\typeRCODEfile{\externalfilterinputfile}
> \startleftbartext[framecolor=darkgreen, backgroundcolor=lightgreen]
>   \setupalign[flushleft, verytolerant]
>   % range={1,-1} not currently supported
>   % See below for details
>   \typefile[range={1,-1}]{#1}
> \stopleftbartext}
> 
> 
> \defineexternalfilter
>  [R]
>  [ filtercommand={R CMD BATCH -q --no-timing --save --restore
> \externalfilterinputfile\space \externalfilteroutputfile},
> output=\externalfilterbasefile.out,
> directory=output,
> readcommand=\ShowOutput,
> read=no,
> cache=yes,
> purge=yes, % THE COMMA WAS MISSING
>   ]
> 
> \starttext
> 
> Some text...
> 
> \startR[read=yes]
>   pdf("RPlots/MyHistogram.pdf",5,5)
>   X <- rnorm(200,mean=10,sd=2)
>   hist(X, col =  "red3" ,  xlab="Score QI" , main="", ylab="fréquence")
> \stopR
> 
> \externalfigure[RPlots/MyHistogram.pdf][width=.5\textwidth]
> 
> \stoptext
> 
> 


Thanks so much for your answer. I had (of course) to install nvim in order the 
code to work, but this works ! Thanks also for your additional work regarding 
the locale setting.. this is really deep magic for me. 

I think the facility to run R code directly from context can open ConTeXt to 
new users. The alliance between R and LaTeX is a winning combination to a lot 
of my colleagues. Do you think this would be appropriate to do a simple page on 
the wiki explaining how R code can be done in ConTeXt, with eventual 
formatting, with some simple examples, or this is too much noise ?

Thanks. Fabrice.






___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Filter module for R

2020-06-14 Thread Fabrice L
Hi,Following a question about the broken R module (R the statistical software), Aditya suggested me the filter module (thanks to him). I’m about to distribute a set of course notes to colleagues, and I need to deal with details now. I have one problem and two questions.1) the filter collect R code between \startR / \stopR and submit this code to R. As it can be seen in the following minimal example, when a label contains an accented character (« Fréquence » in my example), the pdf graphic does not contains the « é ». Strangely, the snippet of code (which is saved locally as « test2-temp-R-0.tmp » (for test2.tex)) when submitted with the same command as the filtercommand, works correctly; that means the same file works when submitted to R outside of ConTeXt. I have no idea how to solve this. 2) In a teaching context, we may want sometimes to show the code. The filter module actually permits to show the output of the code submitted to R (which can include or not the input commands); would it be possible to typeset the submitted code ?3) Finally, using "R CMD BATCH… » as the filtercommand add an extra line at the end of the output file which can be typeset to visualize results. Would it be possible by a magic trick to deleter the last line of the file ?Here is a minimal code:% —\usemodule[filter]\defineexternalfilter  [R]  [ filtercommand={R CMD BATCH -q --no-timing --save --restore \externalfilterinputfile\space \externalfilteroutputfile},     output=\externalfilterbasefile.out,     directory=output,     readcommand=\typefile,     read=no,     cache=yes,     purge=yes   ]\starttextSome text...\startR[read=yes]   pdf("RPlots/MyHistogram.pdf",5,5)   X <- rnorm(200,mean=10,sd=2)   hist(X, col =  "red3" ,  xlab="Score QI" , main="", ylab="fréquence")\stopR\externalfigure[MyHistogram.pdf][width=.5\textwidth] \stoptext% —Sorry for the three questions… and thanks for any help.Fabrice.

MyHistogram.pdf
Description: Adobe PDF document
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] start/stop executed conditionally on mode ?

2020-06-09 Thread Fabrice L


> Le 9 juin 2020 à 03:37, Hans Hagen  a écrit :
> 
> On 6/8/2020 9:53 PM, Fabrice L wrote:
>>> Le 7 juin 2020 à 23:19, Aditya Mahajan >> <mailto:adit...@umich.edu>> a écrit :
>>> 
>>> On Sun, 7 Jun 2020, Fabrice L wrote:
>>> 
>>>> Dear List,
>>>> 
>>>> I would like to insert a page using (ideally) start/stop instructions. The 
>>>> problem is that this page should be inserted only in a certain mode. 
>>>> Consulting the mailing list, I thought the following code was working, but 
>>>> it’s not ! The code is executed in the mode as expected, but the following 
>>>> instructions ("Some other text... » in the exemple) is not typeset.
>>>> 
>>>> Here is a minimal (not working!) example:
>>>> 
>>>> % 
>>>> \unexpanded\def\StartQuestionsList{
>>>> \startmode[ClassRoom]  \page[yes] Here are some questions: \blank
>>>> }
>>>> \unexpanded\def\StopQuestionsList{
>>>> \page[yes] \stopmode
>>>> }
>>>> \definestartstop[Questions][
>>>> before=\StartQuestionsList,
>>>> after=\StopQuestionsList
>>>> ]
>>>> 
>>>> 
>>>> \startQuestions
>>>> Question A….
>>>> Question B….
>>>> \stopQuestions
>>>> 
>>>> Some other text...
>>>> % 
> One of the oldest mechanism available ... blocks:
> 
> \enablemode[classroom] % comment this
> 
> \defineblock[Question]
> 
> \doifmode {classroom} {
>\keepblocks[Question]
> }
> 
> \starttext
> 
>Text A
> 
>\beginQuestion
>Question A….
>\endQuestion
> 
>Text B
> 
>\beginQuestion
>Question B….
>\endQuestion
> 
>\page
> 
>\doifnotmode {classroom} {
>\useblocks[Question]
>}
> 
> \stoptext

You are right of course... In fact I already use blocks, for another purpose, 
but I did not think about this solution because I needed a lot of formatting 
(these blocks should occupy whole page, different background color…), but 
blocks can adapt to my current need (I have try this morning) using the 
\setupblock[][before=..,after=…] command. And there is a bonus; I can « collect 
» these blocks and put them all together at the end of my courses notes, this 
is perfect.


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] start/stop executed conditionally on mode ?

2020-06-08 Thread Fabrice L


> Le 7 juin 2020 à 23:19, Aditya Mahajan  a écrit :
> 
> On Sun, 7 Jun 2020, Fabrice L wrote:
> 
>> Dear List,
>> 
>> I would like to insert a page using (ideally) start/stop instructions. The 
>> problem is that this page should be inserted only in a certain mode. 
>> Consulting the mailing list, I thought the following code was working, but 
>> it’s not ! The code is executed in the mode as expected, but the following 
>> instructions ("Some other text... » in the exemple) is not typeset.
>> 
>> Here is a minimal (not working!) example:
>> 
>> % 
>> \unexpanded\def\StartQuestionsList{
>>  \startmode[ClassRoom]  \page[yes] Here are some questions: \blank
>> }
>> \unexpanded\def\StopQuestionsList{
>>  \page[yes] \stopmode
>> }
>> \definestartstop[Questions][
>>  before=\StartQuestionsList,
>>  after=\StopQuestionsList
>>  ]
>> 
>> 
>> \startQuestions
>>  Question A….
>>  Question B….
>> \stopQuestions
>> 
>> Some other text...
>> % 
>> 
>> 
>> So to be clear, I would like the result in the « ClassRoom » mode to be:
>> % 
>> Here are some questions:
>> 
>>  Question A….
>>  Question B….
>> 
>> Some other text...
>> % 
>> 
>> Otherwise to be:
>> % 
>> Some other text...
>> % 
> 
> If you only set `ClassRoom` mode at compile time (rather than setting and 
> unsetting it the middle of the document), then you can do:
> 
> \definebuffer[Questions]
> 
> \startmode[ClassRoom]
> \define\StopQuestionsList {...}
> 
> \definestartstop[Questions][...]
> \stopmode
> 

Thanks to Aditya, I have succeeded, but it was not trivial for me. So, in case 
somebody someday would need a detailed solution, here is a minimal example, and 
an explanation. 

A buffer « Questions » is defined. If in « ClassRoom » mode, a start/stop « 
Questions » is also defined. So when ConTeXt encounters the \startQuestions / 
\stopQuestions, if the « ClassRoom » mode is enabled, the buffer is processed 
(with some format if needed - framed here for the example), and if the mode « 
ClassRoom » is disabled, then nothing is process. You can add as many 
\startQuestions / \stopQuestions you wish. 


% --
\definebuffer[Questions]

\enablemode[ClassRoom] % Try "On / Off » to process "\startQuestions / 
\stopQuestions » or not.

\startmode[ClassRoom]
 
\definestartstop[Questions][before={\startframedtext\red},after={\stopframedtext\blue}]
\stopmode

\starttext

Before...

\startQuestions
The content of the buffer ! 
\stopQuestions

After...

\stoptext
% --

Thanks Aditya !
Fabrice.



> Aditya___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / 
> http://www.ntg.nl/mailman/listinfo/ntg-context 
> <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / 
> http://context.aanhet.net <http://context.aanhet.net/>
> archive  : https://bitbucket.org/phg/context-mirror/commits/ 
> <https://bitbucket.org/phg/context-mirror/commits/>
> wiki : http://contextgarden.net <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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] start/stop executed conditionally on mode ?

2020-06-08 Thread Fabrice L
Dear Aditya,

> Le 7 juin 2020 à 23:19, Aditya Mahajan  a écrit :
> 
> On Sun, 7 Jun 2020, Fabrice L wrote:
> 
>> Dear List,
>> 
>> I would like to insert a page using (ideally) start/stop instructions. The 
>> problem is that this page should be inserted only in a certain mode. 
>> Consulting the mailing list, I thought the following code was working, but 
>> it’s not ! The code is executed in the mode as expected, but the following 
>> instructions ("Some other text... » in the exemple) is not typeset.
>> 
>> Here is a minimal (not working!) example:
>> 
>> % 
>> \unexpanded\def\StartQuestionsList{
>>  \startmode[ClassRoom]  \page[yes] Here are some questions: \blank
>> }
>> \unexpanded\def\StopQuestionsList{
>>  \page[yes] \stopmode
>> }
>> \definestartstop[Questions][
>>  before=\StartQuestionsList,
>>  after=\StopQuestionsList
>>  ]
>> 
>> 
>> \startQuestions
>>  Question A….
>>  Question B….
>> \stopQuestions
>> 
>> Some other text...
>> % 
>> 
>> 
>> So to be clear, I would like the result in the « ClassRoom » mode to be:
>> % 
>> Here are some questions:
>> 
>>  Question A….
>>  Question B….
>> 
>> Some other text...
>> % 
>> 
>> Otherwise to be:
>> % 
>> Some other text...
>> % 
> 
> If you only set `ClassRoom` mode at compile time (rather than setting and 
> unsetting it the middle of the document), then you can do:
> 
> \definebuffer[Questions]
> 
> \startmode[ClassRoom]
> \define\StopQuestionsList {...}
> 
> \definestartstop[Questions][...]
> \stopmode
> 


Thanks for your answer, I will try that.
Fabrice,


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] start/stop executed conditionally on mode ?

2020-06-07 Thread Fabrice L
Dear List,

I would like to insert a page using (ideally) start/stop instructions. The 
problem is that this page should be inserted only in a certain mode. Consulting 
the mailing list, I thought the following code was working, but it’s not ! The 
code is executed in the mode as expected, but the following instructions ("Some 
other text... » in the exemple) is not typeset. 

Here is a minimal (not working!) example: 

% 
\unexpanded\def\StartQuestionsList{ 
\startmode[ClassRoom]  \page[yes] Here are some questions: \blank 
}
\unexpanded\def\StopQuestionsList{ 
\page[yes] \stopmode
}
\definestartstop[Questions][
before=\StartQuestionsList,
after=\StopQuestionsList
]


\startQuestions
Question A….
Question B…. 
\stopQuestions

Some other text...
% 


So to be clear, I would like the result in the « ClassRoom » mode to be:
% 
Here are some questions: 

Question A….
Question B…. 

Some other text...
% 

Otherwise to be:
% 
Some other text...
% 

Thanks for any help !
Fabrice.___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metapost and TikZ color code equivalent

2020-02-14 Thread Fabrice L
Hi,

> Le 13 févr. 2020 à 16:45, Fabrice Couvreur  a 
> écrit :

> How to have the color defined by {yellow!60!black} with Metapost ?

color MyColor ; MyColor := .6[yellow,black] ;

See metafun manual, section 1.13.

> Thank you.
> Fabrice

Fabrice (another one !).
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] R module

2019-11-23 Thread Fabrice L
Dear Aditya.

> Le 22 nov. 2019 à 17:49, Aditya Mahajan  a écrit :
> 
>>  I’m teaching with R this term, and I tried (without success) the 
>> R-module (I think the path of R is not found). Having no time to test and 
>> find out the problem, I have tried with success knitr (with is Rmarkdown 
>> code converted to latex-beamer). But I’m missing Context… My understanding 
>> is that the R-module is working only with mk-ii. Is there people in this 
>> list using successfully the r-module with mk-iv ?
> 
> Have you tried the filter module:
> https://github.com/adityam/filter/blob/master/README.md
> 
> For setup with R, see:
> https://github.com/adityam/filter/wiki/R
> 
> Aditya

Thanks for your answer. I did not know about the filter module. I had a look; 
the module is  powerful… but complex to install. It is not clear for me: this 
module would permits to submit code to R, optionally shows this code in the 
conTeXt document, and includes the output of R ? So is it a modern replacement 
of the r-module ?

Thanks !
Fabrice.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] R module

2019-11-22 Thread Fabrice L
Dear list,

I’m teaching with R this term, and I tried (without success) the 
R-module (I think the path of R is not found). Having no time to test and find 
out the problem, I have tried with success knitr (with is Rmarkdown code 
converted to latex-beamer). But I’m missing Context… My understanding is that 
the R-module is working only with mk-ii. Is there people in this list using 
successfully the r-module with mk-iv ?

Thanks, Fabrice. 
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Arithmetic overflow on placing an external figure in MP

2019-09-07 Thread Fabrice L
Hi,

> Le 7 sept. 2019 à 16:47, Henning Hraban Ramm  a écrit :
> 
> Bear with me, I still got no experience in MetaPost…
> 
> I’m trying to place a pixel image on a MP page.
> 
> According to the MetaFun manual this should work:
> 
> \startMPpage
> draw externalfigure "mill.png" scaled 5cm shifted (-6cm,0) ;
> \stopMPpage
> 
> And it works with mill.png (copied into my test dir), but with none of my 
> other PNGs, I always get
> 
> ! Arithmetic overflow.
> <*> ...xternalfigure "dodo.png" scaled 5cm shifted
> (-6cm,0) ; ;
> Uh, oh. A little while ago one of the quantities that I was
> computing got too large, so I'm afraid your answers will be
> somewhat askew. You'll probably have to adopt different
> tactics next time. But I shall try to carry on anyway.
> 
> [1]
> 
> 1 \startMPpage
> 2 draw externalfigure "dodo.png" scaled 5cm shifted (-6cm,0) ;
> 3 >>  \stopMPpage
> 4
> 

I can reproduce your error with MKIV, but this world with lmtx; I think this is 
just too big for MKIV (I’m not sure why !).
Be aware of the difference between « scaled » and « sized ». You can try:

\starttext
\startMPpage
draw externalfigure "dodo.png" sized  5cm shifted (-6cm,0) ;
\stopMPpage
\stoptext

and try:

\starttext
\startMPpage
draw externalfigure "dodo.png" scaled 0.018cm shifted (0,0) ;
draw ((0,0) -- (5cm,0) -- (5cm,5cm) -- (0,5cm) -- cycle ) withcolor red ;
\stopMPpage
\stoptext

In the second case, your image fits (approximately) in a 5cm square. 
Fabrice.


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Syntax hightlighting

2019-08-28 Thread Fabrice L
Dear list,

I’m using colored verbatim code (for course notes). In the past, I modified 
verb-mp.mkii for the langage I need (SAS). This code works fine with MKII:

%——
\setupcolors[state=start]
\definetyping [MP] [option=MP]

\starttext
A example:
\startMP
draw (0,0) withpen pencircle 1in withcolor red ;
\stopMP
\stoptext
%——

I obtain a color syntax output (« draw » in red, « within » in green for 
example). This code does not work anymore in MKIV (every word is the same 
color, green). There should be a solution ?

Trying to find some help, in the maling list and the « verbatim_text » page on 
Context garden, I found some solutions, like pretty printing, which should work 
on MKIV, but "pret-mp.lua » is found nowhere (nor in the context source 
browser, nor in my recent distribution). 

I must admit I’m lost in all the solutions I found there and there (most of 
them never works out of the box on my installation). Can somebody refer me to a 
simple solution, which permit me to do colored verbatim code, such as I can 
modify a source to insert the keywords of the langage I use ?

Thanks !
Fabrice.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Why is the list so quiet these days?

2019-07-02 Thread Fabrice L
Le 2 juillet 2019 à 14:39:47, Andres Conrado Montoya (
andresconr...@gmail.com) a écrit:

Yes! I always get an answer, and I'm very grateful for that, and all the
work you all do. This is a great mail list, and ConTeXt is an amazing tool
that I very much enjoy working with. Thank you all!

I second this thinking ! Thanks to all that make context so amazing !

Fabrice.



Andrés Conrado Montoya
Andi Kú
andresconr...@gmail.com
http://sesentaycuatro.com
http://messier87.com
http://chiquitico.org

Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.


“You develop an instant global consciousness, a people orientation, an
intense dissatisfaction with the state of the world, and a compulsion to do
something about it. From out there on the moon, international politics look
so petty. You want to grab a politician by the scruff of the neck and drag
him a quarter of a million miles out and say, ‘Look at that, you son of a
bitch.’” — Apollo 14 astronaut Edgar Mitchell


El mar., 2 jul. 2019 a las 13:19, Hans Hagen () escribió:

> On 7/2/2019 8:09 PM, Andres Conrado Montoya wrote:
> > Is there an event or something else? Or everybody is just busy?
>
> normally traffic is somewhat lower during the summer (holiday season)
>
> https://mailman.ntg.nl/pipermail/ntg-context/2019/date.html
>
> but i'm pretty sure that when you post a question that you get an answer
>
> Hans
>
> -
>Hans Hagen | PRAGMA ADE
>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] preparing math exams

2019-04-23 Thread Fabrice L
Hi,

Le 23 avril 2019 à 11:10:11, Gour (g...@atmarama.com) a écrit:

Hello,

For regular formulas involving e.g. rational numbers, I'm sure that
input language for math is quite sufficient, but wonder about drawing
part?


Metapost (Metafun) is your best friend here. You can insert directly in
context some MetaFun code, like this:

\starttext
Lorem Ipsum…

\startMPcode
draw ( (0,0) — (1,0) — (0,1)) with color red ;
\stopMPcode

\stoptext

Look at this entry in the wiki:
https://wiki.contextgarden.net/MetaPost_in_ConTeXt

Also, you will find a link to the meta fun manual in this page, this a good
place to start !
Fabrice.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] getdocumentargument in Metafun

2019-02-22 Thread Fabrice L
Le 22 février 2019 à 11:08:51, Aditya Mahajan (adit...@umich.edu) a écrit:

Untested. Add quotes around FileName:

> string FileName ;
> FileName := "\getdocumentargument{File}" ;


And not tested successfully !

Thanks a lot Aditya !

Fabrice.



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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] getdocumentargument in Metafun

2019-02-22 Thread Fabrice L
Dear list,

I wish to do several zoom from a picture made in MetaFun, from a pdf file
which name is given on the commande line, like:

context zoom.tex —File=EntryFile —Page=9 —result=OutFile.pdf

Minimal example:

\starttext
  \startMPpage
numeric ThePage ;
string FileName ;
FileName := \getdocumentargument{File} ;
ThePage := \getdocumentargument{Page} ;
draw textext("\externalfigure["  & FileName &"][page="  & ThePage &"]")
xysized (48in,48in) ;
  \stopMPpage
\stoptext

I can get in the MPpage the page number in entry (9 in my example), but not
the file name.
Thanks for any help.
Fabrice.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] About the macro path intersectionpoint path with Metapost

2019-02-04 Thread Fabrice L
Hi,

I guess your problem is to find the two points of intersection between p
and r ? If so, the problem is that intersectionpoint does return the same
intersection when there is several, as it is the case here. So a quick
solution that you can do is to find intersections for the two part. A
drawing is simple than words ! here is the code to illustrate:

Happy drawing !
F.

\setupcolors[state=start]
\starttext
\startMPpage
  path p, q, r, b , u;
  p:= fullcircle scaled 6cm ;
  q:= fullcircle scaled 4cm shifted (2.5cm,2cm) ;
  r:= fullcircle scaled 4cm shifted (-2.5cm,2cm);
  b:= fullcircle scaled 2cm shifted (0,-3cm);
  pair A, B ;
  path rprime ;
  % Rprime is a a part of r (drawn in black to see it):
  rprime := r cutbefore point .5 along r;
  A:= p intersectionpoint r ;
  B:= p intersectionpoint rprime ;
  draw A withpen pencircle scaled .1in ;
  draw B withpen pencircle scaled .1in ;

  u:= A--B--cycle ;
  draw p withcolor green;
  draw q withcolor blue;
  draw rprime  withpen pencircle scaled .05in withcolor black;
  draw r withcolor red;
  draw b withcolor magenta;
  draw u numberstriped (.25,15,5) withcolor magenta ;
\stopMPpage
\stoptext


Le 3 février 2019 à 06:28:37, Fabrice Couvreur (fabrice1.couvr...@gmail.com)
a écrit:

Hi,
I would like to reproduce the attached figure. My problem is to create the
points of intersection between the circles. It seems that my approach is
not the right one.
Thank you.
Fabrice

\starttext
\startMPcode
  path p, q, r, b ;
  p:= fullcircle scaled 6cm ;
  q:= fullcircle scaled 4cm shifted (2.5cm,2cm) ;
  r:= fullcircle scaled 4cm shifted (-2.5cm,2cm);
  b:= fullcircle scaled 2cm shifted (0,-3cm);
  pair A, B ;
  A:= p intersectionpoint r ;
  B:= p intersectionpoint r ;
  path u ;
  u:= A--B--cycle ;
  draw p ;
  draw q ;
  draw r ;
  draw b ;
  draw u numberstriped (.25,15,5) withcolor magenta ;
\stopMPcode
\stoptext
___
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Variable instance identifiers exhausted

2018-09-21 Thread Fabrice L
Le 19 septembre 2018 à 15:47:07, Fabrice L (fabrice.al...@gmail.com) a
écrit:




Le 19 septembre 2018 à 15:28:54, Alan Braslau (braslau.l...@comcast.net
(mailto:braslau.l...@comcast.net)) a écrit:

> On Tue, 18 Sep 2018 19:21:31 -0700
> Fabrice L wrote:
>
> > The problem is that the process take hours of compilations, and
> > tests are not easy to do. Anyway, I will enrich my « minimal » code to
my
> > « full » code in order to find the difference… and the problem. I will
> > update the thread as soon as can.
>
> My over 700k object graphics example, processed several times
(repeatedly, over several pages with modifications) took less than one
minute to process. In fact, each graphic took almost as long to render from
the pdf as it did for metapost/lua to process.
>
> Alan

I do not know what your example is (but I’m curious: can I see this
somewhere ?).

In my case, the long time needed is to check if a new object does not
intersect with any other object: so when I try to find the maximum size of
the 1000th object at a given position, I have to check with the 999 others…
I do this with « intersectiontimes ». And so on for the 10001th… I have a
course try to find solutions to gain time, like using the coordinate of a
new object: when the coordinate of a new object is chosen, I do not need to
check potential intersections with objects far away… but surprisingly (to
me) this take more time than to blindly check with every object.

This is an algorithmic problem more than a ConTeXt/Metapost one… but I you
have suggestions, I’m sure I can learn !

Below is minimal code. (Just to be clear, this code work, even for 20K
objects.)
Thanks.

\starttext
  \startMPpage
  path Obj[] , ObjTemp ;
  pair ObjPos , Inter ;
  numeric NObj ;
  % Change herte "NObj" to a big numer (says 20K)
  NObj := 100;
  numeric Danger, MaxSize ;

  % Draw an initial object of random shape and random size ;
  Obj[1]:= fullsquare randomized .001in
  scaled (uniformdeviate(.5)*1in)
  shifted (uniformdeviate(5)*1in,uniformdeviate(5)*1in) ;
  Obj[1] := curved ( Obj[1] );
  fill Obj[1] withcolor cyan randomized (.2,1.5);
  draw Obj[1] withcolor black randomized (.2,1.5);

  for i=2 upto NObj :
  Danger := 0;
% Choose a position for the object :
  ObjPos := (uniformdeviate(5)*1in,uniformdeviate(5)*1in) ;
  % Choose a form :
  Obj[i] := fullsquare randomized .01in ;
  Obj[i] := curved ( Obj[i] );
  % Choose a scale so the object does not interact with any other object:
for j=1 upto 50:
   MaxSize := (j*.01in) ;
ObjTemp := Obj[i] scaled MaxSize shifted ObjPos ;
   %draw ObjTemp withcolor magenta ;
   % Check if this temporary object intersect with any other object :
   for k=1 upto (i-1):
string trace ;
 Inter := Obj[k] intersectiontimes ObjTemp ;
 if (xpart Inter) <> -1 : Danger := 1; fi ;
 if Danger=1: MaxSize := ((j-1)*.01in) ; fi;
 exitif Danger = 1;
   endfor;
   exitif Danger = 1;
  endfor ;
  Obj[i] := Obj[i] scaled MaxSize shifted ObjPos ;

  fill Obj[i] withcolor cyan randomized (.2,1.5);
  draw Obj[i] withcolor black randomized (.2,1.5);
  endfor;
  \stopMPpage
\stoptext



So after some hours of computation, this code above breaks for me if the
number of objects,  NObj in my code, is too large. Of course, perhaps an
error occurs at some point and is not caused directly by the number of
objects, because according to what has been said in this thread this should
not be is not a problem. I put below the log. If somebody has a hint in
which direction I should look… thanks !

Fabrice.

mtx-context | run 1: luatex
--fmt="/Users/fabricel/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en"
--jobname="0030-0018-minimal2"
--lua="/Users/fabricel/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui"
--no-parse-first-line --c:currentrun=1
--c:fulljobname="./0030-0018-minimal2.tex"
--c:input="./0030-0018-minimal2.tex" --c:kindofrun=1 --c:maxnofruns=1
--c:runs="1" "cont-yes.mkiv"

This is LuaTeX, Version 1.08.0 (TeX Live 2018)
 system commands enabled.
open source > level 1, order 1, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv'
system  >
system  > ConTeXt  ver: 2018.05.17 18:32 MKIV beta  fmt: 2018.5.18
 int: english/english
system  >
system  > 'cont-new.mkiv' loaded
open source > level 2, order 2, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system  > beware: some patches loaded from cont-new.mkiv
close source> level 2, order 2, name
'/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system  > files > jobname '0030-0018-minimal2', input
'./0030-0018-

Re: [NTG-context] Variable instance identifiers exhausted

2018-09-18 Thread Fabrice L
Le 18 septembre 2018 à 03:11:40, Taco Hoekwater (t...@elvenkind.com) a
écrit:

> On 17 Sep 2018, at 21:17, Fabrice L  wrote:
>
> Dear List,
>
> I’m running into a problem in Metapost (using Context of course!)
> creating (I think) too many objects; I got this error message:
>
> variable instance identifiers exhausted

The max value for that is 2^31, or about 2 billion (and some change).
Are you sure you do not have an eternal loop in your source?

The number of objects I have is clearly less than 2^31, so my problem is
elsewhere then.

I do not think this a loop problem, because the same code runs ok for 15
000 objects, but give an error for 18 000 objects. I’m working to build a
minimal example.

Thanks a lot for the help ! Much appreciated.

Fabrice.



Best wishes,
Taco





___
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Variable instance identifiers exhausted

2018-09-18 Thread Fabrice L
Le 18 septembre 2018 à 01:15:36, luigi scarso (luigi.sca...@gmail.com) a
écrit:



On Mon, Sep 17, 2018 at 9:18 PM Fabrice L  wrote:

> Dear List,
>
> I’m running into a problem in Metapost (using Context of course!)
> creating (I think) too many objects; I got this error message:
>
> variable instance identifiers exhausted
>
> I have tried without success to find information and a solution.
> Does somebody has a hint to solve this ?
>

Do you have  minimal example ?

I have worked on a minimal example today with no success ! What I mean is
that I have rebuilt the same algorithm from scratch in order to show
something minimal to the list, and I do not seem to encounter the problem
anymore ! The problem is that the process take hours of compilations, and
tests are not easy to do. Anyway, I will enrich my « minimal » code to my
« full » code in order to find the difference… and the problem. I will
update the thread as soon as can.

Thanks a lot for helping.

Fabrice.



--
luigi
___
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] Variable instance identifiers exhausted

2018-09-17 Thread Fabrice L
Dear List,

I’m running into a problem in Metapost (using Context of course!)
creating (I think) too many objects; I got this error message:

variable instance identifiers exhausted

I have tried without success to find information and a solution.
Does somebody has a hint to solve this ?

Thanks, Fabrice.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] roadmap

2018-05-16 Thread Fabrice L
Dear all,

> - Check what additional features users want (miss) and decide to what
extent and with what priority we will put effort in this.

As asked, I add a wish to the list...

One feature which I depend a lot on is to be able to do animations: I
actually use the Raw Steps module, by David Munger (dated from 2006), which
still worked, but in MKII only. This is essential for me for my teaching
and talks. During teaching, I have designed courses notes in ConText using
a lot modes of context: the notes are different for the teacher, are
available in two formats for the students (paper and for completion on
tablets), and there is a last version for use in the class by me. In class,
this is essential for me that the material is presented by steps, otherwise
students have a tendency to not listen, or to not try to solve a problem is
the solution is already on the screen. I can not use the animation
tools available in ConTexT using javascript, since I use to show notes in
class an iPad, and I use the stylus to fill blanks present in the notes
(which work great by the way !). The facility to use modes in the courses
notes like this have convinced several of my colleagues to use ConTeXt for
their teaching needs.

Following threads on this list on animations, my understanding is that Hans
is not a great supporter of the method of animations in the Raw Steps
module, for technical reasons.

I have switch to MKIV for others documents, but I'm still on MKII for this
reason for my courses notes, which are 90% one my needs in TeX.
Fabrice.

2018-05-14 11:17 GMT-04:00 Hans Hagen :

> Hi,
>
> The ConTeXt meeting is - as usual - the right place and moment to discuss
> the roadmap. We never had real binding roadmaps, more informal ones.
> Anyway, here are some thoughts on the two main components: MkIV and LuaTeX.
>
> ConTeXt MkIV:
>
> - Check if some mechanism can (by now) be simplified due to LuaTeX
> extension introduced the last few years that can be considered stable by
> now. This has a low impact as we already use Lua a lot.
>
> - Figure out what mechanism in ConTeXt are bottlenecks in performance if
> there are such bottlenecks at all. We need user input on this.
>
> - Get rid of inconsistencies in the user interface e.g. by introducing new
> commands with settings.
>
> - Check what additional features users want (miss) and decide to what
> extent and with what priority we will put effort in this. We've reached a
> point where interference prevents more complex extensions.
>
> - Try to improve tricky mechanisms, like columns and tables. Improvements
> are of course always on the agenda.
>
> - We can add more trickery for fonts and scripts. There are some pending
> extensions.
>
> - Maybe we should provide a few more general styles.
>
> - Are there reasonable challenges left.
>
> LuaTeX 1.09:
>
> - This version is pretty close to what is the final version (seen from the
> functional point of view). We're still debating where to move after this.
> LuaTeX 2.0? A stripped down (lean and mean) version specific for ConTeXt?
> Keep in mind that we cannot fundamentally change something, even if we want
> to, because other macro packages use it and don't expect it to change much.
>
> - There will probably be some more options in controlling math (given
> issues with fonts). We have to accept that not everything has a generic
> programmable solution (which is why we have Lua on board).
>
> - There might be a few more callbacks but probably nothing fundamental is
> planned.
>
> - We keep cleaning up the code base (less code is better, less
> dependencies too, some documentation is missing or not yet adapted to the
> new code). For instance the pdf inclusion code will soon be redone (and
> then tested in the ConTeXt distribution as usual).
>
> - When possible we will try to improve performance but there is not much
> to gain to be expected there.
>
> - We will also keep up with Lua (currently 5.3, some day 5.4). It is
> unclear to what extent LuaJit follows. When it stays behind we need to
> decide if support in ConTeXt will stay (to some extent we can have dual
> code paths as we have now).
>
> - We expect the ffi interface to external libraries to become more stable
> over time. ConTeXt will not introduce dependencies (what can be done in Lua
> will happen in Lua) but on the other hand we might put some libraries in
> the distribution e.g. for database support.
>
> - We might add some extensions to MetaPost in MPLib.
>
> In addition we could formulate ideas with respect to the distribution,
> garden, documentation and so on.
>
> You can react on this list but if you come to the meeting, you can
> participate in discussions.
>
> So far for now,
>
> Hans
>
> -
>   Hans Hagen | PRAGMA ADE
>   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>tel: 038 477 53 69 | www.pragma-ade.nl | 

Re: [NTG-context] Border matrix

2018-04-19 Thread Fabrice L
Wolfgang, thanks so much ! Everything is clear now, and works fine.

I will explore the mathalignment environment, which I’m not used to.
Fabrice.


Le 19 avril 2018 à 16:14:51, Wolfgang Schuster (schuster.wolfg...@gmail.com)
a écrit:

1. The bordermatrix code is part of the core and you can remove it from
cont-new.mkiv.

2. To use the \equalign command you have to enable the special meaning of &
in math mode with \setupmathematics[ampersand=normal].

3. User the new mathalignment environment as replacement for \equalign
which avoids special characters like &.

Wolfgang

Fabrice L <fabrice.al...@gmail.com>
19. April 2018 um 22:05
Dear list,

Some months ago, Hans wrote to this list (see below) a macro to do matrix
showing outside the brackets some informations (like we usually do for
Markov chains), but adapted some plain tex code, which worked in MKII). I
have used with success this code since then, but some weeks ago, the
behavior of Context had changed (probably something on my part; I have
updated the installation, but nothing changed).

The problem (I think) is linked to \unprotect \protect. When this code is
put before the \starttext to the the cont-new-mkiv, the border matrix
behave well, but a simple \eqalign like this:

\startformula
\eqalign{ & \lambda=5, \mu =5 \cr
   & \mu=8 \cr }
\stopformula

do not works is I replace «  \lambda » by « \lambda_2 » for example. I have
no idea what’s is going on. here is a minimal example where Hans’s code is
before the \starttext:

___
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Border matrix

2018-04-19 Thread Fabrice L
Dear list,

Some months ago, Hans wrote to this list (see below) a macro to do matrix
showing outside the brackets some informations (like we usually do for
Markov chains), but adapted some plain tex code, which worked in MKII). I
have used with success this code since then, but some weeks ago, the
behavior of Context had changed (probably something on my part; I have
updated the installation, but nothing changed).

The problem (I think) is linked to \unprotect \protect. When this code is
put before the \starttext to the the cont-new-mkiv, the border matrix
behave well, but a simple \eqalign like this:

\startformula
\eqalign{ & \lambda=5, \mu =5 \cr
   & \mu=8 \cr }
\stopformula

do not works is I replace «  \lambda » by « \lambda_2 » for example. I have
no idea what’s is going on. here is a minimal example where Hans’s code is
before the \starttext:


% 
\unprotect

\def\math_border_NC_indeed
{\gdef\math_border_NC{\aligntab}}

\let\math_border_NC\math_border_NC_indeed

\def\math_border_NR
{\glet\math_border_NC\math_border_NC_indeed
\cr}

\unexpanded\def\math_border_matrix#1#2#3% adapted plain
{\begingroup
%
\pushmacro\cr
%
\setbox\scratchbox\hbox\bgroup
\mr B%
\egroup
\scratchdimenone\wd\scratchbox
%
\scratchdimentwo.2\bodyfontsize
%
\mathsurround\zeropoint
%
\def\NC{\math_border_NC}%
\def\NR{\math_border_NR}%
%
\setbox\scratchboxone\vbox\bgroup
\def\cr{%
\crcr
\noalign\bgroup
\kern\scratchdimentwo
\global\let\cr\endline
\egroup
}%
\ialign{%
\startimath\alignmark\alignmark\stopimath
\hfil
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
\aligntab
\thinspace
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\aligntab
\aligntab
\quad
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\crcr
\omit
\strut
\hfil
\crcr
\noalign{\kern-\baselineskip}%
#3\crcr
\omit
\strut
\cr
}%
\egroup
\setbox\scratchboxtwo\vbox\bgroup
\unvcopy\scratchboxone
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\unhbox\globalscratchbox
\unskip
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\startimath
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
\left#1\relax
\kern-\wd\globalscratchbox
\global\setbox\globalscratchbox\vbox\bgroup
\box\globalscratchbox
\kern\scratchdimentwo
\egroup
\vcenter\bgroup
\kern-\ht\globalscratchbox
\unvbox\scratchboxone
\kern-\baselineskip
\egroup
\thinspace
\right#2\relax
\stopimath
\egroup
\null
\thickspace
\vbox\bgroup
\kern\ht\globalscratchbox
\box\scratchboxtwo
\egroup
%
\popmacro\cr
%
\endgroup}

\unexpanded\def\bordermatrix {\math_border_matrix()}
\unexpanded\def\bbordermatrix{\math_border_matrix[]}

\unexpanded\def\startbordermatrix #1\stopbordermatrix
{\math_border_matrix(){#1}}
\unexpanded\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}}

\let\stopbordermatrix \relax
\let\stopbbordermatrix\relax

% 
% Should there be a "\ptotect" ?
%\protect
% 

\starttext

A plain border matrix  :

\startformula
\bbordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula

\startformula
\startbbordermatrix
\NC a \NC b \NC c \NC d \NR
\NC e \NC f \NC G \NC h \NR
\NC i \NC j \NC k \NC l \NR
\stopbbordermatrix
\stopformula

\startformula
\eqalign{
& \lambda=5, \mu =5 \cr
% 
% Does not work if the next line is uncommented
% & \lambda_1=5, \mu =4 \cr
% 
& \mu=8 \cr
}
\stopformula

\stoptext

% 

Thanks for any help. By the way. Is there with MKIV a more direct way to do
such matrix ?
Fabrice.


Le 28 août 2017 à 13:47:59, Hans Hagen (pra...@wxs.nl) a écrit:

Hi,

Put this in cont-new.mkiv (after \unprotect):

\def\math_border_NC_indeed
{\gdef\math_border_NC{\aligntab}}

\let\math_border_NC\math_border_NC_indeed

\def\math_border_NR
{\glet\math_border_NC\math_border_NC_indeed
\cr}

\unexpanded\def\math_border_matrix#1#2#3% adapted plain
{\begingroup
%
\pushmacro\cr
%
\setbox\scratchbox\hbox\bgroup
\mr B%
\egroup
\scratchdimenone\wd\scratchbox
%
\scratchdimentwo.2\bodyfontsize
%
\mathsurround\zeropoint
%
\def\NC{\math_border_NC}%
\def\NR{\math_border_NR}%
%
\setbox\scratchboxone\vbox\bgroup
\def\cr{%
\crcr
\noalign\bgroup
\kern\scratchdimentwo
\global\let\cr\endline
\egroup
}%
\ialign{%
\startimath\alignmark\alignmark\stopimath
\hfil
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
\aligntab
\thinspace
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\aligntab
\aligntab
\quad
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\crcr
\omit
\strut
\hfil
\crcr
\noalign{\kern-\baselineskip}%
#3\crcr
\omit
\strut
\cr
}%
\egroup
\setbox\scratchboxtwo\vbox\bgroup
\unvcopy\scratchboxone
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\unhbox\globalscratchbox
\unskip
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\startimath
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
\left#1\relax

Re: [NTG-context] Border matrix

2017-08-28 Thread Fabrice L
Thanks so much !
I’ll will add an entry to the wiki.
Fabrice.


Le 28 août 2017 à 13:29:55, Hans Hagen (pra...@wxs.nl) a écrit:

On 8/28/2017 6:33 PM, Fabrice L wrote:
> Hi,
>
> I’have a lot of courses notes in MKII. I’m trying to move to MKIV. I
> have a problem that I’m not able to resolve, to make a border matrix
> with brackets. In MKII, I was using a macro, found somewhere, which
> works great, but no longer works; here is the macro:
>
> % Border matrix: first line and column are label
> \catcode`\@=11\relax
> \newdimen\p@renwd
> \font\tenex=cmex10 \setbox0=\hbox{\tenex B} \p@renwd=\wd0
> \def\bbordermatrix#1{\begingroup \m@th
> \setbox\z@\vbox{\def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
> \ialign{$##$\hfil\kern2\p@\kern\p@renwd&\thinspace\hfil$##$\hfil
>   &&\quad\hfil$##$\hfil\crcr
>   \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
>   #1\crcr\omit\strut\cr}}%
>   \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
>   \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
>   \setbox\tw@\hbox{$\kern\wd\@ne\kern-\p@renwd\left[\kern-\wd\@ne
> \global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
> \vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right]$}%
>   \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
> \catcode`\@=12\relax

Such a plain macro needs to be made bodyfotn size aware and such.

> but MKIV gives me the error:
>
> \bbordermatrix #1->\begingroup \m@th
>
>  \setbox \z@ \vbox {\def \cr {\crcr
> \noa...
>
> l.26i & j & k & l \cr}
>
>
> 16   \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
>
> 17 \catcode`\@=12\relax
>
>
> I look for solutions on the list, but did not find anything.Here is a
> minimal example:
>
> \starttext
> A border matrix:
> \startformula
> \bbordermatrix{
>a & b & c & d \cr
>e & f & G & h \cr
>i & j & k & l \cr}
> \stopformula
> \stoptext
>
> As I have in my notes hundreds of such matrix, it is really difficult to
> change the input format.
>
> Do you know, or can you point me, to a solution ? I’m in a dead end..
> Thanks a lot.
I'll add this:

\unprotect

\unexpanded\def\math_border_matrix#1#2#3% adapted plain
{\begingroup
%
\pushmacro\cr
%
\setbox\scratchbox\hbox\bgroup
\mr B%
\egroup
\scratchdimenone\wd\scratchbox
%
\scratchdimentwo.2\bodyfontsize
%
\mathsurround\zeropoint
%
\setbox\scratchboxone\vbox\bgroup
\def\cr{%
\crcr
\noalign\bgroup
\kern\scratchdimentwo
\global\let\cr\endline
\egroup
}%
\ialign{%
\startimath\alignmark\alignmark\stopimath
\hfil
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
\aligntab
\thinspace
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\aligntab
\aligntab
\quad
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\crcr
\omit
\strut
\hfil
\crcr
\noalign{\kern-\baselineskip}%
#3\crcr
\omit
\strut
\cr
}%
\egroup
\setbox\scratchboxtwo\vbox\bgroup
\unvcopy\scratchboxone
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\unhbox\globalscratchbox
\unskip
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\startimath
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
\left#1\relax
\kern-\wd\globalscratchbox
\global\setbox\globalscratchbox\vbox\bgroup
\box\globalscratchbox
\kern\scratchdimentwo
\egroup
\vcenter\bgroup
\kern-\ht\globalscratchbox
\unvbox\scratchboxone
\kern-\baselineskip
\egroup
\thinspace
\right#2\relax
\stopimath
\egroup
\null
\thickspace
\vbox\bgroup
\kern\ht\globalscratchbox
\box\scratchboxtwo
\egroup
%
\popmacro\cr
%
\endgroup}

\unexpanded\def\bordermatrix {\math_border_matrix()}
\unexpanded\def\bbordermatrix{\math_border_matrix[]}

\protect

\starttext

A plain border matrix:

\startformula
\bordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula

\startformula
\bbordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula

\stoptext


-
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___
__

[NTG-context] Border matrix

2017-08-28 Thread Fabrice L
Hi,

I’have a lot of courses notes in MKII. I’m trying to move to MKIV. I have a
problem that I’m not able to resolve, to make a border matrix with
brackets. In MKII, I was using a macro, found somewhere, which works great,
but no longer works; here is the macro:

% Border matrix: first line and column are label
\catcode`\@=11\relax
\newdimen\p@renwd
\font\tenex=cmex10 \setbox0=\hbox{\tenex B} \p@renwd=\wd0
\def\bbordermatrix#1{\begingroup \m@th
\setbox\z@\vbox{\def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
\ialign{$##$\hfil\kern2\p@\kern\p@renwd&\thinspace\hfil$##$\hfil
  &&\quad\hfil$##$\hfil\crcr
  \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
  #1\crcr\omit\strut\cr}}%
  \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
  \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
  \setbox\tw@\hbox{$\kern\wd\@ne\kern-\p@renwd\left[\kern-\wd\@ne
\global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
\vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right]$}%
  \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
\catcode`\@=12\relax

but MKIV gives me the error:

\bbordermatrix #1->\begingroup \m@th

 \setbox \z@ \vbox {\def \cr {\crcr
\noa...

l.26i & j & k & l \cr}




16   \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}

17 \catcode`\@=12\relax

I look for solutions on the list, but did not find anything.Here is a
minimal example:

\starttext
A border matrix:
\startformula
\bbordermatrix{
   a & b & c & d \cr
   e & f & G & h \cr
   i & j & k & l \cr}
\stopformula
\stoptext

As I have in my notes hundreds of such matrix, it is really difficult to
change the input format.

Do you know, or can you point me, to a solution ? I’m in a dead end..
Thanks a lot.
F.
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Steps in presentation

2015-01-02 Thread Fabrice L.

pol stra ryzz at hotmail.fr writes:

  Hello,I tried to use some steps in a presentation.  In the following
conversationhttp://www.mail-archive.com/ntg-context at
ntg.nl/msg53524.html, Wolfgang saysthat we can use the pre-60 module. 
So I tried this snippet:\usemodule[pre-
stepwise]\starttext\StartSteps\startitemize\item one \FlushStep\item two
\FlushStep\item three \FlushStep\stopitemize\StopSteps\stoptextBut it
does not compile:ConTeXt  ver: 2012.09.11 20:36 MKIV  fmt: 2012.9.12 
int: english/englishsystem   cont-new.mkiv
loaded(/opt/context-minimals/texmf-context/tex/context/base/cont-new.
mkivsystem   beware: some patches loaded from
cont-new.mkiv)fonts    latin modern fonts are not
preloadedlanguages    language en is
active(pre60.texresolvers    modules  loaded:
'pre-stepwise'(/opt/context-minimals/texmf-context/tex/context/base/s-
pre-60.mkivfonts    beware: no fonts are loaded yet, using 'lm
mono' in box(/opt/context-minimals/texmf-
context/tex/context/base/java-imp-stp.mkiv)interactions     javascripts
 loaded: library 'stp'metapost     loaded: library 'nav'
(/opt/context-minimals/texmf-
context/tex/context/base/meta-imp-nav.mkiv)){/opt/context-minimals/texmf
- fonts/fonts/map/pdftex/context/mkiv-base.map}fonts   
preloading latin modern fonts (second stage)fonts   
typescripts  unknown: library 'loc'{/opt/context-minimals/texmf-
fonts/fonts/map/dvips/lm/lm-math.map}{/opt/context-minimals/texmf-
fonts/fonts/map/dvips/lm/lm-rm.map}fonts    virtual math 
unable to resolve name mapsfromcharfonts    fallback modern rm
12pt is loaded!LuaTeX error: There should have been a lua node here,
not an object with type string! == Fatal error occurred, no output PDF
file produced!Is there something broken in recent release of conteXt? 
By the way It seemsthere is no Rawsteps module anymore but it still is
in the wiki. Is there issomething like a bugtracker for conteXt, in
order to signal when  a feature isnot working or outdated and signal
when it is back (or definitly depreciate)?(it would be a complementary
tool for the mailing list)   



I'm following on an old thread about the RawSteps Module, which is
broken in MKIV. Trying to move to MKIV, this is a no go for me since I
absolutely need this module for teaching. I've contacted David Munger,
the author of the module,  last September, which had been a real helper
in the past about this module, but he has presently no time to work on
this. If someone know how to fix the problem, I provide a short minimal
exemple:

%%% \enableregime[utf] 
\usemodule[rsteps]

\setupcolors[state=start] \setuppapersize[S4][S4]

\starttext

\StartSteps \startformula 
 \eqalign{ P[\text{atteindre l'état}\ j | \text{partant de } i] 
   = P\left[\bigcup_{n=0}^\infty (X_n=j)| X_0 = i\right]\cr
   \leq \sum_{n=0}^\infty P[X_n=j|X_0=i]\cr 
   =\sum_{n=0}^\infty P_{ij}^n =0 \cr } 
\stopformula \StopSteps

\StartSteps \startformula
\eqalign{
  \FromStep[1][reserve]{P[\text{atteindre l'état}\ j | \text{partant de } i]} 
  \FromStep[1][reserve]{= P\left[\bigcup_{n=0}^\infty (X_n=j)| X_0 = 
i\right]}\cr 
  \FromStep[2][reserve]{\leq \sum_{n=0}^\infty P[X_n=j|X_0=i]}\cr 
  \FromStep[3][reserve]{=\sum_{n=0}^\infty P_{ij}^n =0 }\cr } 
\stopformula
\StopSteps

\stoptext 
 


Also, here is the contextHarden link:
http://wiki.contextgarden.net/RawSteps

If somebody know another solution to show content by step in a page, I
would be happy to know about it. Thanks, Fabrice.


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