ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] LUA API for page numbers
@ 2024-05-21  8:26 Luc Chabassier
  2024-05-21  9:45 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Chabassier @ 2024-05-21  8:26 UTC (permalink / raw)
  To: ntg-context

Hi everyone,

I have recently migrated my PhD dissertation from LaTeX to ConTeXt. In
LaTeX I was using kaobook, a template with lots of margin notes, but I
was frustrated with the automatic placement of the notes.

I implemented a system using overlays that automatically places the
notes using lua. To know where the ideal placement should be (if they do
not interact with each other), I use lua to insert a latelua whatsit
that uses lpdf.getpos() to get the coordinate on the rendered page.
However, I haven't found a way to get the page number using lua, and the
tex macro \pagenumber is unreliable near pagebreaks.

Furthermore, it would be helpful to know if there is a way to access the
position and sizes of figures at the end.

Thanks,
Luc

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21  8:26 [NTG-context] LUA API for page numbers Luc Chabassier
@ 2024-05-21  9:45 ` Hans Hagen
  2024-05-21 13:35   ` Luc Chabassier
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2024-05-21  9:45 UTC (permalink / raw)
  To: ntg-context

On 5/21/2024 10:26 AM, Luc Chabassier wrote:
> Hi everyone,
> 
> I have recently migrated my PhD dissertation from LaTeX to ConTeXt. In
> LaTeX I was using kaobook, a template with lots of margin notes, but I
> was frustrated with the automatic placement of the notes.
> 
> I implemented a system using overlays that automatically places the
> notes using lua. To know where the ideal placement should be (if they do
> not interact with each other), I use lua to insert a latelua whatsit
> that uses lpdf.getpos() to get the coordinate on the rendered page.
> However, I haven't found a way to get the page number using lua, and the
> tex macro \pagenumber is unreliable near pagebreaks.
> 
> Furthermore, it would be helpful to know if there is a way to access the
> position and sizes of figures at the end.
you have to provide some mwe so that we can see what is intended; in 
principle much info is available one way or the other

concerning notes in the margin ... did you try the built in magin text 
mechanisms?

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 / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21  9:45 ` [NTG-context] " Hans Hagen
@ 2024-05-21 13:35   ` Luc Chabassier
  2024-05-21 13:54     ` Wolfgang Schuster
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Chabassier @ 2024-05-21 13:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

Excerpts from Hans Hagen's message of May 21, 2024 11:45 am:
> you have to provide some mwe so that we can see what is intended; in 
> principle much info is available one way or the other
I joined a minimal working example. The lua function
`userdata.sidenotes_save_run` places the notes so that they do not
intersect (the method I actually use is more complicated, but the idea
is the same).

> concerning notes in the margin ... did you try the built in magin text 
> mechanisms?
I did, but as far as I know they place the text on the margin next to
the \inmargin invocation in the text, so they may overlap, which is what
I want to avoid.

Luc

[-- Attachment #2: main.tex --]
[-- Type: application/javascript, Size: 3258 bytes --]

[-- Attachment #3: Type: text/plain, Size: 511 bytes --]

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21 13:35   ` Luc Chabassier
@ 2024-05-21 13:54     ` Wolfgang Schuster
  2024-05-21 14:07       ` vm via ntg-context
                         ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wolfgang Schuster @ 2024-05-21 13:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Luc Chabassier

Luc Chabassier schrieb am 21.05.2024 um 15:35:
> Excerpts from Hans Hagen's message of May 21, 2024 11:45 am:
>> you have to provide some mwe so that we can see what is intended; in
>> principle much info is available one way or the other
> I joined a minimal working example. The lua function
> `userdata.sidenotes_save_run` places the notes so that they do not
> intersect (the method I actually use is more complicated, but the idea
> is the same).
> 
>> concerning notes in the margin ... did you try the built in magin text
>> mechanisms?
> I did, but as far as I know they place the text on the margin next to
> the \inmargin invocation in the text, so they may overlap, which is what
> I want to avoid.

\setupmarginblocks[inbetween=]

\starttext

\dorecurse{100}
   {\bold{#1:} \samplefile{ward}%
    \startmarginblock Note #1\stopmarginblock
    \par}

\stoptext

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21 13:54     ` Wolfgang Schuster
@ 2024-05-21 14:07       ` vm via ntg-context
  2024-05-21 14:30         ` Wolfgang Schuster
  2024-05-21 14:17       ` vm via ntg-context
  2024-05-21 14:39       ` Luc Chabassier
  2 siblings, 1 reply; 8+ messages in thread
From: vm via ntg-context @ 2024-05-21 14:07 UTC (permalink / raw)
  To: ntg-context; +Cc: vm



On 21/05/2024 15:54, Wolfgang Schuster wrote:
> \setupmarginblocks[inbetween=]
> 
> \starttext
> 
> \dorecurse{100}
>    {\bold{#1:} \samplefile{ward}%
>     \startmarginblock Note #1\stopmarginblock
>     \par}
> 
> \stoptext


when I compile this, i get per page with
\par 1..10 -> the notes 1..11
\par 11..20 -> the notes 12..21
\par 21..30 -> the notes 32..31

...

is this expected standard?

i'd expect \par and notes synced on page.
1..10 -> 1..10



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21 13:54     ` Wolfgang Schuster
  2024-05-21 14:07       ` vm via ntg-context
@ 2024-05-21 14:17       ` vm via ntg-context
  2024-05-21 14:39       ` Luc Chabassier
  2 siblings, 0 replies; 8+ messages in thread
From: vm via ntg-context @ 2024-05-21 14:17 UTC (permalink / raw)
  To: ntg-context; +Cc: vm

just noticed that if the notes need more margin space then are pages 
available by the text, they get lost. e.g. this mwe generates 10 pages 
with 100 par but only 80 notes will show up.


\setupmarginblocks[inbetween=]

\starttext

\dorecurse{100}
   {\bold{#1:} \samplefile{ward}%
    \startmarginblock {\bf #1} one two three four five six seven eight 
nine ten eleven twelve thirteen\stopmarginblock
    \par}

\stoptext


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21 14:07       ` vm via ntg-context
@ 2024-05-21 14:30         ` Wolfgang Schuster
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Schuster @ 2024-05-21 14:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users, vm via ntg-context

vm via ntg-context schrieb am 21.05.2024 um 16:07:
> 
> 
> On 21/05/2024 15:54, Wolfgang Schuster wrote:
>> \setupmarginblocks[inbetween=]
>>
>> \starttext
>>
>> \dorecurse{100}
>>    {\bold{#1:} \samplefile{ward}%
>>     \startmarginblock Note #1\stopmarginblock
>>     \par}
>>
>> \stoptext
> 
> 
> when I compile this, i get per page with
> \par 1..10 -> the notes 1..11
> \par 11..20 -> the notes 12..21
> \par 21..30 -> the notes 32..31
> 
> ...
> 
> is this expected standard?
> 
> i'd expect \par and notes synced on page.
> 1..10 -> 1..10

TeX was still on page 1 to collect text when it put note 11 into the 
buffer for the margin and the decision to make the break after block 10 
happened afterwards.

You can control page breaks to a certain degree with the \testpage 
command between paragraphs.

\starttext

\dorecurse{100}
   {\testpage[3]
    \bold{#1:} \samplefile{ward}%
    \startmarginblock Note #1\stopmarginblock
    \par}

\stoptext

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: LUA API for page numbers
  2024-05-21 13:54     ` Wolfgang Schuster
  2024-05-21 14:07       ` vm via ntg-context
  2024-05-21 14:17       ` vm via ntg-context
@ 2024-05-21 14:39       ` Luc Chabassier
  2 siblings, 0 replies; 8+ messages in thread
From: Luc Chabassier @ 2024-05-21 14:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Wolfgang Schuster

Excerpts from Wolfgang Schuster's message of May 21, 2024 3:54 pm:
> Luc Chabassier schrieb am 21.05.2024 um 15:35:
>> Excerpts from Hans Hagen's message of May 21, 2024 11:45 am:
>>> concerning notes in the margin ... did you try the built in magin text
>>> mechanisms?
>> I did, but as far as I know they place the text on the margin next to
>> the \inmargin invocation in the text, so they may overlap, which is what
>> I want to avoid.
> 
> \setupmarginblocks[inbetween=]
> 
> \starttext
> 
> \dorecurse{100}
>    {\bold{#1:} \samplefile{ward}%
>     \startmarginblock Note #1\stopmarginblock
>     \par}
> 
> \stoptext
I did not know about margin blocks, they are nice. But is there a way to
place them next to the \startmarginblock invocation, instead of flushing
them all either to the top or bottom of the page ?
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-21 14:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-21  8:26 [NTG-context] LUA API for page numbers Luc Chabassier
2024-05-21  9:45 ` [NTG-context] " Hans Hagen
2024-05-21 13:35   ` Luc Chabassier
2024-05-21 13:54     ` Wolfgang Schuster
2024-05-21 14:07       ` vm via ntg-context
2024-05-21 14:30         ` Wolfgang Schuster
2024-05-21 14:17       ` vm via ntg-context
2024-05-21 14:39       ` Luc Chabassier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).