[latex3-commits] [git/LaTeX3-latex3-xcolor] main: make user commands protected like in color.sty, issue #17 (1b2e923)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun Jun 12 14:54:16 CEST 2022


Repository : https://github.com/latex3/xcolor
On branch  : main
Link       : https://github.com/latex3/xcolor/commit/1b2e923daa244bc0a95158b7b899313d2ac7e048

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

commit 1b2e923daa244bc0a95158b7b899313d2ac7e048
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun Jun 12 14:54:16 2022 +0200

    make user commands protected like in color.sty, issue #17


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

1b2e923daa244bc0a95158b7b899313d2ac7e048
 ChangeLog  |  4 +++-
 xcolor.dtx | 16 ++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fc587f2..6798a11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,11 +3,13 @@ https://github.com/latex3/xcolor/issues
 
 History
 =======
-2022/04/19 v2.14
+2022/06/12 v2.14
 * New features:
     - Load if it exists the code from LaTeX to define \mathcolor.
 * Bugfixes (LaTeX Team)
     - Modify \XC at info to avoid spurious error from \colorlet{foo}{} issue #12
+* make \normalcolor, \colorbox, \fcolorbox \textcolor, \pagecolor, 
+ \nopagecolor, \definecolor, \DefineNamedColor protected as in color.sty issue#17
 
 2021/10/31 v2.13
 * Bugfixes (LaTeX Team)
diff --git a/xcolor.dtx b/xcolor.dtx
index dd78aba..1d4abda 100644
--- a/xcolor.dtx
+++ b/xcolor.dtx
@@ -4855,7 +4855,7 @@
 % \end{itemize}
 % See table \vref{tab.internal} for some examples.
 %    \begin{macrocode}
-\def\definecolor{\@testopt{\XC at definecolor}{}}
+\protected\def\definecolor{\@testopt{\XC at definecolor}{}}
 \def\XC at definecolor[#1]#2%
  {\@testopt{\XC at definec@lor[#1]{#2}}\colornameprefix}
 %    \end{macrocode}
@@ -5072,7 +5072,7 @@
 % \begin{macro}{\DefineNamedColor}
 %   \marg{type}\marg{name}\marg{model-list}\marg{spec-list}
 %    \begin{macrocode}
-\def\DefineNamedColor#1%
+\protected\def\DefineNamedColor#1%
  {\@nameuse{XC@\ifdefinecolors defin\else prepar\fi ecolor}[#1]}
 %    \end{macrocode}
 %  \end{macro}
@@ -5437,7 +5437,7 @@
 % The naming is by analogy with |\textrm| (as opposed to |\rm| and |\rmfamily|) although it is slightly a misnomer as the command also works in math-mode.
 % Additionally, it calls |\leavevmode| to ensure the start of horizontal mode.
 %    \begin{macrocode}
-\def\textcolor#1#{\@textcolor{#1}}
+\protected\def\textcolor#1#{\@textcolor{#1}}
 \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
 %    \end{macrocode}
 %  \end{macro}
@@ -5448,7 +5448,7 @@
 % Specifies the background color for the current, and all following, pages.
 % It is a global declaration which does not respect \TeX\ groups.
 %    \begin{macrocode}
-\def\pagecolor
+\protected\def\pagecolor
  {\begingroup
   \let\ignorespaces\endgroup \let\set at color\set at page@color
   \color}
@@ -5459,7 +5459,7 @@
 % Removes any currently specified page color returning to the default transparent background.
 % It is not yet supported by all driver options and so generates a warning if there is no definition in the driver file.
 %    \begin{macrocode}
-\def\nopagecolor
+\protected\def\nopagecolor
  {\@ifundefined{no at page@color}%
    {\PackageInfo{xcolor}{\@backslashchar nopagecolor\space is not supported}}%
    {\no at page@color}}
@@ -5479,7 +5479,7 @@
 %   \oarg{model}\marg{spec}\marg{text}\\
 % Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box.
 %    \begin{macrocode}
-\def\colorbox#1#{\protect\color at box{#1}}
+\protected\def\colorbox#1#{\color at box{#1}}
 \def\color at box#1#2{\color at b@x\relax{\color#1{#2}}}
 %    \end{macrocode}
 % \end{macro}
@@ -5492,7 +5492,7 @@
 % Puts a frame of the first color around a box with a background specified by the second color.
 % If only the first optional argument is given, it specifies the color model for both colors.
 %    \begin{macrocode}
-\def\fcolorbox#1#{\color at fbox{#1}}
+\protected\def\fcolorbox#1#{\color at fbox{#1}}
 \def\color at fbox#1#2#3#{\protect\color at fb@x{#1}{#2}{#3}}
 \def\color at fb@x#1#2#3#4%
  {\color at b@x{\fboxsep\z@\color#1{#2}\XC at fbox}%
@@ -6985,7 +6985,7 @@
 % |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it is safe to use this in macros that may possibly be used in conjunction with color.
 % It will have no effect until the \XCP{} is also loaded.
 %    \begin{macrocode}
-\def\normalcolor{\let\current at color\default at color\set at color}
+\protected\def\normalcolor{\let\current at color\default at color\set at color}
 %    \end{macrocode}
 % \end{macro}
 %





More information about the latex3-commits mailing list.