ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Foonotes in Captions ... again
@ 2022-06-15 15:05 Denis Maier via ntg-context
  2022-06-15 23:31 ` Max Chernoff via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Maier via ntg-context @ 2022-06-15 15:05 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier


[-- Attachment #1.1: Type: text/plain, Size: 1112 bytes --]

Hi everyone

What's the current state of affairs regarding footnotes in floats? Both version in the example below don't quite work...
(Ideally, the note should be on the page with the float and the caption, but the numbering should also be adjusted.)

Best,
Denis

\starttext

\footnote{asdf} \footnote{asdf} \footnote{asdf}

\input ward

\startplacefigure[title={asdfasdf\footnote{test 1}}]
\externalfigure[cow.pdf]
\stopplacefigure

\footnote{asdf} \footnote{asdf} \footnote{asdf}

\startplacefigure[title={asdfasdf\footnote{test 2}}]
\externalfigure[cow.pdf][height=10cm]
\stopplacefigure

\footnote{asdf} \footnote{asdf} \footnote{asdf}


\page
\footnote{asdf} \footnote{asdf} \footnote{asdf}

\input ward

\startplacefigure[title={asdfasdf\footnote{test 1}}]
\externalfigure[cow.pdf]
\stopplacefigure

\footnote{asdf} \footnote{asdf} \footnote{asdf}

\startpostponingnotes
\startplacefigure[title={asdfasdf\footnote{test 2}}]
\externalfigure[cow.pdf][height=10cm]
\stopplacefigure
\stoppostponingnotes

\footnote{asdf} \footnote{asdf} \footnote{asdf}
\stoptext

[-- Attachment #1.2: Type: text/html, Size: 5281 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

* Re: Foonotes in Captions ... again
  2022-06-15 15:05 Foonotes in Captions ... again Denis Maier via ntg-context
@ 2022-06-15 23:31 ` Max Chernoff via ntg-context
  2022-06-16  9:15   ` Denis Maier via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Max Chernoff via ntg-context @ 2022-06-15 23:31 UTC (permalink / raw)
  To: ntg-context; +Cc: Max Chernoff

> What's the current state of affairs regarding footnotes in floats? Both version in the example below don't quite work...
> (Ideally, the note should be on the page with the float and the caption, but the numbering should also be adjusted.)

We can completely abuse a bunch of different ConTeXt features to ensure
that the footnote numbers are always in the page order.

     % New Code
     \unprotect

     \startluacode
         userdata.visual_order = 0
         userdata.input_order = 0
         userdata.save_data = job.passes.define("saved_footnotes")
         userdata.previous_data = job.passes.getcollected("saved_footnotes")

         interfaces.implement {
             name = "set_footnote_number",
             actions = function ()
                 userdata.input_order = userdata.input_order + 1

                 local input_index = userdata.input_order
                 local page_index = userdata.previous_data[input_index]

                 if page_index then
                     structures.counters.set("footnote", 1, page_index - 1)
                 end
             end
         }
     \stopluacode

     \def\save_footnote_data#1{%
         \latelua{
             userdata.visual_order = userdata.visual_order + 1
             userdata.save_data[#1] = userdata.visual_order
         }%
     }

     \let\old_footnote=\footnote

     \starttexdefinition protected footnote #1
         \begingroup
             \clf_set_footnote_number

             \def\insert##1\bgroup##2\egroup{
                 \normalexpanded{
                     \noexpand\save_footnote_data
                     {\cldcontext{userdata.input_order}}
                 }
                 \normalinsert##1{##2}
             }

             \old_footnote{#1}
         \endgroup
     \stoptexdefinition

     \protect

     % Original Example

     \starttext

     \footnote{asdf} \footnote{asdf} \footnote{asdf}

     \input ward

     \startplacefigure[title={asdfasdf\footnote{test 1}}]
     \externalfigure[cow.pdf]
     \stopplacefigure

     \footnote{asdf} \footnote{asdf} \footnote{asdf}

     \startplacefigure[title={asdfasdf\footnote{test 2}}]
     \externalfigure[cow.pdf][height=10cm]
     \stopplacefigure

     \footnote{asdf} \footnote{asdf} \footnote{asdf}


     \page
     \footnote{asdf} \footnote{asdf} \footnote{asdf}

     \input ward

     \startplacefigure[title={asdfasdf\footnote{test 1}}]
     \externalfigure[cow.pdf]
     \stopplacefigure

     \footnote{asdf} \footnote{asdf} \footnote{asdf}

     % (Can't use postponingnotes)
     % \startpostponingnotes
     \startplacefigure[title={asdfasdf\footnote{test 2}}]
     \externalfigure[cow.pdf][height=10cm]
     \stopplacefigure
     % \stoppostponingnotes

     \footnote{asdf} \footnote{asdf} \footnote{asdf}
     \stoptext

Here, we save a mapping between each footnote's index in the input and
its index in the output to the .tuc file. The code is definitely not
pretty, but works well enough for the sample file provided.

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

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

* Re: Foonotes in Captions ... again
  2022-06-15 23:31 ` Max Chernoff via ntg-context
@ 2022-06-16  9:15   ` Denis Maier via ntg-context
  2022-06-16 11:09     ` Denis Maier via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Maier via ntg-context @ 2022-06-16  9:15 UTC (permalink / raw)
  To: mseven, ntg-context; +Cc: denis.maier

Thanks, Max! That's very neat, and it indeed works in my use case.

Can anyone see any drawbacks here?

Best,
Denis

> -----Ursprüngliche Nachricht-----
> Von: Max Chernoff <mseven@telus.net>
> Gesendet: Donnerstag, 16. Juni 2022 01:32
> An: ntg-context@ntg.nl
> Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> Betreff: Re: [NTG-context] Foonotes in Captions ... again
> 
> > What's the current state of affairs regarding footnotes in floats? Both
> version in the example below don't quite work...
> > (Ideally, the note should be on the page with the float and the
> > caption, but the numbering should also be adjusted.)
> 
> We can completely abuse a bunch of different ConTeXt features to ensure
> that the footnote numbers are always in the page order.
> 
>      % New Code
>      \unprotect
> 
>      \startluacode
>          userdata.visual_order = 0
>          userdata.input_order = 0
>          userdata.save_data = job.passes.define("saved_footnotes")
>          userdata.previous_data = job.passes.getcollected("saved_footnotes")
> 
>          interfaces.implement {
>              name = "set_footnote_number",
>              actions = function ()
>                  userdata.input_order = userdata.input_order + 1
> 
>                  local input_index = userdata.input_order
>                  local page_index = userdata.previous_data[input_index]
> 
>                  if page_index then
>                      structures.counters.set("footnote", 1, page_index - 1)
>                  end
>              end
>          }
>      \stopluacode
> 
>      \def\save_footnote_data#1{%
>          \latelua{
>              userdata.visual_order = userdata.visual_order + 1
>              userdata.save_data[#1] = userdata.visual_order
>          }%
>      }
> 
>      \let\old_footnote=\footnote
> 
>      \starttexdefinition protected footnote #1
>          \begingroup
>              \clf_set_footnote_number
> 
>              \def\insert##1\bgroup##2\egroup{
>                  \normalexpanded{
>                      \noexpand\save_footnote_data
>                      {\cldcontext{userdata.input_order}}
>                  }
>                  \normalinsert##1{##2}
>              }
> 
>              \old_footnote{#1}
>          \endgroup
>      \stoptexdefinition
> 
>      \protect
> 
>      % Original Example
> 
>      \starttext
> 
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> 
>      \input ward
> 
>      \startplacefigure[title={asdfasdf\footnote{test 1}}]
>      \externalfigure[cow.pdf]
>      \stopplacefigure
> 
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> 
>      \startplacefigure[title={asdfasdf\footnote{test 2}}]
>      \externalfigure[cow.pdf][height=10cm]
>      \stopplacefigure
> 
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> 
> 
>      \page
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> 
>      \input ward
> 
>      \startplacefigure[title={asdfasdf\footnote{test 1}}]
>      \externalfigure[cow.pdf]
>      \stopplacefigure
> 
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> 
>      % (Can't use postponingnotes)
>      % \startpostponingnotes
>      \startplacefigure[title={asdfasdf\footnote{test 2}}]
>      \externalfigure[cow.pdf][height=10cm]
>      \stopplacefigure
>      % \stoppostponingnotes
> 
>      \footnote{asdf} \footnote{asdf} \footnote{asdf}
>      \stoptext
> 
> Here, we save a mapping between each footnote's index in the input and its
> index in the output to the .tuc file. The code is definitely not pretty, but
> works well enough for the sample file provided.
> 
> -- Max
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Foonotes in Captions ... again
  2022-06-16  9:15   ` Denis Maier via ntg-context
@ 2022-06-16 11:09     ` Denis Maier via ntg-context
  2022-06-16 18:56       ` Henning Hraban Ramm via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Maier via ntg-context @ 2022-06-16 11:09 UTC (permalink / raw)
  To: ntg-context, mseven; +Cc: denis.maier

Hmmm, I probably was to quick. Does not really work in my real document...

I'll try to solve the issue now by integrating the notes into the caption. Let's see if the authors accept it.

Anyway, maybe that would be a nice topic for the monthly context chat?

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Denis Maier
> via ntg-context
> Gesendet: Donnerstag, 16. Juni 2022 11:16
> An: mseven@telus.net; ntg-context@ntg.nl
> Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> Betreff: Re: [NTG-context] Foonotes in Captions ... again
> 
> Thanks, Max! That's very neat, and it indeed works in my use case.
> 
> Can anyone see any drawbacks here?
> 
> Best,
> Denis
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Max Chernoff <mseven@telus.net>
> > Gesendet: Donnerstag, 16. Juni 2022 01:32
> > An: ntg-context@ntg.nl
> > Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> > Betreff: Re: [NTG-context] Foonotes in Captions ... again
> >
> > > What's the current state of affairs regarding footnotes in floats?
> > > Both
> > version in the example below don't quite work...
> > > (Ideally, the note should be on the page with the float and the
> > > caption, but the numbering should also be adjusted.)
> >
> > We can completely abuse a bunch of different ConTeXt features to
> > ensure that the footnote numbers are always in the page order.
> >
> >      % New Code
> >      \unprotect
> >
> >      \startluacode
> >          userdata.visual_order = 0
> >          userdata.input_order = 0
> >          userdata.save_data = job.passes.define("saved_footnotes")
> >          userdata.previous_data =
> > job.passes.getcollected("saved_footnotes")
> >
> >          interfaces.implement {
> >              name = "set_footnote_number",
> >              actions = function ()
> >                  userdata.input_order = userdata.input_order + 1
> >
> >                  local input_index = userdata.input_order
> >                  local page_index =
> > userdata.previous_data[input_index]
> >
> >                  if page_index then
> >                      structures.counters.set("footnote", 1, page_index - 1)
> >                  end
> >              end
> >          }
> >      \stopluacode
> >
> >      \def\save_footnote_data#1{%
> >          \latelua{
> >              userdata.visual_order = userdata.visual_order + 1
> >              userdata.save_data[#1] = userdata.visual_order
> >          }%
> >      }
> >
> >      \let\old_footnote=\footnote
> >
> >      \starttexdefinition protected footnote #1
> >          \begingroup
> >              \clf_set_footnote_number
> >
> >              \def\insert##1\bgroup##2\egroup{
> >                  \normalexpanded{
> >                      \noexpand\save_footnote_data
> >                      {\cldcontext{userdata.input_order}}
> >                  }
> >                  \normalinsert##1{##2}
> >              }
> >
> >              \old_footnote{#1}
> >          \endgroup
> >      \stoptexdefinition
> >
> >      \protect
> >
> >      % Original Example
> >
> >      \starttext
> >
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >
> >      \input ward
> >
> >      \startplacefigure[title={asdfasdf\footnote{test 1}}]
> >      \externalfigure[cow.pdf]
> >      \stopplacefigure
> >
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >
> >      \startplacefigure[title={asdfasdf\footnote{test 2}}]
> >      \externalfigure[cow.pdf][height=10cm]
> >      \stopplacefigure
> >
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >
> >
> >      \page
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >
> >      \input ward
> >
> >      \startplacefigure[title={asdfasdf\footnote{test 1}}]
> >      \externalfigure[cow.pdf]
> >      \stopplacefigure
> >
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >
> >      % (Can't use postponingnotes)
> >      % \startpostponingnotes
> >      \startplacefigure[title={asdfasdf\footnote{test 2}}]
> >      \externalfigure[cow.pdf][height=10cm]
> >      \stopplacefigure
> >      % \stoppostponingnotes
> >
> >      \footnote{asdf} \footnote{asdf} \footnote{asdf}
> >      \stoptext
> >
> > Here, we save a mapping between each footnote's index in the input and
> > its index in the output to the .tuc file. The code is definitely not
> > pretty, but works well enough for the sample file provided.
> >
> > -- Max
> ______________________________________________________________
> _____________________
> 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
___________________________________________________________________________________

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

* Re: Foonotes in Captions ... again
  2022-06-16 11:09     ` Denis Maier via ntg-context
@ 2022-06-16 18:56       ` Henning Hraban Ramm via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-06-16 18:56 UTC (permalink / raw)
  To: ntg-context; +Cc: Henning Hraban Ramm

Am 16.06.22 um 13:09 schrieb Denis Maier via ntg-context:
> Hmmm, I probably was to quick. Does not really work in my real document...
> 
> I'll try to solve the issue now by integrating the notes into the caption. Let's see if the authors accept it.
> 
> Anyway, maybe that would be a nice topic for the monthly context chat?

I agree – local, floating or postponed footnotes are an interesting topic.

In MkIV we needed \automigrateinserts, but that’s unnecessary and a noop 
in LMTX.

In my book still footnotes (esp. in table floats) go missing, and I need 
to find a MWE.

In your example, I get repeated footnotes in a strange order after the 
postponed notes.


Next online meetup is on July 13th. but maybe we can resolve everything 
before that date ;)

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

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

end of thread, other threads:[~2022-06-16 18:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 15:05 Foonotes in Captions ... again Denis Maier via ntg-context
2022-06-15 23:31 ` Max Chernoff via ntg-context
2022-06-16  9:15   ` Denis Maier via ntg-context
2022-06-16 11:09     ` Denis Maier via ntg-context
2022-06-16 18:56       ` Henning Hraban Ramm via ntg-context

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).