texlive[73034] Master/texmf-dist: postnotes (4dec24)
commits+karl at tug.org
commits+karl at tug.org
Wed Dec 4 22:12:17 CET 2024
Revision: 73034
https://tug.org/svn/texlive?view=revision&revision=73034
Author: karl
Date: 2024-12-04 22:12:17 +0100 (Wed, 04 Dec 2024)
Log Message:
-----------
postnotes (4dec24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/postnotes/CHANGELOG.md
trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-code.pdf
trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.pdf
trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.tex
trunk/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
trunk/Master/texmf-dist/tex/latex/postnotes/postnotes.sty
Modified: trunk/Master/texmf-dist/doc/latex/postnotes/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/postnotes/CHANGELOG.md 2024-12-04 21:12:05 UTC (rev 73033)
+++ trunk/Master/texmf-dist/doc/latex/postnotes/CHANGELOG.md 2024-12-04 21:12:17 UTC (rev 73034)
@@ -1,7 +1,37 @@
# Changelog
-## [Unreleased](https://github.com/gusbrs/postnotes/compare/v0.4.2...HEAD)
+## [Unreleased](https://github.com/gusbrs/postnotes/compare/v0.5.0...HEAD)
+## [v0.5.0](https://github.com/gusbrs/postnotes/compare/v0.4.2...v0.5.0) (2024-12-03)
+
+### Changed
+- The support for running headers in `\printpostnotes`, which previously
+ generated its data by means of an internal cross-reference structure, has
+ migrated to use the generalized mark mechanism provided by the `ltmarks`
+ kernel module instead. This was a long due change, since `ltmarks` is *the*
+ right tool for the task, but unfortunately was not available when
+ `postnotes` was originally developed and released. In practice, we get
+ improved functionality replacing what was a complicated cross-reference
+ setup with a straightforward application of `ltmarks`. Very neat, if I may
+ say so. Hat tip to `ltmarks` devs.
+
+### Deprecated
+- The header support variables `\pnhdpagefirst`, `\pnhdpagelast`,
+ `\pnhdchapfirst`, `\pnhdchaplast`, `\pnhdsectfirst`, `\pnhdsectlast`,
+ `\pnhdnamefirst`, and `\pnhdnamelast` are deprecated in favor of the new
+ `ltmarks` based mark classes.
+ - For the sake of stability, the package still provides a "legacy" version
+ of these variables, set using `ltmarks` data. This is meant to provide
+ a window of opportunity for users to migrate to the new system smoothly,
+ but *migrate you must*, since *these variables will be removed in the
+ future*. Migrating should range somewhere between "very easy" and
+ "trivial", and intervention is only needed if you used any of these
+ variables to build custom headers. See the User manual for updated
+ examples.
+ - Also note that this "legacy version" of the variables require one more
+ compilation run to converge, so there's also a clear benefit for you to
+ adjust sooner rather than later.
+
## [v0.4.2](https://github.com/gusbrs/postnotes/compare/v0.4.1...v0.4.2) (2024-11-27)
### Fixed
Modified: trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-code.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.tex 2024-12-04 21:12:05 UTC (rev 73033)
+++ trunk/Master/texmf-dist/doc/latex/postnotes/postnotes-doc.tex 2024-12-04 21:12:17 UTC (rev 73034)
@@ -88,6 +88,7 @@
\IfBooleanTF ,
\IfNoValueTF ,
\tl_if_eq:NNTF ,
+ \tl_if_eq:eeTF ,
\tl_new:N ,
\tl_gset:Nv ,
\prop_new:N ,
@@ -101,6 +102,8 @@
\gappto ,
\extras ,
\captions ,
+ \FirstMark ,
+ \LastMark ,
}
}
\lstdefinestyle{postnotes}{
@@ -121,14 +124,6 @@
\pnthechapternextnote ,
\pnthesectionnextnote ,
\pnidnextnote ,
- \pnhdpagefirst ,
- \pnhdpagelast ,
- \pnhdchapfirst ,
- \pnhdchaplast ,
- \pnhdsectfirst ,
- \pnhdsectlast ,
- \pnhdnamefirst ,
- \pnhdnamelast ,
\mypnheader ,
\thepostnote ,
\demochapter ,
@@ -565,10 +560,9 @@
For the purposes of building running headers, each \cs{postnotesection} can be
identified by its \opt{name}. This is mainly intended to support unnumbered
headings, but its mechanism is general. The name of a note section is made
-available for the first and last note on a given page through the variables
-\cs{pnhdnamefirst} and \cs{pnhdnamelast} at the moment the header of the page
-is typeset. For details on how to use these variables, see
-\zcref{sec:headers}.
+available through the (lt)mark class \opt{postnotes/sectname}, for details on
+how to use it, see \zcref{sec:headers} and, in particular,
+\zcref{ex:hd:fancy}.
\DescribeOption{exp} %
By default, \cs{postnotesection} stores its \meta{text} argument with ``no
@@ -829,24 +823,45 @@
\label{sec:headers}
\pkg{postnotes}' support for running headers comprises a basic header, enabled
-by default, generating headers in the form ``Notes to pages N--M'', but also
-some infrastructure for users to build more elaborate ones.
+by default, generating headers in the form ``Notes to pages N--M'', but it is
+actually focused on generating mark data, using the \pkg{ltmarks} kernel
+module,\footnote{Note that ``mark'' in the context of \pkg{ltmarks} is a
+ completely different thing than what is usually meant in the context of an
+ end notes package. I won't try to invent terminology here, and hopefully
+ context is sufficient for the difference to be clear. But beware.} so that
+users can build their own headers, possibly more elaborate ones.
The default headers are generated by the function \cs{pnheaderdefault} which,
as we saw in \zcref{sec:section-options} is used to set the headers in option
\opt{heading} (with \cs{@mkboth}). So, the default headers are enabled
-through that particular setting.
+through that particular setting, depending on the page style in use.
-Examining the definition of \cs{pnheaderdefault} is possibly the most direct
-way to explore how the feature is meant to work.
+Examining a slightly simplified version of the definition of
+\cs{pnheaderdefault} is possibly the most direct way to explore how to use the
+mark data generated by the package.\footnote{The ``slight simplification'' is,
+ namely, that I'm using here a L3 \texttt{e}-type expansion for comparing the
+ equality between the marks, instead of expanding them with
+ \cs{protected at edef} before comparing them. The contents of the marks set by
+ \pkg{postnotes} are typically ``safe'' in the context of an \texttt{e}-type
+ expansion, but not necessarily so. You know them: \cs{thepage},
+ \cs{thechapter}, \cs{thesection}, etc. So I won't overburden the User
+ manual with this technical aspect. But if your marks may contain fragile
+ content, you'd need to expand them with \cs{protected at edef} before comparing
+ with \cs{tl_if_eq:NNTF} or equivalent, as \cs{pnheaderdefault} actually
+ does.}
\begin{pnsnippet}
\ExplSyntaxOn
\NewDocumentCommand \pnheaderdefault {}
{
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { \pnhdnotes{} ~ \pnhdtopage{} ~ \pnhdpagefirst }
- { \pnhdnotes{} ~ \pnhdtopages{} ~ \pnhdpagefirst -- \pnhdpagelast }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/page} }
+ { \LastMark{postnotes/page} }
+ { \pnhdnotes{}~\pnhdtopage{}~ \FirstMark{postnotes/page} }
+ {
+ \pnhdnotes{}~\pnhdtopages{}~
+ \FirstMark{postnotes/page}--\LastMark{postnotes/page}
+ }
}
\ExplSyntaxOff
\end{pnsnippet}
@@ -860,37 +875,40 @@
\ExplSyntaxOn
\NewDocumentCommand \pnheaderdefault {}
{
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { Notes~to~page~ \pnhdpagefirst }
- { Notes~to~pages~ \pnhdpagefirst -- \pnhdpagelast }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/page} }
+ { \LastMark{postnotes/page} }
+ { Notes~to~page~\FirstMark{postnotes/page} }
+ { Notes~to~pages~\FirstMark{postnotes/page}--\LastMark{postnotes/page} }
}
\ExplSyntaxOff
\end{pnsnippet}
-\DescribeMacro{\pnhdpagefirst} %
-\DescribeMacro{\pnhdpagelast} %
-\DescribeMacro{\pnhdchapfirst} %
-\DescribeMacro{\pnhdchaplast} %
-\DescribeMacro{\pnhdsectfirst} %
-\DescribeMacro{\pnhdsectlast} %
-\DescribeMacro{\pnhdnamefirst} %
-\DescribeMacro{\pnhdnamelast} %
-\cs{pnhdpagefirst} and \cs{pnhdpagelast} store the value of \cs{thepage} for
-the first and the last notes (where these notes were originally placed) of the
-current page (at the point they are being printed). These variables are
-updated every page along the span of \cs{printpostnotes} to the values
-corresponding to their respective first and last note (which start on that
-page), so that these values are available at the moment the headers get to be
-typeset. Hence, what the definition of \cs{pnheaderdefault} does is to use
-these variables to build a rule in the form: ``if the page of the first and
-last notes are equal, write a singular form and just one value but, if they
-are different, write a plural form and a range of both values''.
-\cs{pnhdchapfirst}, \cs{pnhdchaplast}, \cs{pnhdsectfirst}, and
-\cs{pnhdsectlast} provide the same for \cs{thechapter} and \cs{thesection}.
-\cs{pnhdnamefirst} and \cs{pnhdnamelast} contain the name of the notes
-section, the one given with the \opt{name} option of \cs{postnotesection} (and
-are empty in case no \opt{name} was provided).
+What the definition of \cs{pnheaderdefault} does is to build a rule in the
+form: ``if the page of the first and last notes are equal, write a singular
+form and just one value but, if they are different, write a plural form and a
+range of both values''. The data used for this purpose, retrieved there by
+the \cs{FirstMark}/\cs{LastMark} calls, is provided by some \pkg{ltmarks} mark
+classes set by \pkg{postnotes}.
+\DescribeOption{\normalfont\emph{Mark classes}} %
+\DescribeOption{postnotes/page} %
+\DescribeOption{postnotes/chapter} %
+\DescribeOption{postnotes/section} %
+\DescribeOption{postnotes/sectname} %
+These mark classes class keep track of the information of interest, and can be
+accessed through \pkg{ltmarks}' user interface: particularly, but not only,
+\cs{TopMark}, \cs{FirstMark}, and \cs{LastMark}. Now, \pkg{postnotes} inserts
+the marks when the notes are being printed, but the values being tracked are
+those from where the respective note marks were originally placed, since
+that's what interests us for a purpose of building running headers for
+\cs{printpostnotes}. As their names suggest, the \opt{postnotes/page},
+\opt{postnotes/chapter}, and \opt{postnotes/section} classes keep track of
+\cs{thepage}, \cs{thechapter}, and \cs{thesection}, respectively. The
+\opt{postnotes/sectname} class, in turn, tracks the name of the notes section,
+the one given with the \opt{name} option of \cs{postnotesection} (and is empty
+in case no \opt{name} was provided).
+
With that in hand, fancier headers can be built. For example, if we'd like
headers in the form ``Notes to chapters A--C, pages N--M'', we could define:
\begin{pnsnippet}
@@ -897,12 +915,19 @@
\ExplSyntaxOn
\NewDocumentCommand \mypnheader {}
{
- \tl_if_eq:NNTF \pnhdchapfirst \pnhdchaplast
- { Notes~to~chapter~\pnhdchapfirst,~ }
- { Notes~to~chapters~\pnhdchapfirst -- \pnhdchaplast,~ }
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { page~\pnhdpagefirst }
- { pages~\pnhdpagefirst -- \pnhdpagelast }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/chapter} }
+ { \LastMark{postnotes/chapter} }
+ { Notes~to~chapter~\FirstMark{postnotes/chapter},~ }
+ {
+ Notes~to~chapters~
+ \FirstMark{postnotes/chapter}--\LastMark{postnotes/chapter},~
+ }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/page} }
+ { \LastMark{postnotes/page} }
+ { page~\FirstMark{postnotes/page} }
+ { pages~\FirstMark{postnotes/page}--\LastMark{postnotes/page} }
}
\ExplSyntaxOff
\end{pnsnippet}
@@ -911,7 +936,7 @@
chapters (containing notes) are numbered, but if unnumbered ones come into
play, again we can fine-tune the automation, adjusting for the exception.
That's the purpose of the \opt{name} option for \cs{postnotesection}, and of
-\cs{pnhdnamefirst} and \cs{pnhdnamelast}. \zcref{ex:hd:fancy} illustrates
+the \opt{postnotes/sectname} mark class. \zcref{ex:hd:fancy} illustrates
their use (of course, the use of \pkg{lipsum} is just for demonstration):
\begin{pnexample}[caption={Fancy headers},label={ex:hd:fancy}]
@@ -933,24 +958,31 @@
\bool_case:nF
{
{
- \str_if_eq_p:ee { \pnhdnamefirst } { intro } &&
- \str_if_eq_p:ee { \pnhdnamelast } { intro }
+ \str_if_eq_p:ee { \FirstMark{postnotes/sectname} } { intro } &&
+ \str_if_eq_p:ee { \LastMark{postnotes/sectname} } { intro }
}
{ Notes~to~the~introduction,~ }
{
- \str_if_eq_p:ee { \pnhdnamefirst } { intro } &&
- ! \str_if_eq_p:ee { \pnhdnamelast } { intro }
+ \str_if_eq_p:ee { \FirstMark{postnotes/sectname} } { intro } &&
+ ! \str_if_eq_p:ee { \LastMark{postnotes/sectname} } { intro }
}
- { Notes~to~the~introduction~and~chapter~\pnhdchaplast{},~ }
+ { Notes~to~the~introduction~and~chapter~\LastMark{postnotes/chapter},~ }
}
{
- \tl_if_eq:NNTF \pnhdchapfirst \pnhdchaplast
- { Notes~to~chapter~\pnhdchapfirst{},~ }
- { Notes~to~chapters~\pnhdchapfirst{} -- \pnhdchaplast{},~ }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/chapter} }
+ { \LastMark{postnotes/chapter} }
+ { Notes~to~chapter~\FirstMark{postnotes/chapter},~ }
+ {
+ Notes~to~chapters~
+ \FirstMark{postnotes/chapter}--\LastMark{postnotes/chapter},~
+ }
}
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { page~\pnhdpagefirst{} }
- { pages~\pnhdpagefirst{} -- \pnhdpagelast{} }
+ \tl_if_eq:eeTF
+ { \FirstMark{postnotes/page} }
+ { \LastMark{postnotes/page} }
+ { page~\FirstMark{postnotes/page} }
+ { pages~\FirstMark{postnotes/page}--\LastMark{postnotes/page} }
}
\ExplSyntaxOff
\usepackage{hyperref}
@@ -972,7 +1004,19 @@
\end{document}
\end{pnexample}
+Note that there's absolutely no ``prescriptive'' aspect in this particular way
+of setting the headers used in the examples above, by means of these functions
+then used as content for \cs{markboth} or similar. This is just a way to do
+things which is mostly independent of the document class in use and of the
+presence of other related packages. Indeed, if you just set the \opt{heading}
+option removing call to \cs{@mkboth}, or simply use a page style which
+disables it, \pkg{postnotes} is completely ``hands-off'' in this area. The
+main effort of the package is to generate the data, by setting appropriate
+\texttt{ltmarks}, so that it is available. How to use this data is the
+business of the user. The facilities of your favorite document class, or
+\pkg{fancyhdr}, may well be be better options than this simple minded setup.
+
\section{Cross-references}
\label{sec:cross-references}
Modified: trunk/Master/texmf-dist/source/latex/postnotes/postnotes.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/postnotes/postnotes.dtx 2024-12-04 21:12:05 UTC (rev 73033)
+++ trunk/Master/texmf-dist/source/latex/postnotes/postnotes.dtx 2024-12-04 21:12:17 UTC (rev 73034)
@@ -153,7 +153,7 @@
%
%
% \begin{macrocode}
-\ProvidesExplPackage {postnotes} {2024-11-27} {0.4.2}
+\ProvidesExplPackage {postnotes} {2024-12-03} {0.5.0}
{Endnotes for LaTeX}
% \end{macrocode}
%
@@ -334,15 +334,7 @@
\bool_new:N \g_@@_firstrun_bool
\bool_gset_true:N \g_@@_firstrun_bool
\cs_new_protected:Npn \@@_store_labelseq:nn #1#2
- {
- \bool_lazy_any:nT
- {
- { \str_if_eq_p:nn {#1} { mark } }
- { \str_if_eq_p:nn {#1} { section } }
- { \str_if_eq_p:nn {#1} { preprint } }
- }
- { \seq_gput_right:Nn \g_@@_labelseq_seq { {#1} {#2} } }
- }
+ { \seq_gput_right:Nn \g_@@_labelseq_seq { {#1} {#2} } }
\cs_new_protected:Npn \@@_step_counteraux:nnn #1#2#3
{
\bool_lazy_and:nnT
@@ -419,9 +411,7 @@
% \@@_set_label:nnnn ,
% \@@_set_mark_page_label:nn ,
% \@@_set_section_page_label:n ,
-% \@@_set_text_page_label:n ,
-% \@@_set_print_page_label:n ,
-% \@@_set_pre_print_label:n ,
+% \@@_set_print_label:n ,
% \c_@@_page_counter_tl ,
% }
% Label setting functions for each pertinent context. They must use
@@ -432,9 +422,7 @@
% ~~\Arg{counteraux step}
% \cs{@@_set_mark_page_label:nn} \Arg{note id} \Arg{counteraux step}
% \cs{@@_set_section_page_label:n} \Arg{note id}
-% \cs{@@_set_text_page_label:n} \Arg{note id}
-% \cs{@@_set_print_page_label:n} \Arg{note id}
-% \cs{@@_set_pre_print_label:n} \Arg{note id}
+% \cs{@@_set_print_label:n} \Arg{note id}
% \end{syntax}
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_label:nnnn #1#2#3#4
@@ -441,12 +429,10 @@
{
\legacy_if:nT { @filesw }
{
- \protected at write \@auxout
- { \cs_set_eq:NN \c_@@_page_counter_tl \scan_stop: }
+ \protected at write \@auxout { }
{ \token_to_str:N \post at note { #1 } { #2 } { #3 } { #4 } }
}
}
-\tl_const:Nn \c_@@_page_counter_tl { \int_use:N \c at page }
\cs_new_protected:Npn \@@_set_mark_page_label:nn #1#2
{ \@@_set_label:nnnn { mark } { #1 } { \thepage } { #2 } }
\cs_generate_variant:Nn \@@_set_mark_page_label:nn { ee }
@@ -453,15 +439,9 @@
\cs_new_protected:Npn \@@_set_section_page_label:n #1
{ \@@_set_label:nnnn { section } { #1 } { \thepage } { } }
\cs_generate_variant:Nn \@@_set_section_page_label:n { e }
-\cs_new_protected:Npn \@@_set_text_page_label:n #1
- { \@@_set_label:nnnn { text } { #1 } { \c_@@_page_counter_tl } { } }
-\cs_generate_variant:Nn \@@_set_text_page_label:n { e }
-\cs_new_protected:Npn \@@_set_print_page_label:n #1
- { \@@_set_label:nnnn { print } { #1 } { \c_@@_page_counter_tl } { } }
-\cs_generate_variant:Nn \@@_set_print_page_label:n { e }
-\cs_new_protected:Npn \@@_set_pre_print_label:n #1
- { \@@_set_label:nnnn { preprint } { #1 } { } { } }
-\cs_generate_variant:Nn \@@_set_pre_print_label:n { e }
+\cs_new_protected:Npn \@@_set_print_label:n #1
+ { \@@_set_label:nnnn { print } { #1 } { } { } }
+\cs_generate_variant:Nn \@@_set_print_label:n { e }
% \end{macrocode}
% \end{macro}
%
@@ -528,7 +508,31 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[int]{\pnheaderdefault}
+% A basic header function to be used as default in the \opt{heading} option.
+% It produces a header in the form ``Notes to pages N--M'', with a text
+% which can be localized (see Section~\ref{sec:languages}).
+% \begin{syntax}
+% \cs{pnheaderdefault}
+% \end{syntax}
+% \begin{macrocode}
+\NewDocumentCommand \pnheaderdefault {}
+ {
+ \group_begin:
+ \protected at edef \l_@@_tmpa_tl { \FirstMark{postnotes/page} }
+ \protected at edef \l_@@_tmpb_tl { \LastMark{postnotes/page} }
+ \tl_if_eq:NNTF \l_@@_tmpa_tl \l_@@_tmpb_tl
+ { \pnhdnotes{}~\pnhdtopage{}~ \FirstMark{postnotes/page} }
+ {
+ \pnhdnotes{}~\pnhdtopages{}~
+ \FirstMark{postnotes/page}--\LastMark{postnotes/page}
+ }
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
%
+%
% \subsection*{\opt{format} option}
%
% \begin{macrocode}
@@ -1229,6 +1233,7 @@
% \end{syntax}
% \begin{macrocode}
\NewHook { postnotes/note/begin }
+\NewHook { postnotes/note/setlabels }
\cs_new_protected:Npn \@@_note:nn #1#2
{
\group_begin:
@@ -1278,6 +1283,7 @@
}
\tl_set:Nn \l_@@_note_set_labels_tl
{
+ \UseHook { postnotes/note/setlabels }
\MakeLinkTarget* { postnote. \l_postnotes_note_id_tl .mark }
\@@_set_mark_page_label:ee { \l_postnotes_note_id_tl }
{ \int_use:N \l_@@_counteraux_step_int }
@@ -1697,6 +1703,10 @@
% \l_@@_print_type_next_tl ,
% \l_@@_print_type_prev_tl ,
% \l_@@_print_content_tl ,
+% \l_@@_print_page_tl ,
+% \l_@@_print_chapter_tl ,
+% \l_@@_print_section_tl ,
+% \l_@@_print_sectname_tl ,
% \l_@@_clear_queue_seq ,
% }
% Auxiliary variables for \cs{@@_print_notes:}.
@@ -1712,12 +1722,26 @@
\tl_new:N \l_@@_print_type_next_tl
\tl_new:N \l_@@_print_type_prev_tl
\tl_new:N \l_@@_print_content_tl
+\tl_new:N \l_@@_print_page_tl
+\tl_new:N \l_@@_print_chapter_tl
+\tl_new:N \l_@@_print_section_tl
+\tl_new:N \l_@@_print_sectname_tl
\seq_new:N \l_@@_clear_queue_seq
% \end{macrocode}
% \end{macro}
%
%
-% \cs{@@_print_notes:}' hooks. Both meant at providing points of entry for
+% \pkg{ltmarks} mark classes for running header support data.
+%
+% \begin{macrocode}
+\mark_new_class:n { postnotes/page }
+\mark_new_class:n { postnotes/chapter }
+\mark_new_class:n { postnotes/section }
+\mark_new_class:n { postnotes/sectname }
+% \end{macrocode}
+%
+%
+% \cs{@@_print_notes:}' hooks. Meant to provide points of entry for
% additional setup, specially to add support to packages and features which
% require it. The \texttt{postnotes/print/begin} hook is run early in
% \cs{@@_print_notes:} and only once per call, after the user options have
@@ -1729,6 +1753,8 @@
% \begin{macrocode}
\NewHook { postnotes/print/begin }
\NewHook { postnotes/print/note/begin }
+\NewHook { postnotes/print/note/typesetmark }
+\NewHook { postnotes/print/note/ltmarks }
% \end{macrocode}
%
%
@@ -1796,13 +1822,9 @@
% \end{macrocode}
% The purpose of this label is to provide a point for splitting the labelseq
% with the \opt{counteraux} option. It only needs to exist, it doesn't even
-% store the page value. The \cs{@@_set_print_page_label:e} done at
-% \cs{@@_set_headers_vars_first:} right below does not suffice for this
-% purpose for two reasons. It won't be set if the queue is empty (or not yet
-% populated), and also it comes after the heading (as it must), which means
-% \cs{postnotesection}s added through hooks to it will come before it.
+% store the page value.
% \begin{macrocode}
- \@@_set_pre_print_label:e
+ \@@_set_print_label:e
{ \int_use:N \g_@@_print_postnotes_int }
\seq_if_empty:NTF \g_@@_print_queue_seq
{ \msg_warning:nn { postnotes } { empty-printpostnotes } }
@@ -1814,7 +1836,6 @@
\@@_sort_queue:N \g_@@_print_queue_seq
\@@_check_floats:N \g_@@_print_queue_seq
\bool_gset_true:N \g_@@_header_vars_next_bool
- \@@_get_headers_data:N \g_@@_print_queue_seq
\@@_set_headers_vars_first:
% \end{macrocode}
% Ensure the first note after a heading has paragraph indentation when
@@ -1907,8 +1928,15 @@
}
\group_begin:
\UseHook { postnotes/print/note/begin }
- \@@_get_pageref:Ne \pnthepage
+ \@@_get_pageref:Ne \l_@@_print_page_tl
{ mark@ \l_postnotes_print_note_id_tl }
+ \@@_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { thechapter } \l_@@_print_chapter_tl
+ \@@_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { thesection } \l_@@_print_section_tl
+ \@@_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { pnsectname } \l_@@_print_sectname_tl
+ \tl_set_eq:NN \pnthepage \l_@@_print_page_tl
\@@_prop_get:nnN
{ \l_postnotes_print_note_id_tl }
{ mark } \l_@@_print_mark_tl
@@ -1926,10 +1954,9 @@
\tl_set:Nn \l_@@_print_typeset_mark_tl
{
\tag_socket_use:n { postnotes/printmark/begin }
+ \UseHook { postnotes/print/note/typesetmark }
\MakeLinkTarget*
{ postnote. \l_postnotes_print_note_id_tl .text }
- \@@_set_text_page_label:e
- { \l_postnotes_print_note_id_tl }
\l_@@_pre_textmark_tl
\@@_typeset_text_mark:eV
{ \l_postnotes_print_note_id_tl }
@@ -1963,6 +1990,25 @@
\tag_socket_use:n { postnotes/printnote/begin }
\l_@@_print_typeset_mark_tl
}
+% \end{macrocode}
+% In principle, inserting the \pkg{ltmarks} marks would be best done at
+% \cs{l_@@_print_typeset_mark_tl}, immediately \emph{before} the mark,
+% alongside the anchor. However, \cs{mark_insert:nn} is documented not to
+% work inside a box (see \url{https://tex.stackexchange.com/a/732007}) and the
+% \cs{item}'s label is typeset as a box, so that's not an option. Before the
+% \cs{item} is also not a good idea. As long as the mark is no longer than a
+% line, which is arguably to be expected, there shouldn't be any difference
+% though. Either way, I don't see any other placement options.
+% \begin{macrocode}
+ \UseHook { postnotes/print/note/ltmarks }
+ \mark_insert:nn { postnotes/page }
+ { \l_@@_print_page_tl }
+ \mark_insert:nn { postnotes/chapter }
+ { \l_@@_print_chapter_tl }
+ \mark_insert:nn { postnotes/section }
+ { \l_@@_print_section_tl }
+ \mark_insert:nn { postnotes/sectname }
+ { \l_@@_print_sectname_tl }
\tag_socket_use:n { postnotes/printtext/begin }
\l_@@_print_content_tl
\tag_socket_use:n { postnotes/printtext/end }
@@ -2048,10 +2094,10 @@
% Furthermore, the purpose of \cs{g_@@_labelseq_seq} is different in each
% case. With \opt{counteraux} it is used to build the actual print queue,
% while in the standard case it is only used in \cs{@@_check_floats:N}.
-% Therefore, with \opt{counteraux} the cut is made at the place the preprint
-% label for the current \cs{printpostnotes} is found, while in the standard
-% case, \cs{g_@@_note_id_int} is used directly to distribute the elements
-% between the current \cs{printpostnotes} and future ones.
+% Therefore, with \opt{counteraux} the cut is made at the place the
+% \texttt{print} label for the current \cs{printpostnotes} is found, while in
+% the standard case, \cs{g_@@_note_id_int} is used directly to distribute the
+% elements between the current \cs{printpostnotes} and future ones.
%
%
% \begin{macro}{\@@_split_labelseq:}
@@ -2065,13 +2111,13 @@
\bool_if:NTF \g_@@_counteraux_bool
{
\tl_set:Ne \l_@@_tmpa_tl
- { { preprint } { \int_use:N \g_@@_print_postnotes_int } }
+ { { print } { \int_use:N \g_@@_print_postnotes_int } }
% \end{macrocode}
-% The preprint label of a \cs{printpostnotes} at the end of the document may
-% not have been written: if it's empty, it may not be shipped out at all.
+% The \texttt{print} label of a \cs{printpostnotes} at the end of the document
+% may not have been written: if it's empty, it may not be shipped out at all.
% But, since it's a counter, stepped sequentially and not floating, even if it
% is transitorily missing, it will be at the end. In other words, if this one
-% is not found, there will be no subsequent preprints in the sequence.
+% is not found, there will be no subsequent \texttt{print}s in the sequence.
% \begin{macrocode}
\seq_if_in:NVF \g_@@_labelseq_seq \l_@@_tmpa_tl
{ \seq_gput_right:NV \g_@@_labelseq_seq \l_@@_tmpa_tl }
@@ -2113,10 +2159,10 @@
}
% \end{macrocode}
% No need for the \texttt{F} branch of \cs{str_case:enT}, at this point the
-% preprint of past \cs{printpostnotes} can no longer be here, and we don't go
-% further than the current one. In theory, we could even go without
-% \cs{str_case:enT}, but let's play safe and keep the function robust against
-% future changes of the code.
+% \texttt{print} label of past \cs{printpostnotes} can no longer be here, and
+% we don't go further than the current one. In theory, we could even go
+% without \cs{str_case:enT}, but let's play safe and keep the function robust
+% against future changes of the code.
% \begin{macrocode}
}
\seq_gset_eq:NN \g_@@_print_labelseq_queue_seq
@@ -2147,8 +2193,8 @@
}
% \end{macrocode}
% Also no need for the \texttt{F} branch here, but for a different reason.
-% The preprint label plays no role whatsoever if \opt{couteraux=false}, so we
-% just drop them altogether if found.
+% The \texttt{print} label plays no role whatsoever if \opt{couteraux=false},
+% so we just drop them altogether if found.
% \begin{macrocode}
}
\seq_gset_eq:NN \g_@@_print_labelseq_queue_seq
@@ -2358,68 +2404,15 @@
%
% \section{Headers}
%
-% The headers infrastructure of \pkg{postnotes} is comprised of three basic
-% parts:
+% NOTE The use of these variables has been deprecated in 2024-12-03 for v0.5.0.
+% The setting of values for them, now based on \pkg{ltmarks} data, is still
+% transitionally provided so that users have time to adjust to the new
+% mechanism without immediate breakage of existing documents. These variables
+% are scheduled to be removed though, and users \emph{must} migrate. Not only
+% that, these values have been less intensively tested, and also require one
+% compilation run more to converge. So there's also a clear benefit in
+% migrating sooner rather than later.
%
-% \begin{enumerate}
-% \item For each \cs{postnote}, labels are set storing the \texttt{page} where
-% the note occurs. Each note actually generates a pair of such labels, once
-% when \cs{postnote} is called (with the mark), and another where the note
-% is printed (in \cs{printpostnotes}). The former ones store \cs{thepage},
-% since we want the printed representation of it for typesetting purposes,
-% the latter ones store the value of the \texttt{page} counter, since we
-% don't need to typeset it, but do need to perform algebraic operations with
-% it. These labels are set by \cs{@@_set_mark_page_label:nn},
-% \cs{@@_set_text_page_label:n}, and \cs{@@_set_print_page_label:n} at the
-% appropriate places. The set of these labels provides a mapping from each
-% note's ``mark'' and ``text'' to the page where it occurs.
-% \item This information set is processed by \cs{@@_get_headers_data:N} at the
-% beginning of \cs{@@_print_notes:} to identify the first and last note of
-% each page in \cs{printpostnotes}, and to generate a mapping from these
-% first and last notes on each page to the pages where their corresponding
-% marks occur. We also take the opportunity to enrich this mapping with
-% other metadata of each note. So we get also mappings from the first and
-% last note on each page to \cs{thechapter}, \cs{thesection}, and the
-% \opt{name} of the section in which they occur. These mappings are stored
-% in property lists \cs[no-index]{g_@@_header_\meta{info}_first_prop} and
-% \cs[no-index]{g_@@_header_\meta{info}_last_prop} where the \texttt{key} is
-% the page in \cs{printpostnotes} where their note's content is typeset (or
-% rather where it starts to be typeset, it is the page where the text's mark
-% is printed).
-% \item Based on these mappings, along the span of notes section we run
-% \cs{@@_set_headers_vars_next:} at each \texttt{shipout/before} hook to set
-% user facing variables for the \emph{next} page, which will be available
-% when their heading gets typeset. Given that at \texttt{shipout} we can
-% rely on a correct value of the \texttt{page} counter, we use it as
-% \texttt{key} to query the property lists generated in the previous step.
-% These user facing variables are called \cs[no-index]{pnhd\meta{info}first}
-% and \cs[no-index]{pnhd\meta{info}last}. Since we cannot rely on the
-% shipout hook for the first page of \cs{printpostnotes},
-% \cs{@@_set_headers_vars_first:} is run at its beginning to ensure correct
-% values are in place on the first page of the notes section.
-% \end{enumerate}
-%
-% These \cs[no-index]{pnhd\meta{info}first} and
-% \cs[no-index]{pnhd\meta{info}last} variables can then be used to build
-% simple functions which can be passed to mark commands to achieve rich
-% contextual running headers.
-%
-%
-% \begin{macro}[int]
-% {
-% \pnhdpagefirst ,
-% \pnhdpagelast ,
-% \pnhdchapfirst ,
-% \pnhdchaplast ,
-% \pnhdsectfirst ,
-% \pnhdsectlast ,
-% \pnhdnamefirst ,
-% \pnhdnamelast ,
-% }
-% User facing variables, aimed at making available header data for the user.
-% Setting these variables with correct values at the moment the header gets
-% typeset is \emph{the} objective of the whole headers infrastructure of the
-% package.
% \begin{macrocode}
\tl_new:N \pnhdpagefirst
\tl_new:N \pnhdpagelast
@@ -2430,346 +2423,96 @@
\tl_new:N \pnhdnamefirst
\tl_new:N \pnhdnamelast
% \end{macrocode}
-% \end{macro}
%
-%
-% \begin{macro}
-% {
-% \g_@@_header_page_first_prop ,
-% \g_@@_header_page_last_prop ,
-% \g_@@_header_chap_first_prop ,
-% \g_@@_header_chap_last_prop ,
-% \g_@@_header_sect_first_prop ,
-% \g_@@_header_sect_last_prop ,
-% \g_@@_header_name_first_prop ,
-% \g_@@_header_name_last_prop ,
-% \g_@@_header_prev_last_page_tl ,
-% \g_@@_header_prev_last_chap_tl ,
-% \g_@@_header_prev_last_sect_tl ,
-% \g_@@_header_prev_last_name_tl ,
-% \l_@@_prev_text_page_tl ,
-% \l_@@_curr_text_page_tl ,
-% \l_@@_prev_mark_page_tl ,
-% \l_@@_prev_mark_chap_tl ,
-% \l_@@_prev_mark_sect_tl ,
-% \l_@@_prev_mark_name_tl ,
-% }
-% Auxiliary variables for the headers infrastructure.
% \begin{macrocode}
-\prop_new:N \g_@@_header_page_first_prop
-\prop_new:N \g_@@_header_page_last_prop
-\prop_new:N \g_@@_header_chap_first_prop
-\prop_new:N \g_@@_header_chap_last_prop
-\prop_new:N \g_@@_header_sect_first_prop
-\prop_new:N \g_@@_header_sect_last_prop
-\prop_new:N \g_@@_header_name_first_prop
-\prop_new:N \g_@@_header_name_last_prop
-\tl_new:N \g_@@_header_prev_last_page_tl
-\tl_new:N \g_@@_header_prev_last_chap_tl
-\tl_new:N \g_@@_header_prev_last_sect_tl
-\tl_new:N \g_@@_header_prev_last_name_tl
-\tl_new:N \l_@@_prev_text_page_tl
-\tl_new:N \l_@@_curr_text_page_tl
-\tl_new:N \l_@@_prev_mark_page_tl
-\tl_new:N \l_@@_prev_mark_chap_tl
-\tl_new:N \l_@@_prev_mark_sect_tl
-\tl_new:N \l_@@_prev_mark_name_tl
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\@@_get_headers_data:N}
-% Process header data for \cs{@@_set_headers_vars:n}.
-% \begin{syntax}
-% \cs{@@_get_headers_data:N} \meta{\cs{g_@@_print_queue_seq}}
-% \end{syntax}
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_get_headers_data:N #1
+\cs_new_protected:Npn \@@_set_headers_vars:n #1
{
\group_begin:
- \tl_gclear:N \pnhdpagefirst
- \tl_gclear:N \pnhdpagelast
- \tl_gclear:N \pnhdchapfirst
- \tl_gclear:N \pnhdchaplast
- \tl_gclear:N \pnhdsectfirst
- \tl_gclear:N \pnhdsectlast
- \tl_gclear:N \pnhdnamefirst
- \tl_gclear:N \pnhdnamelast
- \prop_gclear:N \g_@@_header_page_first_prop
- \prop_gclear:N \g_@@_header_page_last_prop
- \prop_gclear:N \g_@@_header_chap_first_prop
- \prop_gclear:N \g_@@_header_chap_last_prop
- \prop_gclear:N \g_@@_header_sect_first_prop
- \prop_gclear:N \g_@@_header_sect_last_prop
- \prop_gclear:N \g_@@_header_name_first_prop
- \prop_gclear:N \g_@@_header_name_last_prop
- \tl_gclear:N \g_@@_header_prev_last_page_tl
- \tl_gclear:N \g_@@_header_prev_last_chap_tl
- \tl_gclear:N \g_@@_header_prev_last_sect_tl
- \tl_gclear:N \g_@@_header_prev_last_name_tl
- \tl_clear:N \l_@@_prev_text_page_tl
- \tl_clear:N \l_@@_curr_text_page_tl
- \tl_clear:N \l_@@_prev_mark_page_tl
- \tl_clear:N \l_@@_prev_mark_chap_tl
- \tl_clear:N \l_@@_prev_mark_sect_tl
- \tl_clear:N \l_@@_prev_mark_name_tl
- \seq_map_inline:Nn #1
- {
- \exp_args:Ne \tl_if_eq:nnT
- { \@@_prop_item:nn {##1} { type } }
- { note }
- {
- \@@_get_pageref:Nn
- \l_@@_curr_text_page_tl { text@ ##1 }
- \tl_if_empty:NF \l_@@_curr_text_page_tl
- {
- \tl_if_eq:NNTF
- \l_@@_prev_text_page_tl
- \l_@@_curr_text_page_tl
- {
-% \end{macrocode}
-% We are on the same page as the previous note, just update the
-% \texttt{prev_mark} data.
-% \begin{macrocode}
- \@@_get_pageref:Nn
- \l_@@_prev_mark_page_tl { mark@ ##1 }
- \@@_prop_get:nnN {##1} { thechapter }
- \l_@@_prev_mark_chap_tl
- \@@_prop_get:nnN {##1} { thesection }
- \l_@@_prev_mark_sect_tl
- \@@_prop_get:nnN {##1} { pnsectname }
- \l_@@_prev_mark_name_tl
- }
- {
-% \end{macrocode}
-% We are on the transition between two pages, current ID is the first note of
-% the new page (or on the very first note of \cs{printpostnotes}, given
-% \cs{l_@@_prev_text_page_tl} is initialized to empty).
-%
-% Set `last' values for previous page, based on the last valid
-% \texttt{prev_mark} stored ones. There is no previous page to the first one
-% of \cs{printpostnotes}, so we don't set `last' values for it (conditioning
-% on \cs{l_@@_prev_text_page_tl} being empty, which only occurs on the first
-% note).
-% \begin{macrocode}
- \tl_if_empty:NF \l_@@_prev_text_page_tl
- {
- \prop_gput:NVV \g_@@_header_page_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_page_tl
- \prop_gput:NVV \g_@@_header_chap_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_chap_tl
- \prop_gput:NVV \g_@@_header_sect_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_sect_tl
- \prop_gput:NVV \g_@@_header_name_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_name_tl
- }
-% \end{macrocode}
-%
-% Set `first' values for current page, based on the current note ID.
-% \begin{macrocode}
- \prop_gput:NVe \g_@@_header_page_first_prop
- \l_@@_curr_text_page_tl
- { \@@_extract_pageref:n { mark@ ##1 } }
- \@@_prop_get:nnN {##1} { thechapter }
- \l_@@_tmpa_tl
- \prop_gput:NVV \g_@@_header_chap_first_prop
- \l_@@_curr_text_page_tl
- \l_@@_tmpa_tl
- \@@_prop_get:nnN {##1} { thesection }
- \l_@@_tmpa_tl
- \prop_gput:NVV \g_@@_header_sect_first_prop
- \l_@@_curr_text_page_tl
- \l_@@_tmpa_tl
- \@@_prop_get:nnN {##1} { pnsectname }
- \l_@@_tmpa_tl
- \prop_gput:NVV \g_@@_header_name_first_prop
- \l_@@_curr_text_page_tl
- \l_@@_tmpa_tl
-% \end{macrocode}
-%
-% Store \texttt{prev_mark} data for the first note on the page.
-% \begin{macrocode}
- \@@_get_pageref:Nn
- \l_@@_prev_mark_page_tl { mark@ ##1 }
- \@@_prop_get:nnN {##1} { thechapter }
- \l_@@_prev_mark_chap_tl
- \@@_prop_get:nnN {##1} { thesection }
- \l_@@_prev_mark_sect_tl
- \@@_prop_get:nnN {##1} { pnsectname }
- \l_@@_prev_mark_name_tl
-% \end{macrocode}
-%
-% Set \cs{l_@@_prev_text_page_tl} for the next page
-% (\cs{l_@@_curr_text_page_tl} is never empty at this point, since we
-% conditioned to it).
-% \begin{macrocode}
- \tl_set:NV \l_@@_prev_text_page_tl
- \l_@@_curr_text_page_tl
- }
- }
- }
- }
-% \end{macrocode}
-% We can't catch the transition from the last page of \cs{printpostnotes} to
-% the following one through the mapping above, but the \texttt{prev_mark}
-% values of the last note in the loop are the ones we want, so we set `last'
-% values for the last page based on them.
-% \begin{macrocode}
- \tl_if_empty:NF \l_@@_prev_text_page_tl
- {
- \prop_gput:NVV \g_@@_header_page_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_page_tl
- \prop_gput:NVV \g_@@_header_chap_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_chap_tl
- \prop_gput:NVV \g_@@_header_sect_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_sect_tl
- \prop_gput:NVV \g_@@_header_name_last_prop
- \l_@@_prev_text_page_tl
- \l_@@_prev_mark_name_tl
- }
+ \protected at xdef \pnhdpagefirst
+ { \property_ref:nn { #1 } { postnotes/page/first } }
+ \protected at xdef \pnhdpagelast
+ { \property_ref:nn { #1 } { postnotes/page/last } }
+ \protected at xdef \pnhdchapfirst
+ { \property_ref:nn { #1 } { postnotes/chapter/first } }
+ \protected at xdef \pnhdchaplast
+ { \property_ref:nn { #1 } { postnotes/chapter/last } }
+ \protected at xdef \pnhdsectfirst
+ { \property_ref:nn { #1 } { postnotes/section/first } }
+ \protected at xdef \pnhdsectlast
+ { \property_ref:nn { #1 } { postnotes/section/last } }
+ \protected at xdef \pnhdnamefirst
+ { \property_ref:nn { #1 } { postnotes/sectname/first } }
+ \protected at xdef \pnhdnamelast
+ { \property_ref:nn { #1 } { postnotes/sectname/last } }
\group_end:
}
+\cs_generate_variant:Nn \@@_set_headers_vars:n { e }
% \end{macrocode}
-% \end{macro}
%
-%
-% The sequence of pages processed in \cs{@@_get_headers_data:N} is not ensured
-% to be continuous, since not every page of \cs{printpostnotes} starts a note.
-% There may be notes that fill whole pages, or the last page of the notes may
-% end with a note that started on the penultimate page. We must handle this
-% case at \cs{@@_set_headers_vars:n}. For every page for which there is
-% information provided by \cs{@@_get_headers_data:N} we store a
-% \texttt{header_prev_last} (the last value of the previous header) for each
-% of the variables of interest. If the next page is skipped in the sequence
-% (no notes starting on it), we can use these stored values to set both
-% `first' and `last' variables based on them for that page.
-%
-%
-% \begin{macro}{\@@_set_headers_vars:n}
-% Set user facing variables based on data generated by
-% \cs{@@_get_headers_data:N}.
-% \begin{syntax}
-% \cs{@@_set_headers_vars:n} \Arg{page number}
-% \end{syntax}
% \begin{macrocode}
-\cs_new_protected:Npn \@@_set_headers_vars:n #1
+\property_new:nnnn { postnotes/page/first } { shipout } { }
+ { \FirstMark { postnotes/page } }
+\property_new:nnnn { postnotes/page/last } { shipout } { }
+ { \LastMark { postnotes/page } }
+\property_new:nnnn { postnotes/chapter/first } { shipout } { }
+ { \FirstMark { postnotes/chapter } }
+\property_new:nnnn { postnotes/chapter/last } { shipout } { }
+ { \LastMark { postnotes/chapter } }
+\property_new:nnnn { postnotes/section/first } { shipout } { }
+ { \FirstMark { postnotes/section } }
+\property_new:nnnn { postnotes/section/last } { shipout } { }
+ { \LastMark { postnotes/section } }
+\property_new:nnnn { postnotes/sectname/first } { shipout } { }
+ { \FirstMark { postnotes/sectname } }
+\property_new:nnnn { postnotes/sectname/last } { shipout } { }
+ { \LastMark { postnotes/sectname } }
+\clist_const:Nn \c_@@_header_marks_clist
{
- \group_begin:
- \prop_get:NnNTF \g_@@_header_page_first_prop
- {#1} \l_@@_tmpa_tl
- { \tl_gset:NV \pnhdpagefirst \l_@@_tmpa_tl }
- { \tl_gset:NV \pnhdpagefirst \g_@@_header_prev_last_page_tl }
- \prop_get:NnNTF \g_@@_header_page_last_prop
- {#1} \l_@@_tmpa_tl
- {
- \tl_gset:NV \pnhdpagelast \l_@@_tmpa_tl
- \tl_gset:NV \g_@@_header_prev_last_page_tl
- \l_@@_tmpa_tl
- }
- { \tl_gset:NV \pnhdpagelast \g_@@_header_prev_last_page_tl }
- \prop_get:NnNTF \g_@@_header_chap_first_prop
- {#1} \l_@@_tmpa_tl
- { \tl_gset:NV \pnhdchapfirst \l_@@_tmpa_tl }
- { \tl_gset:NV \pnhdchapfirst \g_@@_header_prev_last_chap_tl }
- \prop_get:NnNTF \g_@@_header_chap_last_prop
- {#1} \l_@@_tmpa_tl
- {
- \tl_gset:NV \pnhdchaplast \l_@@_tmpa_tl
- \tl_gset:NV \g_@@_header_prev_last_chap_tl
- \l_@@_tmpa_tl
- }
- { \tl_gset:NV \pnhdchaplast \g_@@_header_prev_last_chap_tl }
- \prop_get:NnNTF \g_@@_header_sect_first_prop
- {#1} \l_@@_tmpa_tl
- { \tl_gset:NV \pnhdsectfirst \l_@@_tmpa_tl }
- { \tl_gset:NV \pnhdsectfirst \g_@@_header_prev_last_sect_tl }
- \prop_get:NnNTF \g_@@_header_sect_last_prop
- {#1} \l_@@_tmpa_tl
- {
- \tl_gset:NV \pnhdsectlast \l_@@_tmpa_tl
- \tl_gset:NV \g_@@_header_prev_last_sect_tl
- \l_@@_tmpa_tl
- }
- { \tl_gset:NV \pnhdsectlast \g_@@_header_prev_last_sect_tl }
- \prop_get:NnNTF \g_@@_header_name_first_prop
- {#1} \l_@@_tmpa_tl
- { \tl_gset:NV \pnhdnamefirst \l_@@_tmpa_tl }
- { \tl_gset:NV \pnhdnamefirst \g_@@_header_prev_last_name_tl }
- \prop_get:NnNTF \g_@@_header_name_last_prop
- {#1} \l_@@_tmpa_tl
- {
- \tl_gset:NV \pnhdnamelast \l_@@_tmpa_tl
- \tl_gset:NV \g_@@_header_prev_last_name_tl
- \l_@@_tmpa_tl
- }
- { \tl_gset:NV \pnhdnamelast \g_@@_header_prev_last_name_tl }
- \group_end:
+ postnotes/page/first ,
+ postnotes/page/last ,
+ postnotes/chapter/first ,
+ postnotes/chapter/last ,
+ postnotes/section/first ,
+ postnotes/section/last ,
+ postnotes/sectname/first ,
+ postnotes/sectname/last ,
}
-\cs_generate_variant:Nn \@@_set_headers_vars:n { e }
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}
-% {
-% \@@_set_headers_vars_next: ,
-% \@@_set_headers_vars_first: ,
-% }
-% The functions that actually call \cs{@@_set_headers_vars:n} at the
-% appropriate contexts with appropriate page values. Though we set
-% \cs{@@_set_headers_vars_next:} to run at every \texttt{shipout/before}
-% hook of the document, it is made no-op by \cs{g_@@_header_vars_next_bool}
-% which only has a \texttt{true} value inside \cs{printpostnotes}.
-% \cs{@@_set_headers_vars_first:} must set a label and retrieve its value to
-% be able to have a reliable value of its own page.
-% \begin{macrocode}
\AddToHook { shipout/before } [ ./header ]
{ \@@_set_headers_vars_next: }
\bool_new:N \g_@@_header_vars_next_bool
+\int_new:N \g_@@_print_header_vars_int
\cs_new_protected:Npn \@@_set_headers_vars_next:
{
\bool_if:NT \g_@@_header_vars_next_bool
- { \@@_set_headers_vars:e { \int_eval:n { \c at page + 1 } } }
+ {
+ \int_gincr:N \g_@@_print_header_vars_int
+ \exp_args:Ne \property_record:nN
+ { __postnotes_header_ \int_use:N \g_@@_print_header_vars_int }
+ \c_@@_header_marks_clist
+ \@@_set_headers_vars:e
+ { __postnotes_header_ \int_use:N \g_@@_print_header_vars_int }
+ }
}
\cs_new_protected:Npn \@@_set_headers_vars_first:
{
- \@@_set_print_page_label:e
- { \int_use:N \g_@@_print_postnotes_int }
+ \tl_gset:Nn \pnhdpagefirst { \FirstMark{postnotes/page} }
+ \tl_gset:Nn \pnhdpagelast { \LastMark{postnotes/page} }
+ \tl_gset:Nn \pnhdchapfirst { \FirstMark{postnotes/chapter} }
+ \tl_gset:Nn \pnhdchaplast { \LastMark{postnotes/chapter} }
+ \tl_gset:Nn \pnhdsectfirst { \FirstMark{postnotes/section} }
+ \tl_gset:Nn \pnhdsectlast { \LastMark{postnotes/section} }
+ \tl_gset:Nn \pnhdnamefirst { \FirstMark{postnotes/sectname} }
+ \tl_gset:Nn \pnhdnamelast { \LastMark{postnotes/sectname} }
+ \int_gincr:N \g_@@_print_header_vars_int
+ \exp_args:Ne \property_record:nN
+ { __postnotes_header_ \int_use:N \g_@@_print_header_vars_int }
+ \c_@@_header_marks_clist
\@@_set_headers_vars:e
- {
- \@@_extract_pageref:e
- { print@ \int_use:N \g_@@_print_postnotes_int }
- }
+ { __postnotes_header_ \int_use:N \g_@@_print_header_vars_int }
}
% \end{macrocode}
-% \end{macro}
%
%
-% \begin{macro}[int]{\pnheaderdefault}
-% A basic header function to be used as default in the \opt{heading} option.
-% It produces a header in the form ``Notes to pages N--M'', with a text
-% which can be localized (see Section~\ref{sec:languages}).
-% \begin{syntax}
-% \cs{pnheaderdefault}
-% \end{syntax}
-% \begin{macrocode}
-\NewDocumentCommand \pnheaderdefault {}
- {
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { \pnhdnotes{} ~ \pnhdtopage{} ~ \pnhdpagefirst }
- { \pnhdnotes{} ~ \pnhdtopages{} ~ \pnhdpagefirst -- \pnhdpagelast }
- }
-% \end{macrocode}
-% \end{macro}
-%
-%
% \section{Compatibility}
%
% A dedicated temp variable for restoring data.
@@ -3790,8 +3533,8 @@
% trust Ulrike knows better than me.
% \begin{macro}
% {
-% \@@_tagsup_store_sctructnum:nN
-% \@@_tagsup_store_crossref:nN
+% \@@_tagsup_store_sctructnum:nN ,
+% \@@_tagsup_store_crossref:nN ,
% }
% \begin{syntax}
% \cs{@@_tagsup_store_sctructnum:nN} \Arg{ref type} \Arg{ID number of note}
Modified: trunk/Master/texmf-dist/tex/latex/postnotes/postnotes.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/postnotes/postnotes.sty 2024-12-04 21:12:05 UTC (rev 73033)
+++ trunk/Master/texmf-dist/tex/latex/postnotes/postnotes.sty 2024-12-04 21:12:17 UTC (rev 73034)
@@ -52,7 +52,7 @@
'postnotes' requires a LaTeX kernel \postnotes at required@kernel\space or newer.%
}%
}%
-\ProvidesExplPackage {postnotes} {2024-11-27} {0.4.2}
+\ProvidesExplPackage {postnotes} {2024-12-03} {0.5.0}
{Endnotes for LaTeX}
\tl_new:N \l__postnotes_tmpa_tl
\tl_new:N \l__postnotes_tmpb_tl
@@ -129,15 +129,7 @@
\bool_new:N \g__postnotes_firstrun_bool
\bool_gset_true:N \g__postnotes_firstrun_bool
\cs_new_protected:Npn \__postnotes_store_labelseq:nn #1#2
- {
- \bool_lazy_any:nT
- {
- { \str_if_eq_p:nn {#1} { mark } }
- { \str_if_eq_p:nn {#1} { section } }
- { \str_if_eq_p:nn {#1} { preprint } }
- }
- { \seq_gput_right:Nn \g__postnotes_labelseq_seq { {#1} {#2} } }
- }
+ { \seq_gput_right:Nn \g__postnotes_labelseq_seq { {#1} {#2} } }
\cs_new_protected:Npn \__postnotes_step_counteraux:nnn #1#2#3
{
\bool_lazy_and:nnT
@@ -202,12 +194,10 @@
{
\legacy_if:nT { @filesw }
{
- \protected at write \@auxout
- { \cs_set_eq:NN \c__postnotes_page_counter_tl \scan_stop: }
+ \protected at write \@auxout { }
{ \token_to_str:N \post at note { #1 } { #2 } { #3 } { #4 } }
}
}
-\tl_const:Nn \c__postnotes_page_counter_tl { \int_use:N \c at page }
\cs_new_protected:Npn \__postnotes_set_mark_page_label:nn #1#2
{ \__postnotes_set_label:nnnn { mark } { #1 } { \thepage } { #2 } }
\cs_generate_variant:Nn \__postnotes_set_mark_page_label:nn { ee }
@@ -214,15 +204,9 @@
\cs_new_protected:Npn \__postnotes_set_section_page_label:n #1
{ \__postnotes_set_label:nnnn { section } { #1 } { \thepage } { } }
\cs_generate_variant:Nn \__postnotes_set_section_page_label:n { e }
-\cs_new_protected:Npn \__postnotes_set_text_page_label:n #1
- { \__postnotes_set_label:nnnn { text } { #1 } { \c__postnotes_page_counter_tl } { } }
-\cs_generate_variant:Nn \__postnotes_set_text_page_label:n { e }
-\cs_new_protected:Npn \__postnotes_set_print_page_label:n #1
- { \__postnotes_set_label:nnnn { print } { #1 } { \c__postnotes_page_counter_tl } { } }
-\cs_generate_variant:Nn \__postnotes_set_print_page_label:n { e }
-\cs_new_protected:Npn \__postnotes_set_pre_print_label:n #1
- { \__postnotes_set_label:nnnn { preprint } { #1 } { } { } }
-\cs_generate_variant:Nn \__postnotes_set_pre_print_label:n { e }
+\cs_new_protected:Npn \__postnotes_set_print_label:n #1
+ { \__postnotes_set_label:nnnn { print } { #1 } { } { } }
+\cs_generate_variant:Nn \__postnotes_set_print_label:n { e }
\cs_new_protected:Npn \__postnotes_get_pageref:Nn #1#2
{
\cs_if_exist:cTF { \c__postnotes_ref_prefix_tl @ #2 }
@@ -257,6 +241,19 @@
\@mkboth{\pnheaderdefault}{\pnheaderdefault}
}
}
+\NewDocumentCommand \pnheaderdefault {}
+ {
+ \group_begin:
+ \protected at edef \l__postnotes_tmpa_tl { \FirstMark{postnotes/page} }
+ \protected at edef \l__postnotes_tmpb_tl { \LastMark{postnotes/page} }
+ \tl_if_eq:NNTF \l__postnotes_tmpa_tl \l__postnotes_tmpb_tl
+ { \pnhdnotes{}~\pnhdtopage{}~ \FirstMark{postnotes/page} }
+ {
+ \pnhdnotes{}~\pnhdtopages{}~
+ \FirstMark{postnotes/page}--\LastMark{postnotes/page}
+ }
+ \group_end:
+ }
\tl_new:N \l__postnotes_print_format_tl
\keys_define:nn { postnotes/setup }
{
@@ -550,6 +547,7 @@
\NewDocumentCommand \postnote { O { } +m }
{ \__postnotes_note:nn {#1} {#2} }
\NewHook { postnotes/note/begin }
+\NewHook { postnotes/note/setlabels }
\cs_new_protected:Npn \__postnotes_note:nn #1#2
{
\group_begin:
@@ -595,6 +593,7 @@
}
\tl_set:Nn \l__postnotes_note_set_labels_tl
{
+ \UseHook { postnotes/note/setlabels }
\MakeLinkTarget* { postnote. \l_postnotes_note_id_tl .mark }
\__postnotes_set_mark_page_label:ee { \l_postnotes_note_id_tl }
{ \int_use:N \l__postnotes_counteraux_step_int }
@@ -850,9 +849,19 @@
\tl_new:N \l__postnotes_print_type_next_tl
\tl_new:N \l__postnotes_print_type_prev_tl
\tl_new:N \l__postnotes_print_content_tl
+\tl_new:N \l__postnotes_print_page_tl
+\tl_new:N \l__postnotes_print_chapter_tl
+\tl_new:N \l__postnotes_print_section_tl
+\tl_new:N \l__postnotes_print_sectname_tl
\seq_new:N \l__postnotes_clear_queue_seq
+\mark_new_class:n { postnotes/page }
+\mark_new_class:n { postnotes/chapter }
+\mark_new_class:n { postnotes/section }
+\mark_new_class:n { postnotes/sectname }
\NewHook { postnotes/print/begin }
\NewHook { postnotes/print/note/begin }
+\NewHook { postnotes/print/note/typesetmark }
+\NewHook { postnotes/print/note/ltmarks }
\newcounter { postnotetext }
\newcounter { postnotesection }
\setcounter { postnotesection } { 10000 }
@@ -874,7 +883,7 @@
}
\seq_set_eq:NN \l__postnotes_clear_queue_seq \g__postnotes_print_queue_seq
\seq_gclear:N \g__postnotes_queue_seq
- \__postnotes_set_pre_print_label:e
+ \__postnotes_set_print_label:e
{ \int_use:N \g__postnotes_print_postnotes_int }
\seq_if_empty:NTF \g__postnotes_print_queue_seq
{ \msg_warning:nn { postnotes } { empty-printpostnotes } }
@@ -886,7 +895,6 @@
\__postnotes_sort_queue:N \g__postnotes_print_queue_seq
\__postnotes_check_floats:N \g__postnotes_print_queue_seq
\bool_gset_true:N \g__postnotes_header_vars_next_bool
- \__postnotes_get_headers_data:N \g__postnotes_print_queue_seq
\__postnotes_set_headers_vars_first:
\bool_if:NF \l__postnotes_print_as_list_bool
{
@@ -963,8 +971,15 @@
}
\group_begin:
\UseHook { postnotes/print/note/begin }
- \__postnotes_get_pageref:Ne \pnthepage
+ \__postnotes_get_pageref:Ne \l__postnotes_print_page_tl
{ mark@ \l_postnotes_print_note_id_tl }
+ \__postnotes_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { thechapter } \l__postnotes_print_chapter_tl
+ \__postnotes_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { thesection } \l__postnotes_print_section_tl
+ \__postnotes_prop_get:nnN { \l_postnotes_print_note_id_tl }
+ { pnsectname } \l__postnotes_print_sectname_tl
+ \tl_set_eq:NN \pnthepage \l__postnotes_print_page_tl
\__postnotes_prop_get:nnN
{ \l_postnotes_print_note_id_tl }
{ mark } \l__postnotes_print_mark_tl
@@ -982,10 +997,9 @@
\tl_set:Nn \l__postnotes_print_typeset_mark_tl
{
\tag_socket_use:n { postnotes/printmark/begin }
+ \UseHook { postnotes/print/note/typesetmark }
\MakeLinkTarget*
{ postnote. \l_postnotes_print_note_id_tl .text }
- \__postnotes_set_text_page_label:e
- { \l_postnotes_print_note_id_tl }
\l__postnotes_pre_textmark_tl
\__postnotes_typeset_text_mark:eV
{ \l_postnotes_print_note_id_tl }
@@ -1007,6 +1021,15 @@
\tag_socket_use:n { postnotes/printnote/begin }
\l__postnotes_print_typeset_mark_tl
}
+ \UseHook { postnotes/print/note/ltmarks }
+ \mark_insert:nn { postnotes/page }
+ { \l__postnotes_print_page_tl }
+ \mark_insert:nn { postnotes/chapter }
+ { \l__postnotes_print_chapter_tl }
+ \mark_insert:nn { postnotes/section }
+ { \l__postnotes_print_section_tl }
+ \mark_insert:nn { postnotes/sectname }
+ { \l__postnotes_print_sectname_tl }
\tag_socket_use:n { postnotes/printtext/begin }
\l__postnotes_print_content_tl
\tag_socket_use:n { postnotes/printtext/end }
@@ -1061,7 +1084,7 @@
\bool_if:NTF \g__postnotes_counteraux_bool
{
\tl_set:Ne \l__postnotes_tmpa_tl
- { { preprint } { \int_use:N \g__postnotes_print_postnotes_int } }
+ { { print } { \int_use:N \g__postnotes_print_postnotes_int } }
\seq_if_in:NVF \g__postnotes_labelseq_seq \l__postnotes_tmpa_tl
{ \seq_gput_right:NV \g__postnotes_labelseq_seq \l__postnotes_tmpa_tl }
\bool_do_until:nn
@@ -1245,219 +1268,88 @@
\tl_new:N \pnhdsectlast
\tl_new:N \pnhdnamefirst
\tl_new:N \pnhdnamelast
-\prop_new:N \g__postnotes_header_page_first_prop
-\prop_new:N \g__postnotes_header_page_last_prop
-\prop_new:N \g__postnotes_header_chap_first_prop
-\prop_new:N \g__postnotes_header_chap_last_prop
-\prop_new:N \g__postnotes_header_sect_first_prop
-\prop_new:N \g__postnotes_header_sect_last_prop
-\prop_new:N \g__postnotes_header_name_first_prop
-\prop_new:N \g__postnotes_header_name_last_prop
-\tl_new:N \g__postnotes_header_prev_last_page_tl
-\tl_new:N \g__postnotes_header_prev_last_chap_tl
-\tl_new:N \g__postnotes_header_prev_last_sect_tl
-\tl_new:N \g__postnotes_header_prev_last_name_tl
-\tl_new:N \l__postnotes_prev_text_page_tl
-\tl_new:N \l__postnotes_curr_text_page_tl
-\tl_new:N \l__postnotes_prev_mark_page_tl
-\tl_new:N \l__postnotes_prev_mark_chap_tl
-\tl_new:N \l__postnotes_prev_mark_sect_tl
-\tl_new:N \l__postnotes_prev_mark_name_tl
-\cs_new_protected:Npn \__postnotes_get_headers_data:N #1
+\cs_new_protected:Npn \__postnotes_set_headers_vars:n #1
{
\group_begin:
- \tl_gclear:N \pnhdpagefirst
- \tl_gclear:N \pnhdpagelast
- \tl_gclear:N \pnhdchapfirst
- \tl_gclear:N \pnhdchaplast
- \tl_gclear:N \pnhdsectfirst
- \tl_gclear:N \pnhdsectlast
- \tl_gclear:N \pnhdnamefirst
- \tl_gclear:N \pnhdnamelast
- \prop_gclear:N \g__postnotes_header_page_first_prop
- \prop_gclear:N \g__postnotes_header_page_last_prop
- \prop_gclear:N \g__postnotes_header_chap_first_prop
- \prop_gclear:N \g__postnotes_header_chap_last_prop
- \prop_gclear:N \g__postnotes_header_sect_first_prop
- \prop_gclear:N \g__postnotes_header_sect_last_prop
- \prop_gclear:N \g__postnotes_header_name_first_prop
- \prop_gclear:N \g__postnotes_header_name_last_prop
- \tl_gclear:N \g__postnotes_header_prev_last_page_tl
- \tl_gclear:N \g__postnotes_header_prev_last_chap_tl
- \tl_gclear:N \g__postnotes_header_prev_last_sect_tl
- \tl_gclear:N \g__postnotes_header_prev_last_name_tl
- \tl_clear:N \l__postnotes_prev_text_page_tl
- \tl_clear:N \l__postnotes_curr_text_page_tl
- \tl_clear:N \l__postnotes_prev_mark_page_tl
- \tl_clear:N \l__postnotes_prev_mark_chap_tl
- \tl_clear:N \l__postnotes_prev_mark_sect_tl
- \tl_clear:N \l__postnotes_prev_mark_name_tl
- \seq_map_inline:Nn #1
- {
- \exp_args:Ne \tl_if_eq:nnT
- { \__postnotes_prop_item:nn {##1} { type } }
- { note }
- {
- \__postnotes_get_pageref:Nn
- \l__postnotes_curr_text_page_tl { text@ ##1 }
- \tl_if_empty:NF \l__postnotes_curr_text_page_tl
- {
- \tl_if_eq:NNTF
- \l__postnotes_prev_text_page_tl
- \l__postnotes_curr_text_page_tl
- {
- \__postnotes_get_pageref:Nn
- \l__postnotes_prev_mark_page_tl { mark@ ##1 }
- \__postnotes_prop_get:nnN {##1} { thechapter }
- \l__postnotes_prev_mark_chap_tl
- \__postnotes_prop_get:nnN {##1} { thesection }
- \l__postnotes_prev_mark_sect_tl
- \__postnotes_prop_get:nnN {##1} { pnsectname }
- \l__postnotes_prev_mark_name_tl
- }
- {
- \tl_if_empty:NF \l__postnotes_prev_text_page_tl
- {
- \prop_gput:NVV \g__postnotes_header_page_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_page_tl
- \prop_gput:NVV \g__postnotes_header_chap_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_chap_tl
- \prop_gput:NVV \g__postnotes_header_sect_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_sect_tl
- \prop_gput:NVV \g__postnotes_header_name_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_name_tl
- }
- \prop_gput:NVe \g__postnotes_header_page_first_prop
- \l__postnotes_curr_text_page_tl
- { \__postnotes_extract_pageref:n { mark@ ##1 } }
- \__postnotes_prop_get:nnN {##1} { thechapter }
- \l__postnotes_tmpa_tl
- \prop_gput:NVV \g__postnotes_header_chap_first_prop
- \l__postnotes_curr_text_page_tl
- \l__postnotes_tmpa_tl
- \__postnotes_prop_get:nnN {##1} { thesection }
- \l__postnotes_tmpa_tl
- \prop_gput:NVV \g__postnotes_header_sect_first_prop
- \l__postnotes_curr_text_page_tl
- \l__postnotes_tmpa_tl
- \__postnotes_prop_get:nnN {##1} { pnsectname }
- \l__postnotes_tmpa_tl
- \prop_gput:NVV \g__postnotes_header_name_first_prop
- \l__postnotes_curr_text_page_tl
- \l__postnotes_tmpa_tl
- \__postnotes_get_pageref:Nn
- \l__postnotes_prev_mark_page_tl { mark@ ##1 }
- \__postnotes_prop_get:nnN {##1} { thechapter }
- \l__postnotes_prev_mark_chap_tl
- \__postnotes_prop_get:nnN {##1} { thesection }
- \l__postnotes_prev_mark_sect_tl
- \__postnotes_prop_get:nnN {##1} { pnsectname }
- \l__postnotes_prev_mark_name_tl
- \tl_set:NV \l__postnotes_prev_text_page_tl
- \l__postnotes_curr_text_page_tl
- }
- }
- }
- }
- \tl_if_empty:NF \l__postnotes_prev_text_page_tl
- {
- \prop_gput:NVV \g__postnotes_header_page_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_page_tl
- \prop_gput:NVV \g__postnotes_header_chap_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_chap_tl
- \prop_gput:NVV \g__postnotes_header_sect_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_sect_tl
- \prop_gput:NVV \g__postnotes_header_name_last_prop
- \l__postnotes_prev_text_page_tl
- \l__postnotes_prev_mark_name_tl
- }
+ \protected at xdef \pnhdpagefirst
+ { \property_ref:nn { #1 } { postnotes/page/first } }
+ \protected at xdef \pnhdpagelast
+ { \property_ref:nn { #1 } { postnotes/page/last } }
+ \protected at xdef \pnhdchapfirst
+ { \property_ref:nn { #1 } { postnotes/chapter/first } }
+ \protected at xdef \pnhdchaplast
+ { \property_ref:nn { #1 } { postnotes/chapter/last } }
+ \protected at xdef \pnhdsectfirst
+ { \property_ref:nn { #1 } { postnotes/section/first } }
+ \protected at xdef \pnhdsectlast
+ { \property_ref:nn { #1 } { postnotes/section/last } }
+ \protected at xdef \pnhdnamefirst
+ { \property_ref:nn { #1 } { postnotes/sectname/first } }
+ \protected at xdef \pnhdnamelast
+ { \property_ref:nn { #1 } { postnotes/sectname/last } }
\group_end:
}
-\cs_new_protected:Npn \__postnotes_set_headers_vars:n #1
+\cs_generate_variant:Nn \__postnotes_set_headers_vars:n { e }
+\property_new:nnnn { postnotes/page/first } { shipout } { }
+ { \FirstMark { postnotes/page } }
+\property_new:nnnn { postnotes/page/last } { shipout } { }
+ { \LastMark { postnotes/page } }
+\property_new:nnnn { postnotes/chapter/first } { shipout } { }
+ { \FirstMark { postnotes/chapter } }
+\property_new:nnnn { postnotes/chapter/last } { shipout } { }
+ { \LastMark { postnotes/chapter } }
+\property_new:nnnn { postnotes/section/first } { shipout } { }
+ { \FirstMark { postnotes/section } }
+\property_new:nnnn { postnotes/section/last } { shipout } { }
+ { \LastMark { postnotes/section } }
+\property_new:nnnn { postnotes/sectname/first } { shipout } { }
+ { \FirstMark { postnotes/sectname } }
+\property_new:nnnn { postnotes/sectname/last } { shipout } { }
+ { \LastMark { postnotes/sectname } }
+\clist_const:Nn \c__postnotes_header_marks_clist
{
- \group_begin:
- \prop_get:NnNTF \g__postnotes_header_page_first_prop
- {#1} \l__postnotes_tmpa_tl
- { \tl_gset:NV \pnhdpagefirst \l__postnotes_tmpa_tl }
- { \tl_gset:NV \pnhdpagefirst \g__postnotes_header_prev_last_page_tl }
- \prop_get:NnNTF \g__postnotes_header_page_last_prop
- {#1} \l__postnotes_tmpa_tl
- {
- \tl_gset:NV \pnhdpagelast \l__postnotes_tmpa_tl
- \tl_gset:NV \g__postnotes_header_prev_last_page_tl
- \l__postnotes_tmpa_tl
- }
- { \tl_gset:NV \pnhdpagelast \g__postnotes_header_prev_last_page_tl }
- \prop_get:NnNTF \g__postnotes_header_chap_first_prop
- {#1} \l__postnotes_tmpa_tl
- { \tl_gset:NV \pnhdchapfirst \l__postnotes_tmpa_tl }
- { \tl_gset:NV \pnhdchapfirst \g__postnotes_header_prev_last_chap_tl }
- \prop_get:NnNTF \g__postnotes_header_chap_last_prop
- {#1} \l__postnotes_tmpa_tl
- {
- \tl_gset:NV \pnhdchaplast \l__postnotes_tmpa_tl
- \tl_gset:NV \g__postnotes_header_prev_last_chap_tl
- \l__postnotes_tmpa_tl
- }
- { \tl_gset:NV \pnhdchaplast \g__postnotes_header_prev_last_chap_tl }
- \prop_get:NnNTF \g__postnotes_header_sect_first_prop
- {#1} \l__postnotes_tmpa_tl
- { \tl_gset:NV \pnhdsectfirst \l__postnotes_tmpa_tl }
- { \tl_gset:NV \pnhdsectfirst \g__postnotes_header_prev_last_sect_tl }
- \prop_get:NnNTF \g__postnotes_header_sect_last_prop
- {#1} \l__postnotes_tmpa_tl
- {
- \tl_gset:NV \pnhdsectlast \l__postnotes_tmpa_tl
- \tl_gset:NV \g__postnotes_header_prev_last_sect_tl
- \l__postnotes_tmpa_tl
- }
- { \tl_gset:NV \pnhdsectlast \g__postnotes_header_prev_last_sect_tl }
- \prop_get:NnNTF \g__postnotes_header_name_first_prop
- {#1} \l__postnotes_tmpa_tl
- { \tl_gset:NV \pnhdnamefirst \l__postnotes_tmpa_tl }
- { \tl_gset:NV \pnhdnamefirst \g__postnotes_header_prev_last_name_tl }
- \prop_get:NnNTF \g__postnotes_header_name_last_prop
- {#1} \l__postnotes_tmpa_tl
- {
- \tl_gset:NV \pnhdnamelast \l__postnotes_tmpa_tl
- \tl_gset:NV \g__postnotes_header_prev_last_name_tl
- \l__postnotes_tmpa_tl
- }
- { \tl_gset:NV \pnhdnamelast \g__postnotes_header_prev_last_name_tl }
- \group_end:
+ postnotes/page/first ,
+ postnotes/page/last ,
+ postnotes/chapter/first ,
+ postnotes/chapter/last ,
+ postnotes/section/first ,
+ postnotes/section/last ,
+ postnotes/sectname/first ,
+ postnotes/sectname/last ,
}
-\cs_generate_variant:Nn \__postnotes_set_headers_vars:n { e }
\AddToHook { shipout/before } [ ./header ]
{ \__postnotes_set_headers_vars_next: }
\bool_new:N \g__postnotes_header_vars_next_bool
+\int_new:N \g__postnotes_print_header_vars_int
\cs_new_protected:Npn \__postnotes_set_headers_vars_next:
{
\bool_if:NT \g__postnotes_header_vars_next_bool
- { \__postnotes_set_headers_vars:e { \int_eval:n { \c at page + 1 } } }
+ {
+ \int_gincr:N \g__postnotes_print_header_vars_int
+ \exp_args:Ne \property_record:nN
+ { __postnotes_header_ \int_use:N \g__postnotes_print_header_vars_int }
+ \c__postnotes_header_marks_clist
+ \__postnotes_set_headers_vars:e
+ { __postnotes_header_ \int_use:N \g__postnotes_print_header_vars_int }
+ }
}
\cs_new_protected:Npn \__postnotes_set_headers_vars_first:
{
- \__postnotes_set_print_page_label:e
- { \int_use:N \g__postnotes_print_postnotes_int }
+ \tl_gset:Nn \pnhdpagefirst { \FirstMark{postnotes/page} }
+ \tl_gset:Nn \pnhdpagelast { \LastMark{postnotes/page} }
+ \tl_gset:Nn \pnhdchapfirst { \FirstMark{postnotes/chapter} }
+ \tl_gset:Nn \pnhdchaplast { \LastMark{postnotes/chapter} }
+ \tl_gset:Nn \pnhdsectfirst { \FirstMark{postnotes/section} }
+ \tl_gset:Nn \pnhdsectlast { \LastMark{postnotes/section} }
+ \tl_gset:Nn \pnhdnamefirst { \FirstMark{postnotes/sectname} }
+ \tl_gset:Nn \pnhdnamelast { \LastMark{postnotes/sectname} }
+ \int_gincr:N \g__postnotes_print_header_vars_int
+ \exp_args:Ne \property_record:nN
+ { __postnotes_header_ \int_use:N \g__postnotes_print_header_vars_int }
+ \c__postnotes_header_marks_clist
\__postnotes_set_headers_vars:e
- {
- \__postnotes_extract_pageref:e
- { print@ \int_use:N \g__postnotes_print_postnotes_int }
- }
+ { __postnotes_header_ \int_use:N \g__postnotes_print_header_vars_int }
}
-\NewDocumentCommand \pnheaderdefault {}
- {
- \tl_if_eq:NNTF \pnhdpagefirst \pnhdpagelast
- { \pnhdnotes{} ~ \pnhdtopage{} ~ \pnhdpagefirst }
- { \pnhdnotes{} ~ \pnhdtopages{} ~ \pnhdpagefirst -- \pnhdpagelast }
- }
\tl_new:N \l__postnotes_restore_tmp_tl
\AddToHook { postnotes/note/begin } [ ./compat/caption ]
{ \cs_if_exist:NT \@captype { \postnotesetup { maybemulti } } }
More information about the tex-live-commits
mailing list.