[latex3-commits] [git/LaTeX3-latex3-latex2e] master: don't loose a brace group with \addtocontents{{\bfseries foo}} :-( (f12fa75)

Frank Mittelbach frank.mittelbach at latex-project.org
Thu Sep 27 20:42:36 CEST 2018


Repository : https://github.com/latex3/latex2e
On branch  : master
Link       : https://github.com/latex3/latex2e/commit/f12fa75ed6738a8c55862d49c4d0b0c5e57aede0

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

commit f12fa75ed6738a8c55862d49c4d0b0c5e57aede0
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Thu Sep 27 20:42:36 2018 +0200

    don't loose a brace group with \addtocontents{{\bfseries foo}} :-(


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

f12fa75ed6738a8c55862d49c4d0b0c5e57aede0
 base/ltmiscen.dtx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/base/ltmiscen.dtx b/base/ltmiscen.dtx
index 7d7e2a3..8651487 100644
--- a/base/ltmiscen.dtx
+++ b/base/ltmiscen.dtx
@@ -384,7 +384,14 @@
 \catcode`\^^A=9 
 \long\gdef\add at percent@to at temptokena
     #1\protected at file@percent#2\add at percent@to at temptokena
-    {\ifx!#2!\@temptokena{#1}\else\@temptokena{#1%^^A
+%    \end{macrocode}
+%    When we call this macro in |\@writefile| we stick in |\@empty| at
+%   the beginning, so that in case the tokenlist consists of a single brace
+%   group the braces aren't stripped. The |\expandafter| then expands
+%   this extra token away again.
+%    \begin{macrocode}
+    {\ifx!#2!\@temptokena\expandafter{#1}\else
+             \@temptokena\expandafter{#1%^^A
 %    \end{macrocode}
 %    Can't be on the same line as the |%| --- see above.
 %    \begin{macrocode}
@@ -410,7 +417,7 @@
 %    out.
 %    \begin{macrocode}
       \add at percent@to at temptokena
-        #2\protected at file@percent
+        \@empty#2\protected at file@percent
         \add at percent@to at temptokena
      \immediate\write\csname tf@#1\endcsname{\the\@temptokena}%
     }%





More information about the latex3-commits mailing list