[NTG-context] button

2024-09-16 Thread Hans van der Meer via ntg-context
\button is defined to jump to a given reference. However, I would like to place 
a button that can execute a macro to be defined by myself.
Thus for example pushing the button \executebutton{text}{macro} will execute 
that macro.

Is this available somewhere in ConTeXT? If not, can it be provided in a future 
update?

yours sincerely
dr. Hans van der Meer



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: button

2024-09-16 Thread Henning Hraban Ramm

Am 16.09.24 um 11:41 schrieb Hans van der Meer via ntg-context:
\button is defined to jump to a given reference. However, I would like 
to place a button that can execute a macro to be defined by myself.
Thus for example pushing the button \executebutton{text}{macro} will 
execute that macro.


Is this available somewhere in ConTeXT? If not, can it be provided in a 
future update?


Did you try \button[Options]{Something}[YourJSFunction] ?

I don’t know it that’s limited to a few predefined functions.

see https://wiki.contextgarden.net/Widgets#JavaScript and 
https://source.contextgarden.net/scrn-but.mkvi


Just to be sure: You understand that this works via JavaScript in the 
viewer, only supported by Acrobat and PDF Studio?


Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Calling C code from ConTeXt LMTX

2024-09-16 Thread Bruce Horrocks


> On 15 Sep 2024, at 22:11, Florent Michel  wrote:
> 
> Thanks Bruce for your very helpful reply! 
> 
> The reason for my question was indeed consistency, e.g. ensuring figure 
> captions stay up to date with what the figures show when changing parameters. 
> Thinking more about it, the second solution you mention seems to be a better 
> option, though - I can simply define the parameters in an external file and 
> read it from both the PDF solver and ConTeXt to ensure consistency. Thanks 
> for mentioning it!  
> 
> Thank you also for mentioning \executesystemcommand, which I was not aware 
> of! 

Another option might be to use a marker such as

% DE_figure_here param1 param2 param3

in your ConTeXt source and then use 'awk' or another Unix text pre-processor to 
scan through for these, run the appropriate DE calculation, plot the graph and 
generate the appropriate \placefigure command to go in its place.

Bonus marks if it can automatically generate the caption based on the 
parameters! But if not, the marker can always follow the \placefigure macro e.g.

\placefigure
  {This is a DE showing something and something else}
  % DE_figure_here param1 param2 param3

so the awk code only needs to insert the image file name.

Note I’ve deliberately omitted the braces from the bit to be substituted so 
that you need to generate them in the awk. That way, if you forget to process, 
you’ll get an error not a missing image.

HTH
—
Bruce Horrocks
Hampshire, UK

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Calling C code from ConTeXt LMTX

2024-09-16 Thread Henning Hraban Ramm

Am 16.09.24 um 12:59 schrieb Bruce Horrocks:




On 15 Sep 2024, at 22:11, Florent Michel  wrote:

Thanks Bruce for your very helpful reply!

The reason for my question was indeed consistency, e.g. ensuring figure 
captions stay up to date with what the figures show when changing parameters. 
Thinking more about it, the second solution you mention seems to be a better 
option, though - I can simply define the parameters in an external file and 
read it from both the PDF solver and ConTeXt to ensure consistency. Thanks for 
mentioning it!

Thank you also for mentioning \executesystemcommand, which I was not aware of!


Another option might be to use a marker such as

% DE_figure_here param1 param2 param3

in your ConTeXt source and then use 'awk' or another Unix text pre-processor to 
scan through for these, run the appropriate DE calculation, plot the graph and 
generate the appropriate \placefigure command to go in its place.

Bonus marks if it can automatically generate the caption based on the 
parameters! But if not, the marker can always follow the \placefigure macro e.g.

\placefigure
   {This is a DE showing something and something else}
   % DE_figure_here param1 param2 param3

so the awk code only needs to insert the image file name.

Note I’ve deliberately omitted the braces from the bit to be substituted so 
that you need to generate them in the awk. That way, if you forget to process, 
you’ll get an error not a missing image.


That sounds needlessly convoluted to me.
I’d use Aditya’s filter module to call external programs, it also does 
caching, i.e. if the parameters don’t change, it won’t waste processing 
time.


https://github.com/adityam/filter

Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Calling C code from ConTeXt LMTX

2024-09-16 Thread Bruce Horrocks
On 16 Sep 2024, at 12:15, Henning Hraban Ramm  wrote:
> 
> Am 16.09.24 um 12:59 schrieb Bruce Horrocks:
>>> On 15 Sep 2024, at 22:11, Florent Michel  wrote:
>>> 
>>> Thanks Bruce for your very helpful reply!
>>> 
>>> The reason for my question was indeed consistency, e.g. ensuring figure 
>>> captions stay up to date with what the figures show when changing 
>>> parameters. Thinking more about it, the second solution you mention seems 
>>> to be a better option, though - I can simply define the parameters in an 
>>> external file and read it from both the PDF solver and ConTeXt to ensure 
>>> consistency. Thanks for mentioning it!
>>> 
>>> Thank you also for mentioning \executesystemcommand, which I was not aware 
>>> of!
>> Another option might be to use a marker such as
>> % DE_figure_here param1 param2 param3
>> in your ConTeXt source and then use 'awk' or another Unix text pre-processor 
>> to scan through for these, run the appropriate DE calculation, plot the 
>> graph and generate the appropriate \placefigure command to go in its place.
>> Bonus marks if it can automatically generate the caption based on the 
>> parameters! But if not, the marker can always follow the \placefigure macro 
>> e.g.
>> \placefigure
>>   {This is a DE showing something and something else}
>>   % DE_figure_here param1 param2 param3
>> so the awk code only needs to insert the image file name.
>> Note I’ve deliberately omitted the braces from the bit to be substituted so 
>> that you need to generate them in the awk. That way, if you forget to 
>> process, you’ll get an error not a missing image.
> 
> That sounds needlessly convoluted to me.
> I’d use Aditya’s filter module to call external programs, it also does 
> caching, i.e. if the parameters don’t change, it won’t waste processing time.
> 
> https://github.com/adityam/filter

I think Florent already has a situation that can be described as convoluted. 
Whether this is more so only he can say.

I didn’t suggest the filter module to start with because it filters a buffer 
through an external command which isn’t Florent’s use-case (which is just the 
ability to call an external command). However I see, buried deeply in the docs, 
under the heading "Special use case:  \write18 with caching” there is the 
ability to call a single command which would work.

Someone with better knowledge of the macro would need to explain how to adapt 
the ’size’ key to Florent’s usage to enable the caching.

Regards,
—
Bruce Horrocks
Hampshire, UK

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Margins using 2UP imposition schema

2024-09-16 Thread Willi Egger
Angel,

I used a lot of impositioning in the past. 

If you want to have small white space at the outer edge, then do not use 
width=fit. Control the inner whitespace with backspace=… Then calculate the 
width of the textarea you want and set this value in width=... There is no need 
to use cutspace in your approach.

Willi
> On 14 Sep 2024, at 19:08, Angel M Alganza  wrote:
> 
> Hello:
> 
> I'm composing an A5 booklet printed on an A4 paper using the 2UP imposition 
> schema.  I believe, in such case, margins should be controlled using 
> 'backspace' and 'cutspace' options of the \setuplayout command, but I'm 
> afraid I don't quite understand how to use those properl.  I want to make the 
> 'external' margin (right on odd pages and left on even pages) as small as 
> possible, and the 'internal' margin larger, so that I can hole punch the 
> booklet.
> 
> I believe, in such case, margins should be controlled using 'backspace' and 
> 'cutspace' options of the \setuplayout command, but I'm afraid I don't quite 
> understand how to use those properly.  Here's a minimal example:
> 
> \setuppapersize[A5][A4]
> \setuparranging[2UP,rotated]
> \setuplayout
> [topspace=13pt,
> backspace=30pt,
> cutspace=-20pt,
> width=fit,
> height=fit,
> header=0pt,
> footer=0pt]
> \setuppagenumbering[state=stop]
> \setupbodyfont[small]
> \starttext
> \dorecurse{20}{\input tufte \vskip 1em}
> \stoptext
> 
> I wonder how I could reduce the left margin and increase the left one on the 
> even pages.
> 
> Any pointers, please?
> 
> Thank you so much in advance.
> Ángel
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Calling C code from ConTeXt LMTX

2024-09-16 Thread Florent Michel
Thanks again Bruce! I had not thought about the possibility of parsing
comments in the tex file from an external tool, but that sounds like a very
good option. I like the fact that it would allow the tex file to contain
all the information needed to keep track of what is represented without
having to duplicate the parameter values. And since my specific workflow is
indeed already convoluted it will not really add extra complexity.

Thanks also Henning for mentioning the filter module! I'll have a closer
look into how I could use it - and it will certainly come useful, either
for this project or a future one!

Best regards,
Florent

Le lun. 16 sept. 2024 à 13:08, Bruce Horrocks  a écrit :

> On 16 Sep 2024, at 12:15, Henning Hraban Ramm  wrote:
> >
> > Am 16.09.24 um 12:59 schrieb Bruce Horrocks:
> >>> On 15 Sep 2024, at 22:11, Florent Michel 
> wrote:
> >>>
> >>> Thanks Bruce for your very helpful reply!
> >>>
> >>> The reason for my question was indeed consistency, e.g. ensuring
> figure captions stay up to date with what the figures show when changing
> parameters. Thinking more about it, the second solution you mention seems
> to be a better option, though - I can simply define the parameters in an
> external file and read it from both the PDF solver and ConTeXt to ensure
> consistency. Thanks for mentioning it!
> >>>
> >>> Thank you also for mentioning \executesystemcommand, which I was not
> aware of!
> >> Another option might be to use a marker such as
> >> % DE_figure_here param1 param2 param3
> >> in your ConTeXt source and then use 'awk' or another Unix text
> pre-processor to scan through for these, run the appropriate DE
> calculation, plot the graph and generate the appropriate \placefigure
> command to go in its place.
> >> Bonus marks if it can automatically generate the caption based on the
> parameters! But if not, the marker can always follow the \placefigure macro
> e.g.
> >> \placefigure
> >>   {This is a DE showing something and something else}
> >>   % DE_figure_here param1 param2 param3
> >> so the awk code only needs to insert the image file name.
> >> Note I’ve deliberately omitted the braces from the bit to be
> substituted so that you need to generate them in the awk. That way, if you
> forget to process, you’ll get an error not a missing image.
> >
> > That sounds needlessly convoluted to me.
> > I’d use Aditya’s filter module to call external programs, it also does
> caching, i.e. if the parameters don’t change, it won’t waste processing
> time.
> >
> > https://github.com/adityam/filter
>
> I think Florent already has a situation that can be described as
> convoluted. Whether this is more so only he can say.
>
> I didn’t suggest the filter module to start with because it filters a
> buffer through an external command which isn’t Florent’s use-case (which is
> just the ability to call an external command). However I see, buried deeply
> in the docs, under the heading "Special use case:  \write18 with caching”
> there is the ability to call a single command which would work.
>
> Someone with better knowledge of the macro would need to explain how to
> adapt the ’size’ key to Florent’s usage to enable the caching.
>
> Regards,
> —
> Bruce Horrocks
> Hampshire, UK
>
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] syntax highlighting: pandoc uses Kate

2024-09-16 Thread Henning Hraban Ramm

Hi, since we recently discussed editor support and syntax highlighting:

Pandoc can use definitions from Kate[1] for syntax highlighting in a 
code block via "--syntax-definition".


There’s also ConTeXt support (MkIV/LMTX):

https://kate-editor.org/syntax/data/syntax/context.xml

Apparently, it can switch contexts to Lua, XML, MetaPost etc.
But the list of commands is quite short.

In case the author (Philipp A.) is listening: Is this intentional (“not 
necessary, highlight everything that starts with a backslash”)? 
Otherwise it probably would make sense to read in the interface files 
(i-*.xml).


I can’t tell if it would make sense to support this syntax via a module 
(like scite and vim). What we have if probably enough for most of us.


Hraban

[1]
List: https://kate-editor.org/syntax/
Specs: https://api.kde.org/frameworks/syntax-highlighting/html/
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] OT: fractal serif

2024-09-16 Thread Henning Hraban Ramm

Here’s an idea for a variable font axis: "serif fractal iterations"

Source: https://mastodon.social/@Agar/113146403367955424

;)___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] (ConTeXt LMTX 2.11.05) how do I make it so that sections, descriptions, and itemizations have just a space between some of the text that they produce

2024-09-16 Thread Felix
\setuppapersize[letter][letter]

\setupalign[normal]

\setuplayout[
backspace=0.5in,
topspace=0.0in,
header=.5in, % No headers
footer=.5in, % Space for the footer
width=middle,
height=middle,
]

\definefontfeature[timesfeatures][default][
trep=yes, % Enables single and double quotes to show up correctly in text, 
perhaps does more
dlig=yes,
% cpsp=yes, use for all caps only
]

\definefontfamily [myfonts] [rm][Times New Roman] 
[features=timesfeatures] % dlig enables times new roman ligatures, and cpsp is 
used by tnr, not aptos

\setupbodyfont[myfonts,12pt]

\mainlanguage[en-us]

\setupindenting[yes,0.5in]

\definedescription[description]

\setupdescription[description][
alternative=serried,
headstyle=bold,
style=normal,
width=broad,
before=,
after=,
]

\setupheads[indentnext=yes] % To get indentation after section numbers, use this

\setuphead[section][
sectionstopper={.}, % Add period after numbers
conversion=R,
before=,
after=,
style=sc, % Small caps style
align=middle, % Center the section titles
]

\startsetups document:start
\centerline{\documentvariable{title}}
\centerline{\documentvariable{author}}
\centerline{\documentvariable{date}}
\blank[line]
\stopsetups

\startdocument[
title={Chapter 4 Quiz},
author={Author},
date={September 16, 2024}
]

\startitemgroup[itemize][n]
\startitem
I'm not a fan of the default spacing
\stopitem
\stopitemgroup

\startdescription{I'm not a fan of the}
default spacing
\stopdescription

\startsection[title={I'm not a fan of the}]
default spacing
\stopsection

\stopdocument

This code shows how I am getting the default spacing between the words from 
itemize, description, and the spacing between the roman numeral and the section 
title. I tried figuring out how to get the spacing for all of these to be set 
to a single space worth but it seems to not be possible with `distance`, 
because it asks for a dimension. How can I get a `\space`'s worth of spacing to 
be the default in descriptions, itemizations, and sections? for itemizations 
and descriptions the spacing seems to vary and I really don't like that. I 
would be thankful to know if there's a way to change the spacing.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: (ConTeXt LMTX 2.11.05) how do I make it so that sections, descriptions, and itemizations have just a space between some of the text that they produce

2024-09-16 Thread Wolfgang Schuster

Felix schrieb am 16.09.2024 um 16:24:

[...]

This code shows how I am getting the default spacing between the words from 
itemize, description, and the spacing between the roman numeral and the section 
title. I tried figuring out how to get the spacing for all of these to be set 
to a single space worth but it seems to not be possible with `distance`, 
because it asks for a dimension. How can I get a `\space`'s worth of spacing to 
be the default in descriptions, itemizations, and sections? for itemizations 
and descriptions the spacing seems to vary and I really don't like that. I 
would be thankful to know if there's a way to change the spacing.


Please remove everything from your examples which isn't necessary to 
show the problem, in your example you can get rid of


- the page layout,
- the font settings,
- the title page and
- all settings from \setupdescription and \setuphead unrelated to the 
space between number/title and the text.



The value you're looking for is \spaceamount which can be used with the 
distance-key to set the width of a space as separator.



For descriptions you have to set the value of the width to fit and use 
the distance key to set a fixed
value for the space between the title and following text, to ensure the 
space doesn't increase set

also the shrink and stretch values to 0.

 begin example
\definedescription
  [description]
  [alternative=serried,
   width=fit,
   distance=\spaceamount,
   stretch=0,
   shrink=0]

\starttext

\startdescription [title={I'm not a fan of the}]
default spacing
\stopdescription

\stoptext
 end example


For itemize you can use the fit keyword but be aware once you have more 
than 9 entries you get
a bigger space between the number and content because the environment 
set the width of all

entries to width of the widest number.

 begin example
\starttext

\startitemize[n,fit][distance=\spaceamount]
\startitem
I'm not a fan of the default spacing
\stopitem
\stopitemize

\stoptext
 end example


For section titles you just have to change the distance value.

 begin example
\setuphead
  [section]
  [distance=\spaceamount]

\starttext

\startsection[title={I'm not a fan of the}]

default spacing

\stopsection

\stoptext
 end example


Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Same font for metafun as document

2024-09-16 Thread Shiv Shankar Dayal
Suppose I use dejavu fonts for the main document then how can I have
metafun use the same fonts for labelling. All the metafun code is
inline.

-- 
Respect,
Shiv Shankar Dayal
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Same font for metafun as document

2024-09-16 Thread Henning Hraban Ramm

Am 17.09.24 um 08:05 schrieb Shiv Shankar Dayal:

Suppose I use dejavu fonts for the main document then how can I have
metafun use the same fonts for labelling. All the metafun code is
inline.


MetaFun usually uses the main font. If it doesn’t, check if you set it 
up before you create your graphics.


If there’s a problem, make a minimal example (MWE).

Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: Same font for metafun as document

2024-09-16 Thread Shiv Shankar Dayal
Yes, you are correct. I got confused with the font shapes
and did not look close enough.

Thanks a bunch.

On Tue, Sep 17, 2024 at 11:45 AM Henning Hraban Ramm  wrote:
>
> Am 17.09.24 um 08:05 schrieb Shiv Shankar Dayal:
> > Suppose I use dejavu fonts for the main document then how can I have
> > metafun use the same fonts for labelling. All the metafun code is
> > inline.
>
> MetaFun usually uses the main font. If it doesn’t, check if you set it
> up before you create your graphics.
>
> If there’s a problem, make a minimal example (MWE).
>
> Hraban
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
>
> maillist : ntg-context@ntg.nl / 
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___



-- 
Respect,
Shiv Shankar Dayal
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___