summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-06-12 20:15:14 +0000
committerKarl Berry <karl@freefriends.org>2023-06-12 20:15:14 +0000
commit53de1ded099dfae852b5bf342c9411ca566b0e00 (patch)
treeb475ce02b073686e0c5c62b88e1ebda5b945acd2 /Master/texmf-dist/source/latex/postnotes/postnotes.dtx
parent6340c1f1407b6c8a60d4d531ce456278f28ce0f3 (diff)
postnotes (12jun23)
git-svn-id: svn://tug.org/texlive/trunk@67345 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/postnotes/postnotes.dtx')
-rw-r--r--Master/texmf-dist/source/latex/postnotes/postnotes.dtx106
1 files changed, 77 insertions, 29 deletions
diff --git a/Master/texmf-dist/source/latex/postnotes/postnotes.dtx b/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
index edf129ed9c1..03a43914527 100644
--- a/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
+++ b/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
@@ -22,7 +22,7 @@
%
% This work consists of the files postnotes.dtx,
% postnotes.ins,
-% postnotes.tex,
+% postnotes-doc.tex,
% postnotes-code.tex,
% and the files generated from them.
%
@@ -153,7 +153,7 @@
%
%
% \begin{macrocode}
-\ProvidesExplPackage {postnotes} {2023-02-21} {0.2.3}
+\ProvidesExplPackage {postnotes} {2023-06-12} {0.2.4}
{Endnotes for LaTeX}
% \end{macrocode}
%
@@ -700,7 +700,7 @@
% offers a boolean to indicate when it is a measuring pass; \pkg{csquotes}
% offers further handles. But the standard \cs{caption} offers none, and
% neither does \pkg{amsmath}'s \cs{text} macro. Well, the pkg{caption}
-% package has can disable the multiple passes for \cs{caption} with the option
+% package can disable the multiple passes for \cs{caption} with the option
% \opt{singlelinecheck}, but it is not reasonable to require it for our
% purposes, so we must assume the worst case.
%
@@ -932,36 +932,50 @@
% conditional, obviously, will always return the true branch unless
% something is done in the \texttt{postnotes/note/inhibit} hook. This hook
% is meant to handle support for packages or features which may justify note
-% inhibition, and the code there should set \cs{l_@@_inhibit_note_bool} and
-% \cs{l_@@_print_plain_mark_bool} as appropriate to the case.
+% inhibition, and the code there should set \cs{l_@@_inhibit_note_bool},
+% \cs{l_@@_print_plain_mark_bool} and
+% \cs{l_@@_print_plain_mark_stepcounter_bool} as appropriate to the case.
% \begin{macrocode}
\bool_new:N \l_@@_inhibit_note_bool
\bool_new:N \l_@@_print_plain_mark_bool
+\bool_new:N \l_@@_print_plain_mark_stepcounter_bool
\NewHook { postnotes/note/inhibit }
\prg_new_protected_conditional:Npnn \@@_inhibit_note: { F }
{
\bool_set_false:N \l_@@_inhibit_note_bool
\bool_set_false:N \l_@@_print_plain_mark_bool
+ \bool_set_false:N \l_@@_print_plain_mark_stepcounter_bool
\UseHook { postnotes/note/inhibit }
% \end{macrocode}
% Printing a plain mark here may be needed because, if we are inhibiting the
% note in a ``measuring context'' and omit it completely, the measuring being
% performed will be off by the size of the mark. So, to ensure the measuring
-% can be done correctly, we place the mark. Since we'd only print this mark
-% in case of inhibition, when we don't actually step the counter, to typeset
-% correctly the mark that would be printed if the counter had been stepped, we
-% increment \cs{c@postnote} locally and grouped, and smuggle \cs{thepostnote}
-% out of the group.
+% can be done correctly, we place the mark. What to do with the counter
+% itself, depends on the situation. In places that are known to restore the
+% counter values after the measuring pass, we can let the counter be stepped.
+% And, actually we should do so, for example, in a \env{tabularx} with
+% multiple postnotes, if we don't step the counter, all the measuring will be
+% done with the number of the first note. Otherwise, we don't actually step
+% the counter but, to typeset correctly the mark that would be printed if the
+% counter had been stepped, we increment \cs{c@postnote} locally and grouped,
+% and smuggle \cs{thepostnote} out of the group.
% \begin{macrocode}
\bool_if:NT \l_@@_print_plain_mark_bool
{
\tl_if_empty:NT \l_@@_mark_tl
{
- \group_begin:
- \int_incr:N \c@postnote
- \exp_args:NNNx
- \group_end:
- \tl_set:Nn \l_@@_mark_tl { \thepostnote }
+ \bool_if:NTF \l_@@_print_plain_mark_stepcounter_bool
+ {
+ \stepcounter { postnote }
+ \tl_set:Nx \l_@@_mark_tl { \thepostnote }
+ }
+ {
+ \group_begin:
+ \int_incr:N \c@postnote
+ \exp_args:NNNx
+ \group_end:
+ \tl_set:Nn \l_@@_mark_tl { \thepostnote }
+ }
}
\@@_typeset_mark_wrapper:n
{ \@@_make_mark:nnn { \l_@@_mark_tl } { } { } }
@@ -2371,6 +2385,7 @@
{
\bool_set_true:N \l_@@_inhibit_note_bool
\bool_set_true:N \l_@@_print_plain_mark_bool
+ \bool_set_true:N \l_@@_print_plain_mark_stepcounter_bool
}
}
% \end{macrocode}
@@ -2414,6 +2429,7 @@
{
\bool_set_true:N \l_@@_inhibit_note_bool
\bool_set_true:N \l_@@_print_plain_mark_bool
+ \bool_set_true:N \l_@@_print_plain_mark_stepcounter_bool
}
}
}
@@ -2445,6 +2461,7 @@
{
\bool_set_true:N \l_@@_inhibit_note_bool
\bool_set_true:N \l_@@_print_plain_mark_bool
+ \bool_set_true:N \l_@@_print_plain_mark_stepcounter_bool
}
}
}
@@ -2453,24 +2470,55 @@
%
% \subsection*{\pkg{tabularray}}
%
-% I've tried, but I could not find any ``handle'' to distinguish in
-% \pkg{tabularray} a trial/measure pass from the final one. So we use
-% \cs{@@_verify_multipass:N} for it.
-%
-% See, however, \url{https://tex.stackexchange.com/q/675818} and
-% \url{https://github.com/lvjr/tabularray/issues/179} (thanks
-% \contributor{Ulrike Fischer}). In sum, there's a not yet released new
-% boolean \cs{lTblrMeasuringBool} provided by \pkg{tabularray}, use it when it
-% comes.
-%
% \begin{macrocode}
\AddToHook { package/tabularray/after }
{
- \clist_map_inline:nn
- { tblr , longtblr , talltblr , booktabs , longtabs , talltabs , +array }
+% \end{macrocode}
+% Since version \texttt{2023A}, from 2023-03-01, \pkg{tabularray} offers the
+% \cs{lTblrMeasuringBool} which is true when measuring and false otherwise.
+% See \url{https://tex.stackexchange.com/q/675818}
+% and \url{https://github.com/lvjr/tabularray/issues/179} (thanks
+% \contributor{Ulrike Fischer}).
+% \begin{macrocode}
+ \bool_if_exist:NTF \lTblrMeasuringBool
{
- \AddToHook { env/#1/begin } [ postnotes ]
- { \bool_set_true:N \l_@@_maybe_multi_bool }
+% \end{macrocode}
+% I'd be inclined to restrict the inhibition effect to known \pkg{tabularray}
+% environments to ``keep things under control''. However this is a dedicated
+% and public boolean, and users can create arbitrary new \pkg{tabularray}
+% environments with \cs{NewTblrEnviron}, which we either wouldn't catch or
+% have to provide an user interface for. So, for the time being, let's trust
+% this boolean won't be misused by third-parties or users. Note that setting
+% \cs{l_@@_print_plain_mark_stepcounter_bool} to true presumes
+% \pkg{tabularray}'s \texttt{counter} module is enabled. But, since this is
+% the only way to get the measuring right in this context if there is more
+% than one \cs{postnote} inside a given table, pkg{postnotes} expects and
+% requires the \texttt{counter} module.
+% \begin{macrocode}
+ \AddToHook { postnotes/note/inhibit } [ postnotes ]
+ {
+ \bool_if:NT \lTblrMeasuringBool
+ {
+ \bool_set_true:N \l_@@_inhibit_note_bool
+ \bool_set_true:N \l_@@_print_plain_mark_bool
+ \bool_set_true:N \l_@@_print_plain_mark_stepcounter_bool
+ }
+ }
+ }
+ {
+% \end{macrocode}
+% If the new boolean is not yet available, we use \cs{@@_verify_multipass:N}
+% to distinguish a trial/measure pass from the final one.
+% \begin{macrocode}
+ \clist_map_inline:nn
+ {
+ tblr , longtblr , talltblr , booktabs ,
+ longtabs , talltabs , +array
+ }
+ {
+ \AddToHook { env/#1/begin } [ postnotes ]
+ { \bool_set_true:N \l_@@_maybe_multi_bool }
+ }
}
}
% \end{macrocode}