[NTG-context] Re: get measures as dimension in Lua

2024-06-09 Thread Max Chernoff
Hi Hraban,

On Sun, 2024-06-09 at 22:12 +0200, Henning Hraban Ramm wrote:
> when I define a measure on the TeX side, I used to get at the value in
> Lua with tex.getdim, like:
>
> \definemeasure[Bleed][3mm]
>
> tex.getdimen("Bleed")
>
> But now I get "incorrect dimen name".
> I need it as a dimension, since I do calculations with other dimensions
> like "topspace".
>
> How should I do this correctly?

There doesn't appear to be any official interfaces to get the value of a
measure from Lua, but the following should work okay:

\definemeasure[mymeasure][10pt]

\newdimen\mydimen \mydimen=10pt

\definemeasure[measureexpr][1in + 27.73pt]

\startluacode
-- Returns the unexpanded value of some variable in a namespace.
local function get_variable(namespace, variable)
-- -- Doesn't work since "measure" is defined as a "system 
namespace".
-- namespace = interfaces.getnamespace(namespace)
namespace = tokens.getters.macro("??" .. namespace)
return tokens.getters.macro(namespace .. variable)
end

-- Gets the value of a measure and converts it to an integer in sp 
units.
local function get_measure(name)
return tex.sp(get_variable("measure", name))
end

-- Gets the \dimexpr-evaluated value of a measure, in sp units.
local function get_measure_expr(name)
local namespace = tokens.getters.macro("??measure")
-- Undocumented, but seems to work as expected.
return tex.getdimensionvalue(namespace .. name)
end

-- Print the values of the lengths.
print(("="):rep(80))
print("mymeasure:"  , get_measure("mymeasure")   )
print("mydimen:", tex.dimen["mydimen"]   )
print("measureexpr:", get_measure_expr("measureexpr"))
print(("="):rep(80))
\stopluacode

\startTEXpage
\measure{mymeasure}
\the\mydimen
\measure{measureexpr}
\stopTEXpage

Thanks,
-- Max

___
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] get measures as dimension in Lua

2024-06-09 Thread Henning Hraban Ramm

Hi,
when I define a measure on the TeX side, I used to get at the value in 
Lua with tex.getdim, like:


\definemeasure[Bleed][3mm]

tex.getdimen("Bleed")

But now I get "incorrect dimen name".
I need it as a dimension, since I do calculations with other dimensions 
like "topspace".


How should I do this correctly?

(I just assume this used to work – the code is old any maybe stuck in an 
intermediate state where I switched from \newdim to \definemeasure…)


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] regular online meet-up

2024-06-09 Thread Henning Hraban Ramm

I nearly forgot:

You’re invited to our regular online meet-up, this upcoming
Wednesday, June 12th, 19:00 CEST (UTC+2)

at https://lecture.senfcall.de/hen-rbr-rku-oke
(same, but shorter: https://u.mtxrun.eu/ctxmtg)

ConTeXt users of all levels are welcome!

Do you have a subject that you’d like to talk about?

Looking forward to seeing you,
Hraban


(Same blurb as always:)

[Howto]
* No special software installation required; most modern browsers should 
work (WebRTC required).

* Open the URL above, accept the privacy statement,
* enter your name,
* click "join" (or "start" if you’re the first),
* click "with microphone", allow your browser to access it, check the audio.
* Your microphone is muted if you join. Activate microphone and/or 
camera with the buttons at the bottom.

* Minimize the default presentation with the "screen" button, bottom right.

* If you’d like to share your screen or upload a file, you can make 
yourself the presenter: Click on your user name, change the setting, 
then you’ll see the "screen sharing" button beside the camera button; 
also there’s now "manage presentations" behind the "plus" button.
Beware there is only one presenter at a time, so don’t kill someone 
else’s presentation.


[Technical hints]
* Sound is usually better if you use a headset (less noise for everyone).
* Connection problems are mostly due to low bandwidth or high latency on 
your side, e.g. with mobile connections.

* Sometimes leaving and re-entering helps.
* If audio/video doesn’t work for you, you can still use the text chat.
* Screen sharing needs a lot of bandwidth.
* BigBlueButton documentation applies: 
https://bigbluebutton.org/teachers/tutorials/


[Netiquette]
* Please use a name that we recognize from here. Some feel uncomfortable 
with anonymous lurkers.

* Mute your microphone while you’re not talking.
* It’s nice to show your face at least when you join.
* If there are connection problems, stop camera sharing.
* The room is set to “everyone’s a moderator“, I trust you...
___
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: Bibliography: separating different kinds of literature OR Sectioning bibliography by type

2024-06-09 Thread Ben Moon via ntg-context
Dear Alan,
Thank you very much for your reply. Unfortunately, I don’t get this working. 
Also, I don’t find the documentation for flushbtxrendering.
Here’s a minimal working example I’m trying:

\startbtxrenderingdefinitions[mybib]

\definebtx
  [mybib]
  [default=default,
   specification=mybib]

\definebtxrendering
  [mybib]
  [specification=mybib,
   numbering=yes]

\stopbtxrenderingdefinitions

\startsetups btx:mybib:list:link
   \btxdoifelse {title} {\btxflush{title}:\space} {No Title}
   \btxdoifelse {url}  {\btxflush{url};\space} {}
   \btxdoifelse {date}  {abgerufen \btxflush{date}.} {}
  \removeunwantedspaces
\stopsetups

\startsetups btx:mybib:list:imagelink
   \btxdoifelse {url}  {\btxflush{url};\space} {}
   \btxdoifelse {date}  {abgerufen \btxflush{date}.} {}
  \removeunwantedspaces
\stopsetups


\startbuffer[maindata]
@link{herbariumathome,
title={Herbarium At Home: A Beginner's Guide},
url={https://youtu.be/2kEbCaTe8XM},
date={04.04.2024}},

@imagelink{zooniverse_logo,
url={https://www.sciencelearn.org.nz/images/3873-zooniverse-logo},
date={04.06.2024}}
\stopbuffer
% enable tracing
\enabletrackers[publications, publications.crossref, publications.details, 
publications.cite, publications.strings]

\definebtxdataset[main]
\usebtxdataset[main][maindata.buffer]
%\definebtxdataset[bilder]
%\usebtxdataset[bilder][imagedata.buffer]
\usebtxdefinitions[mybib, aps] % aps for stuff which isn’t a link or image
\setupbtx[dataset=main]
\definebtxrendering[bibrendering][mybib, aps][dataset=main]

\starttext
\cite[herbariumathome]
\cite[zooniverse_logo]

\section{Quellen: Bilder}
%\placelistofpublications[bibrendering]
\flushbtxrendering [bibrendering]
[method=dataset,
 sorttype=index,
 filter=match(category:imagelink)]

\section{Quellen: Webseiten}
\flushbtxrendering [bibrendering]
[method=dataset,
 sorttype=index,
 filter=match(category:link)]
\stoptext

I would very much appreciate more ideas.

Thank you very much and kind regards

Ben

> On 9 Jun 2024, at 14:37, Alan Braslau via ntg-context  
> wrote:
> 
> Try something like:
> 
>  \flushbtxrendering [bibrendering]
>   [method=dataset,
>sorttype=index,
>filter=match(category:article)]
> 
> I have used the filtering mechanism to select fields, such as 
> filter=match(year:2023).
> 
> Alan
> 
> 
> 
> 
> On Tue, 4 Jun 2024 15:20:14 +0200
> Ben Moon via ntg-context  wrote:
> 
>> Hey there,
>> I would like to place a list of bibliography according to types
>> (article, book, in proceedings) in my document. Similar like here:
>> https://tex.stackexchange.com/questions/112874/sectioning-bibliography-by-type-with-multiple-types-per-section
>> Sectioning bibliography by type (with multiple types per section)
>> tex.stackexchange.com
>> 
>> and here:
>> https://www.mail-archive.com/ntg-context@ntg.nl/msg77056.html
>> The example provided by Hans doesn’t seem to properly work any more,
>> and I cannot make the suggestion work of using two different datasets
>> work as suggested in the same thread. So this is where I’m stuck:
>> 
>> \definebtxdataset[main]
>> \usebtxdataset[main][maindata.buffer]
>> \definebtxdataset[images]
>> \usebtxdataset[images][imagedata.buffer]
>> \usebtxdefinitions[mycustom, aps]
>> \setupbtx[dataset=main]
>> \definebtxrendering[bibrendering][mycustom, aps][dataset=main]
>> \definebtxrendering[bibimgrendering][mycustom, aps][dataset=images]
>> 
>> \placelistofpublications[bibrendering]
>> \placelistofpublications[bibimgrendering]
>> 
>> It would be much appreciated if someone could provide a working
>> example?
>> 
>> Thank you very much
>> 
>> Ben
> 
> ___
> 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: Bibliography: separating different kinds of literature OR Sectioning bibliography by type

2024-06-09 Thread Alan Braslau via ntg-context
Try something like:

  \flushbtxrendering [bibrendering]
   [method=dataset,
sorttype=index,
filter=match(category:article)]

I have used the filtering mechanism to select fields, such as 
filter=match(year:2023).

Alan




On Tue, 4 Jun 2024 15:20:14 +0200
Ben Moon via ntg-context  wrote:

> Hey there,
> I would like to place a list of bibliography according to types
> (article, book, in proceedings) in my document. Similar like here:
> https://tex.stackexchange.com/questions/112874/sectioning-bibliography-by-type-with-multiple-types-per-section
> Sectioning bibliography by type (with multiple types per section)
> tex.stackexchange.com
> 
> and here:
> https://www.mail-archive.com/ntg-context@ntg.nl/msg77056.html
> The example provided by Hans doesn’t seem to properly work any more,
> and I cannot make the suggestion work of using two different datasets
> work as suggested in the same thread. So this is where I’m stuck:
> 
> \definebtxdataset[main]
> \usebtxdataset[main][maindata.buffer]
> \definebtxdataset[images]
> \usebtxdataset[images][imagedata.buffer]
> \usebtxdefinitions[mycustom, aps]
> \setupbtx[dataset=main]
> \definebtxrendering[bibrendering][mycustom, aps][dataset=main]
> \definebtxrendering[bibimgrendering][mycustom, aps][dataset=images]
> 
> \placelistofpublications[bibrendering]
> \placelistofpublications[bibimgrendering]
> 
> It would be much appreciated if someone could provide a working
> example?
> 
> Thank you very much
> 
> Ben

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