[latex3-commits] [latex3/latex2e] ltproperties-activechars: firstaid to make underscore protected and safe in csnames (8e3fd404)

github at latex-project.org github at latex-project.org
Wed Sep 20 14:37:01 CEST 2023


Repository : https://github.com/latex3/latex2e
On branch  : ltproperties-activechars
Link       : https://github.com/latex3/latex2e/commit/8e3fd4046bf15615b74e3400a01794d6866ad64f

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

commit 8e3fd4046bf15615b74e3400a01794d6866ad64f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Sep 20 14:37:01 2023 +0200

    firstaid to make underscore protected and safe in csnames


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

8e3fd4046bf15615b74e3400a01794d6866ad64f
 required/firstaid/changes.txt                      |  11 +-
 required/firstaid/firstaid.ins                     |   3 +
 .../latex2e-first-aid-for-external-files.dtx       |  42 +++++++-
 .../firstaid/testfiles/firstaid-underscore.lvt     |  27 +++++
 .../firstaid/testfiles/firstaid-underscore.tlg     | 117 +++++++++++++++++++++
 5 files changed, 195 insertions(+), 5 deletions(-)

diff --git a/required/firstaid/changes.txt b/required/firstaid/changes.txt
index 17d8f9ac..8db6a5d0 100644
--- a/required/firstaid/changes.txt
+++ b/required/firstaid/changes.txt
@@ -1,8 +1,13 @@
+2023-09-20  Ulrike Fischer  <Ulrike.Fischer at latex-project.org>
+
+	* latex2e-first-aid-for-external-files.dtx: add firstaid for underscore to 
+      make the active char protected and safe for use in csnames.
+      
 2023-07-18  Ulrike Fischer  <Ulrike.Fischer at latex-project.org>
-    * latex2e-first-aid-for-external-files.dtx: remove no longer needed code for 
+	* latex2e-first-aid-for-external-files.dtx: remove no longer needed code for 
       everysel
-    * latex2e-first-aid-for-external-files.dtx: remove no longer needed code for bidi 
-    * latex2e-first-aid-for-external-files.dtx: 
+	* latex2e-first-aid-for-external-files.dtx: remove no longer needed code for bidi 
+	* latex2e-first-aid-for-external-files.dtx: 
       remove no longer needed code for memoir/stockheight 
      
 2023-05-20  Ulrike Fischer  <Ulrike.Fischer at latex-project.org>
diff --git a/required/firstaid/firstaid.ins b/required/firstaid/firstaid.ins
index b3f30c30..22067390 100644
--- a/required/firstaid/firstaid.ins
+++ b/required/firstaid/firstaid.ins
@@ -72,4 +72,7 @@ without such generated files.
 \generate{\file{filehook-ltx.sty}
                {\from{latex2e-first-aid-for-external-files.dtx}{filehook-ltx}}}
 
+\generate{\file{underscore-ltx.sty}
+               {\from{latex2e-first-aid-for-external-files.dtx}{underscore-ltx}}}
+
 \endbatchfile
diff --git a/required/firstaid/latex2e-first-aid-for-external-files.dtx b/required/firstaid/latex2e-first-aid-for-external-files.dtx
index d1eeaf5c..ed6c898d 100644
--- a/required/firstaid/latex2e-first-aid-for-external-files.dtx
+++ b/required/firstaid/latex2e-first-aid-for-external-files.dtx
@@ -111,8 +111,8 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\def\LaTeXFirstAidDate{2023/07/18}
-\def\LaTeXFirstAidVersion{v1.1a}
+\def\LaTeXFirstAidDate{2023/09/20}
+\def\LaTeXFirstAidVersion{v1.1b}
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -563,6 +563,44 @@
 %    \begin{macrocode}
 %</kernel>
 %    \end{macrocode}
+% \subsection{The \pkg{underscore} first aid}
+% 
+% The \pkg{underscore} package makes the underscore active. This means that the
+% underscore can not be used in label and references unless the package option \texttt{strings} is used
+% (which patches a selection of problematic commands like \cs{label} and \cs{ref}) 
+% or \pkg{babel} is used which redefines\footnote{unless the recommended option \texttt{safe=none} is used} 
+% a selection of problematic commands like \cs{@testdef} or \cs{@newl at bel}.
+% 
+% With the new property commands the work-around do not work. We therefore make the 
+% underscore protected and use \cs{ifincsname} to allow its use in csnames.
+% 
+%    \begin{macrocode}
+%<*underscore-ltx>
+\ProvidesPackage{underscore-ltx}[2023/09/20 LaTeX firstaid to make underscore protected ]
+\begingroup
+ \catcode`\_=\active
+ \protected\gdef _{%   
+   \ifincsname % 
+      \string_%
+   \else
+      \ifx\protect\@typeset at protect
+         \ifmmode \sb \else \BreakableUnderscore \fi
+      \else
+         \ifx\protect\@unexpandable at protect \noexpand_%
+         \else \protect_%
+      \fi\fi
+    \fi
+    }
+  \global\let\ActiveUnderscore=_
+\endgroup
+%</underscore-ltx>
+%    \end{macrocode}
+%    \begin{macrocode}
+%<*kernel>
+\AddToHook{file/underscore.sty/after}[firstaid]{%
+  \FirstAidNeededT{underscore}{sty}{2006/09/13}{\RequirePackage{underscore-ltx}}}
+%</kernel>
+%    \end{macrocode}
 %
 % \Finale
 %
diff --git a/required/firstaid/testfiles/firstaid-underscore.lvt b/required/firstaid/testfiles/firstaid-underscore.lvt
new file mode 100644
index 00000000..664f1a59
--- /dev/null
+++ b/required/firstaid/testfiles/firstaid-underscore.lvt
@@ -0,0 +1,27 @@
+\documentclass{book}
+\input{regression-test}
+\usepackage{underscore}
+\usepackage{zref-user}
+\START
+\SHOWFILE{\jobname.aux}
+\OMIT
+\begin{document}
+\TIMO
+\showoutput
+
+activation_energy $E_a$
+
+\label{a"a_a} 
+
+\ExplSyntaxOn
+bbb%
+\property_ref:ee   {b"b_b}{page}
+\property_record:nn{b"b_b}{page}
+\ExplSyntaxOff
+
+ddd\RecordProperties{d"d_d}{page}
+\RefProperty{d"d_d}{page}
+
+eee \zlabel{e"e_e} \zref{e"e_e}
+
+\end{document} 
\ No newline at end of file
diff --git a/required/firstaid/testfiles/firstaid-underscore.tlg b/required/firstaid/testfiles/firstaid-underscore.tlg
new file mode 100644
index 00000000..148faf21
--- /dev/null
+++ b/required/firstaid/testfiles/firstaid-underscore.tlg
@@ -0,0 +1,117 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+-------- firstaid-underscore.aux (start) ---------
+(firstaid-underscore.aux) \relax^^M
+\providecommand\zref at newlabel[2]{}^^M
+\catcode 95\active^^M
+\newlabel{a"a_a}{{}{1}{}{}{}}^^M
+\new at label@record{b"b_b}{{page}{1}}^^M
+\new at label@record{d"d_d}{{page}{1}}^^M
+\zref at newlabel{e"e_e}{\default{}\page{1}}^^M
+\gdef \@abspage at last{1}^^M
+-------- firstaid-underscore.aux (end) -----------
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <7> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <5> on input line ....
+Completed box being shipped out [1]
+\vbox(627.36243+0.0)x380.0
+.\glue 22.0
+.\vbox(605.36243+0.0)x345.0, shifted 35.0
+..\vbox(12.0+0.0)x345.0, glue set 5.55556fil
+...\glue 0.0 plus 1.0fil
+...\hbox(6.44444+0.0)x345.0
+....\hbox(6.44444+0.0)x345.0, glue set 339.99998fil
+.....\glue 0.0 plus 1.0fil
+.....\OT1/cmr/m/n/10 1
+..\glue 18.06749
+..\glue(\lineskip) 0.0
+..\vbox(550.0+0.0)x345.0, glue set 504.0fil
+...\write-{}
+...\glue(\topskip) 3.16669
+...\hbox(6.83331+1.94444)x345.0, glue set 239.15245fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 c
+....\OT1/cmr/m/n/10 t
+....\OT1/cmr/m/n/10 i
+....\OT1/cmr/m/n/10 v
+....\kern-0.55556
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 t
+....\OT1/cmr/m/n/10 i
+....\OT1/cmr/m/n/10 o
+....\OT1/cmr/m/n/10 n
+....\penalty 10000
+....\glue 0.0
+....\kern 0.59998
+....\vbox(0.4+0.0)x3.00003
+.....\rule(0.4+0.0)x3.00003
+....\discretionary
+.....\OT1/cmr/m/n/10 -
+....\penalty 10000
+....\glue 0.0
+....\OT1/cmr/m/n/10 e
+....\OT1/cmr/m/n/10 n
+....\OT1/cmr/m/n/10 e
+....\OT1/cmr/m/n/10 r
+....\OT1/cmr/m/n/10 g
+....\OT1/cmr/m/n/10 y
+....\glue 3.33333 plus 1.66666 minus 1.11111
+....\mathon
+....\OML/cmm/m/it/10 E
+....\hbox(3.01389+0.0)x4.83765, shifted 1.49998
+.....\OML/cmm/m/it/7 a
+....\mathoff
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\write1{\newlabel{a"a_a}{{}{\thepage }{}{}{}}}
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\baselineskip) 3.11111
+...\hbox(6.94444+0.0)x345.0, glue set 308.33327fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 b
+....\OT1/cmr/m/n/10 b
+....\OT1/cmr/m/n/10 b
+....\OT1/cmr/m/n/10 1
+....\write1{\new at label@record{b"b_b}{{page}{\__property_code_page: }}}
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\baselineskip) 5.05556
+...\hbox(6.94444+0.0)x345.0, glue set 304.99994fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 d
+....\OT1/cmr/m/n/10 d
+....\OT1/cmr/m/n/10 d
+....\write1{\new at label@record{d"d_d}{{page}{\__property_code_page: }}}
+....\glue 3.33333 plus 1.66666 minus 1.11111
+....\OT1/cmr/m/n/10 1
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue(\parskip) 0.0 plus 1.0
+...\glue(\parskip) 0.0
+...\glue(\baselineskip) 7.69446
+...\hbox(4.30554+0.0)x345.0, glue set 313.33334fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 e
+....\OT1/cmr/m/n/10 e
+....\OT1/cmr/m/n/10 e
+....\glue 3.33333 plus 1.66666 minus 1.11111
+....\write1{\zref at newlabel{e"e_e}{\default{}\page{\Z at C@page }}}
+....\penalty 10000
+....\glue 0.0
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue 0.0 plus 1.0fil
+...\glue 0.0
+..\glue(\baselineskip) 25.29494
+..\hbox(0.0+0.0)x345.0
+...\hbox(0.0+0.0)x345.0
+(firstaid-underscore.aux)





More information about the latex3-commits mailing list.