Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 8:37 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Hans Hagen wrote:


dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather
than a path. Here is a (to me) simpler definition, where you can change the
shape:


just look in the pdf ... in your case the dot is a n point path while otherwise
it uses the default postscript pen (which is a dot)


Ah, that makes sense.


it surprised me that a math guru like you doesn't do this:

vardef dotlabel@#(expr s,z) text t_ =
% draw textext("$\bullet$") scaled (1/2) shifted z ;
% draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
 draw textext("$\blacksquare$") scaled (1/4) shifted z ;
 label@#(s,z) t_ ;
enddef ;
\stopMPdefinitions


Ha! I know that you said this as a joke, but as someone who did try to use the old 
font-based picture environment in LaTeX back in the day, I would never try to use fonts 
for "drawing". Especially, math fonts, where every designer has a different 
idea of what the shape should look like.

ah pictex memories ... drawing lines with cmr5 periods ...

but actually, we can define a stable font with symbols in metafun and 
use that (quite efficient too) and then one can even cut'n'paste those 
tiny symbols (don't worry ... not much of a challenge so low on my list)


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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Hans Hagen wrote:

> > dotlabel uses a pen to draw the dot, and I am not sure why it uses that 
> > rather
> > than a path. Here is a (to me) simpler definition, where you can change the
> > shape:
> 
> just look in the pdf ... in your case the dot is a n point path while 
> otherwise
> it uses the default postscript pen (which is a dot)

Ah, that makes sense. 

> it surprised me that a math guru like you doesn't do this:
> 
> vardef dotlabel@#(expr s,z) text t_ =
> % draw textext("$\bullet$") scaled (1/2) shifted z ;
> % draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
> draw textext("$\blacksquare$") scaled (1/4) shifted z ;
> label@#(s,z) t_ ;
> enddef ;
> \stopMPdefinitions

Ha! I know that you said this as a joke, but as someone who did try to use the 
old font-based picture environment in LaTeX back in the day, I would never try 
to use fonts for "drawing". Especially, math fonts, where every designer has a 
different idea of what the shape should look like. 

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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 7:04 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Otared Kavian wrote:


Hi Aditya,
Thank you very much !
That's great indeed, you gave me an elegant solution.
  
One more question, in order for me to understand a little more: when defining a new dotlabel as you do, might it not conflict with the internal definitions of dotlabel in Metafun in some other place?

Maybe it is safer for me to call it something like  « dotshapelabel » ?


In general, I agree. Redefining internal macros has the advantage that your 
code doesn't have to change. See, for example:


it depends a bit ... redefing dotlabel in a compatible way is kind of 
ok, but using/redefining \foo_bar_something_internal is a real bad idea 
as that is not part of the interface (okay, i know that there are macro 
packages out there where it's part of the concept to redefine low level 
stuff for styles but in context we should try to avoid it ... we should 
then adapt the high level interface to suport something)


it also depends who does it ... i know that aditya knows the internals 
well enough to deal with it


(one of my concerns is always that while we try to come up with 
efficient solutions it's easy to make things inefficient but that's not 
the case here ... unless of course we want to nurture the 'context is 
slow' meme)


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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Hans Hagen

On 12/10/2020 6:44 PM, Aditya Mahajan wrote:

On Thu, 10 Dec 2020, Otared Kavian wrote:


Hi all,

In Metafun when representing a point I woul dlike to have some dots represented 
by a square (or even by another scalable symbol): for instance in the following 
I would like the dot at the point B to be a square:

\starttext
\startMPcode
draw (2cm,3cm) -- (3cm,5cm) ;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm))
withpen pencircle scaled 12pt
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm))
withpen pencircle scaled 12pt
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

I wonder whether it is possible to define something like « drawsquaredot » or « 
squaredotlabel » in order to do this.


dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather 
than a path. Here is a (to me) simpler definition, where you can change the 
shape:


just look in the pdf ... in your case the dot is a n point path while 
otherwise it uses the default postscript pen (which is a dot)


actually fullcircle is pencircle so you can ponder why that is the case -)


\startMPdefinitions
newpath dotlabelshape;

dotlabelshape := fullcircle;

vardef dotlabel@#(expr s,z) text t_ =
 label@#(s,z) t_ ;
 fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
enddef ;
\stopMPdefinitions

\starttext
\startMPcode
newpath p ;
p := (2cm, 3cm) -- (3cm, 5cm);
dotlabeldiam := 12pt;

% Default
draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p)
 withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p)
 withcolor transparent("exclusion",.5,red) ;

% Using a square "dot"
p := p shifted (5cm, 0);
dotlabelshape := fullsquare;

draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p)
 withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p)
 withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

These types of macros are also a good candidate for the new LMTX syntax, where 
we can make all components configurable via a key-value interface 
(labeldistance etc. as well).

it surprised me that a math guru like you doesn't do this:

vardef dotlabel@#(expr s,z) text t_ =
% draw textext("$\bullet$") scaled (1/2) shifted z ;
% draw textext("$\blacktriangle$") scaled (1/4) shifted z ;
draw textext("$\blacksquare$") scaled (1/4) shifted z ;
label@#(s,z) t_ ;
enddef ;
\stopMPdefinitions



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


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Otared Kavian wrote:

> Hi Aditya,
> Thank you very much !
> That's great indeed, you gave me an elegant solution.
>  
> One more question, in order for me to understand a little more: when defining 
> a new dotlabel as you do, might it not conflict with the internal definitions 
> of dotlabel in Metafun in some other place?
> Maybe it is safer for me to call it something like  « dotshapelabel » ?

In general, I agree. Redefining internal macros has the advantage that your 
code doesn't have to change. See, for example:

https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp

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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Otared Kavian
Hi Aditya,
Thank you very much !
That's great indeed, you gave me an elegant solution.
 
One more question, in order for me to understand a little more: when defining a 
new dotlabel as you do, might it not conflict with the internal definitions of 
dotlabel in Metafun in some other place?
Maybe it is safer for me to call it something like  « dotshapelabel » ?

Best regards and agin many thanks: Otared

> On 10 Dec 2020, at 18:44, Aditya Mahajan  wrote:
> 
> On Thu, 10 Dec 2020, Otared Kavian wrote:
> 
>> Hi all,
>> 
>> In Metafun when representing a point I woul dlike to have some dots 
>> represented by a square (or even by another scalable symbol): for instance 
>> in the following I would like the dot at the point B to be a square:
>> 
>> \starttext
>> \startMPcode
>> draw (2cm,3cm) -- (3cm,5cm) ;
>> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
>>  withpen pencircle scaled 12pt 
>>  withcolor transparent("exclusion",.5,red) ;
>> 
>> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
>>  withpen pencircle scaled 12pt 
>>  withcolor transparent("exclusion",.5,red) ;
>> \stopMPcode
>> \stoptext
>> 
>> I wonder whether it is possible to define something like « drawsquaredot » 
>> or « squaredotlabel » in order to do this.
> 
> dotlabel uses a pen to draw the dot, and I am not sure why it uses that 
> rather than a path. Here is a (to me) simpler definition, where you can 
> change the shape:
> 
> \startMPdefinitions
> newpath dotlabelshape;
> 
> dotlabelshape := fullcircle;
> 
> vardef dotlabel@#(expr s,z) text t_ =
>label@#(s,z) t_ ;
>fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
> enddef ;
> \stopMPdefinitions
> 
> \starttext
> \startMPcode
> newpath p ; 
> p := (2cm, 3cm) -- (3cm, 5cm);
> dotlabeldiam := 12pt;
> 
> % Default
> draw p;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> % Using a square "dot"
> p := p shifted (5cm, 0);
> dotlabelshape := fullsquare;
> 
> draw p;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
>withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
>withcolor transparent("exclusion",.5,red) ;
> \stopMPcode
> \stoptext
> 
> These types of macros are also a good candidate for the new LMTX syntax, 
> where we can make all components configurable via a key-value interface 
> (labeldistance etc. as well).
> 
> 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
___


Re: [NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Aditya Mahajan
On Thu, 10 Dec 2020, Otared Kavian wrote:

> Hi all,
> 
> In Metafun when representing a point I woul dlike to have some dots 
> represented by a square (or even by another scalable symbol): for instance in 
> the following I would like the dot at the point B to be a square:
> 
> \starttext
> \startMPcode
> draw (2cm,3cm) -- (3cm,5cm) ;
> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
>   withpen pencircle scaled 12pt 
>   withcolor transparent("exclusion",.5,red) ;
> 
> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
>   withpen pencircle scaled 12pt 
>   withcolor transparent("exclusion",.5,red) ;
> \stopMPcode
> \stoptext
> 
> I wonder whether it is possible to define something like « drawsquaredot » or 
> « squaredotlabel » in order to do this.

dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather 
than a path. Here is a (to me) simpler definition, where you can change the 
shape:

\startMPdefinitions
newpath dotlabelshape;

dotlabelshape := fullcircle;

vardef dotlabel@#(expr s,z) text t_ =
label@#(s,z) t_ ;
fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_;
enddef ;
\stopMPdefinitions

\starttext
\startMPcode
newpath p ; 
p := (2cm, 3cm) -- (3cm, 5cm);
dotlabeldiam := 12pt;

% Default
draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
withcolor transparent("exclusion",.5,red) ;

% Using a square "dot"
p := p shifted (5cm, 0);
dotlabelshape := fullsquare;

draw p;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) 
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

These types of macros are also a good candidate for the new LMTX syntax, where 
we can make all components configurable via a key-value interface 
(labeldistance etc. as well).

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
___


[NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?

2020-12-10 Thread Otared Kavian
Hi all,

In Metafun when representing a point I woul dlike to have some dots represented 
by a square (or even by another scalable symbol): for instance in the following 
I would like the dot at the point B to be a square:

\starttext
\startMPcode
draw (2cm,3cm) -- (3cm,5cm) ;
dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) 
withpen pencircle scaled 12pt 
withcolor transparent("exclusion",.5,red) ;

dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) 
withpen pencircle scaled 12pt 
withcolor transparent("exclusion",.5,red) ;
\stopMPcode
\stoptext

I wonder whether it is possible to define something like « drawsquaredot » or « 
squaredotlabel » in order to do this.
If I use for B the command
withpen pensquare scaled 12pt
then the dot is a square, but the label B is drawn in a strange way.

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
___


Re: [NTG-context] LMTX, repeated caption

2020-12-10 Thread Hans Hagen

On 12/10/2020 10:58 AM, Jean-Philippe Rey wrote:

Dear list,

In some unclear circumstances, a figure caption is repeated above the figure, 
as with the following example.

==
\starttext
\placefigure
{This caption shouldn't be repeated}
{\hbox{anything here}}
\stoptext
==

The caption is not repeated for all figures. With a longer caption or a wider 
figure, the bug disappears. My guess is that it is triggered by a certain ratio 
between caption length and figure width!

I hope this helps.


fixed in next upload


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


Re: [NTG-context] LMTX, repeated caption

2020-12-10 Thread Bertrand Masson

Hello

I have the same problem.

I noticed that it depends on the length of the caption.

Best regards.
Le 10/12/2020 à 10:58, Jean-Philippe Rey a écrit :

Dear list,

In some unclear circumstances, a figure caption is repeated above the figure, 
as with the following example.

==
\starttext
\placefigure
{This caption shouldn't be repeated}
{\hbox{anything here}}
\stoptext
==

The caption is not repeated for all figures. With a longer caption or a wider 
figure, the bug disappears. My guess is that it is triggered by a certain ratio 
between caption length and figure width!

I hope this helps.

Best regards,


___
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] LMTX, repeated caption

2020-12-10 Thread Jean-Philippe Rey
Dear list,

In some unclear circumstances, a figure caption is repeated above the figure, 
as with the following example.

==
\starttext
\placefigure
{This caption shouldn't be repeated}
{\hbox{anything here}}
\stoptext
==

The caption is not repeated for all figures. With a longer caption or a wider 
figure, the bug disappears. My guess is that it is triggered by a certain ratio 
between caption length and figure width!

I hope this helps.

Best regards,

-- 
Jean-Philippe Rey
jean-philippe@centralesupelec.fr
91192 Gif-sur-Yvette Cedex - France
Empreinte PGP : 807A 5B2C 69E4 D4B5 783A 428A 1B5E E83E 261B BF51


mfe-placetable.pdf
Description: Adobe PDF document


mfe-placetable.log
Description: Binary data
___
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
___