[latex3-commits] [latex3/latex2e] ltmarks-enhance: some documentation of David's idea (071e846b)

github at latex-project.org github at latex-project.org
Tue Nov 14 22:50:55 CET 2023


Repository : https://github.com/latex3/latex2e
On branch  : ltmarks-enhance
Link       : https://github.com/latex3/latex2e/commit/071e846bad7a2771ce86157e70b1877b6a5c7055

>---------------------------------------------------------------

commit 071e846bad7a2771ce86157e70b1877b6a5c7055
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Tue Nov 14 22:50:55 2023 +0100

    some documentation of David's idea


>---------------------------------------------------------------

071e846bad7a2771ce86157e70b1877b6a5c7055
 base/ltmarks.dtx                      | 97 +++++++++++++++++++++++++++++------
 base/testfiles-ltmarks/xmarks-009.tlg |  4 +-
 2 files changed, 83 insertions(+), 18 deletions(-)

diff --git a/base/ltmarks.dtx b/base/ltmarks.dtx
index d523df58..0a682945 100644
--- a/base/ltmarks.dtx
+++ b/base/ltmarks.dtx
@@ -898,16 +898,6 @@
 %  \begin{macro}{@@_prepare_and_extract:nnn}
 %
 %    \begin{macrocode}
-\cs_set_eq:cN{Ignore~infinite~glue~shrinkage~error}\c_max_dim
-%    \end{macrocode}
-%    \begin{macrocode}
-\cs_new_protected:Npx \@@_vbox_set_split_to_maxdimen:NN #1#2
-  { \tex_setbox:D #1 \tex_vsplit:D #2 to \exp_not:N\use:n{
-      \use:c{Ignore~infinite~glue~shrinkage~error}
-     }
-  }
-%    \end{macrocode}
-%    \begin{macrocode}
 \cs_new_protected:Npn \@@_prepare_and_extract:nnn #1#2#3 {
 %    \end{macrocode}
 %
@@ -999,11 +989,7 @@
 %    We therefore, change the interaction mode, so that such errors
 %    appear in the log, but do not stop the processing.
 %    \begin{macrocode}
-          \tl_set:Ne \l_@@_interaction_tl
-             { \interactionmode \the\interactionmode\relax }
-          \interactionmode 0\scan_stop:
           \@@_vbox_set_split_to_maxdimen:NN \l_@@_ii_box \l_@@_box 
-          \l_@@_interaction_tl   
 %    \end{macrocode}
 %    After splitting we check if there is anything left in
 %    \cs{l_@@_box}. If not then the above split has set some split marks
@@ -1038,10 +1024,89 @@
 %  \end{macro}
 %
 %
-%  \begin{macro}{\l_@@_interaction_tl}
+%  \begin{macro}{\@@_vbox_set_split_to_maxdimen:NN}
+%
+%    Split a box to get at its marks without pausing even if \TeX{} is
+%    producing an error message because of infinite negative glue in
+%    the box. If there is such an error we ensure that it only shows
+%    up in the log but not on the terminal.
+%
+%    The nice low-level hack by DPC records in the \texttt{.log} that a glue
+%    shrinkage error is harmless.
+%
+%    We disguise \Cs{c_max_dim} in an odd looking csname, which then
+%    shows up as part of the display of an error message if that error
+%    happens. This csname forms part of the error diplay so what
+%    you get is something like
+%\begin{verbatim}
+%   ! Infinite glue shrinkage found in box being split.
+%   <argument> Glue shrinkage error above ignored ! 
+%   l. ...  }
+%\end{verbatim}
+%    which hopefully makes it clear that the error is harmless and ignored.
+%    \begin{macrocode}
+\cs_set_eq:cN {Glue~shrinkage~error~above~ignored~!}\c_max_dim
+%    \end{macrocode}
+%
+%    The whole definition of \cs{@@_vbox_set_split_to_maxdimen:NN}
+%    below is fully expanded, so we have to use a lot of
+%    \cs{exp_not:N}s to prevent expansion where necessary.
+%    \begin{macrocode}
+\cs_new_protected:Npx \@@_vbox_set_split_to_maxdimen:NN #1#2 {
+%    \end{macrocode}
+%    We start by saving the current interaction and escape char setting.
+%    \begin{macrocode}
+  \tl_set:Nn \exp_not:N \l_@@_saved_parameters_tl
+     {
+       \tex_interactionmode:D
+          \int_use:N \tex_interactionmode:D \scan_stop:
+       \tex_escapechar:D
+          \int_use:N \tex_escapechar:D \scan_stop:
+     }
+%    \end{macrocode}
+%    Then we change them so that no escape char is printed in the
+%    error message (accounts for the missing backslash in front of
+%    \verb/Glue shrinkage .../) and we set the interaction to
+%    \cs{nonstopmode} so that the the error (if any) just goes into
+%    the \texttt{.log} file and \TeX{} doesn't stop at that point.
+%    \begin{macrocode}
+  \tex_escapechar:D     -1 \scan_stop:
+  \nonstopmode
+%    \end{macrocode}
+%    Then we do the splitting of the box to \cs{c_max_dim} to get at
+%    the marks. This may generate the error we are worried about,
+%    i.e., if the box contains infinite negative glue. However, \TeX{}
+%    makes this glue finite and continues, which means we get our split
+%    marks which is really all we care about.
+%    \begin{macrocode}
+  \tex_setbox:D #1 \tex_vsplit:D #2 to
+%    \end{macrocode}
+%    The \cs{use:n} may seem pointless, and it is to some extent, but
+%    we need it to get our  disguised \cs{c_max_dim} displayed
+%    properly as part of the error message if there is one. Without
+%    it, the display would show only part of what we want it to show
+%    (try it).
+%    \begin{macrocode}
+      \exp_not:N \use:n {
+%        \use:c{~Ignore~infinite~glue~shrinkage~error}
+%        \use:c{Glue~shrinkage~error~is~harmless~!}
+        \use:c{Glue~shrinkage~error~above~ignored~!}
+      }
+%    \end{macrocode}
+%    Finally, we change the escape char and the interaction mode back
+%    to what it was before:
+%    \begin{macrocode}
+  \exp_not:N \l_@@_saved_parameters_tl
+}
+%    \end{macrocode}
+%  \end{macro}
+%
+%
+%
+%  \begin{macro}{\l_@@_saved_parameters_tl}
 %    
 %    \begin{macrocode}
-\tl_new:N \l_@@_interaction_tl
+\tl_new:N \l_@@_saved_parameters_tl
 %    \end{macrocode}
 %  \end{macro}
 %
diff --git a/base/testfiles-ltmarks/xmarks-009.tlg b/base/testfiles-ltmarks/xmarks-009.tlg
index f9d5bab1..9c6ee11e 100644
--- a/base/testfiles-ltmarks/xmarks-009.tlg
+++ b/base/testfiles-ltmarks/xmarks-009.tlg
@@ -113,14 +113,14 @@ Marks: set 2e-right-nonempty <- 'H' on line ...
 Marks: set 2e-right <- 'I' on line ...
 Marks: set 2e-right-nonempty <- 'I' on line ...
 ! Infinite glue shrinkage found in box being split.
-\__box_dim_eval:n ...box_dim_eval:w #1\scan_stop: 
+<argument> Glue shrinkage error above ignored ! 
 l. ...   }
 The box you are \vsplitting contains some infinitely
 shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.
 Such glue doesn't belong there; but you can safely proceed,
 since the offensive shrinkability has been made finite.
 ! Infinite glue shrinkage found in box being split.
-\__box_dim_eval:n ...box_dim_eval:w #1\scan_stop: 
+<argument> Glue shrinkage error above ignored ! 
 l. ...   }
 The box you are \vsplitting contains some infinitely
 shrinkable glue, e.g., `\vss' or `\vskip 0pt minus 1fil'.





More information about the latex3-commits mailing list.