[latex3-commits] [git/LaTeX3-latex3-latex2e] mathcolor: added ltnews entry (c17f7d97)
Frank Mittelbach
frank.mittelbach at latex-project.org
Fri Jan 7 19:34:00 CET 2022
Repository : https://github.com/latex3/latex2e
On branch : mathcolor
Link : https://github.com/latex3/latex2e/commit/c17f7d97a966516722743a232c2d92c65b255fc2
>---------------------------------------------------------------
commit c17f7d97a966516722743a232c2d92c65b255fc2
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Fri Jan 7 19:34:00 2022 +0100
added ltnews entry
>---------------------------------------------------------------
c17f7d97a966516722743a232c2d92c65b255fc2
base/doc/ltnews.tex | 6 +++++-
base/doc/ltnews35.tex | 40 +++++++++++++++++++++++++++++++++++++---
required/graphics/mathcolor.dtx | 2 +-
3 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/base/doc/ltnews.tex b/base/doc/ltnews.tex
index 4b62be9f..cba11c3c 100644
--- a/base/doc/ltnews.tex
+++ b/base/doc/ltnews.tex
@@ -222,7 +222,11 @@
\def\y{|multicol}%
\ifx\x\y
\else
- \@latex at error{ltnews.tex: \string\usepackage[#1]{#2} found}\@ehc
+ \def\y{|color}%
+ \ifx\x\y
+ \else
+ \@latex at error{ltnews.tex: \string\usepackage[#1]{#2} found}\@ehc
+ \fi
\fi
\fi
\fi
diff --git a/base/doc/ltnews35.tex b/base/doc/ltnews35.tex
index e7d9ff20..d97201b4 100644
--- a/base/doc/ltnews35.tex
+++ b/base/doc/ltnews35.tex
@@ -47,6 +47,7 @@
\usepackage{csquotes}
\usepackage{multicol}
+\usepackage{color}
\providecommand\hook[1]{\texttt{#1}}
@@ -439,9 +440,42 @@ is now fixed.
\subsection{Color in formulas}
-\emph{write entry}
-%
-\githubissue{???}
+While it is possible to color parts of a formula using \cs{color}
+commands the approach is fairly cumbersome. For example, to color an
+summation sign, but not its limits, you need four \cs{color} commands and
+some seemingly unnecessary set of braces to get coloring and spacing
+right:
+\begin{verbatim}
+\[ X = \color{red} \sum
+% without {{ the superscript below is misplaced
+ _{{\color{black} i=1}}
+% without {{ the \sum is black
+ ^{{\color{black} n}}
+ \color{black} % without it the x_i is red
+ x_i \]
+\end{verbatim}
+Leave out any of the \cs{color} commands or any of the \verb={{...}}=
+will give you a wrong result instead of the desired
+\[ X = \color{red} \sum
+ _{{\color{black} i=1}} % without {{ the superscript is misplaced
+ ^{{\color{black} n}} % without {{ the \sum is black
+ \color{black} % without it the x_i is red
+ x_i
+\]
+So even if this is possible, it is not a very practical solution and
+furthermore there are a number of cases where it is impossible to
+color a certain part of a formula, for example, an opening symbol such
+as \verb=\left(= but not the corresponding \verb=\right)=.
+
+We have therefore added the command \cs{mathcolor} to the \pkg{color}
+and \pkg{xcolor} pachage, which has the same syntax as \cs{textcolor},
+but is specially designed for use in math and handles sub and
+superscripts and other aspects correctly and preserves correct
+spacing. Thus, the above example can now be written as
+\begin{verbatim}
+\[ X = \mathcolor{red}{\sum}_{i=1}^n x_i \]
+\end{verbatim}
+For details and further examples, see \file{mathcolor.pdf}.
\subsection{???}
diff --git a/required/graphics/mathcolor.dtx b/required/graphics/mathcolor.dtx
index dd72262a..a0ea614c 100644
--- a/required/graphics/mathcolor.dtx
+++ b/required/graphics/mathcolor.dtx
@@ -63,7 +63,7 @@
% A total of four color commands and a number of seemingly
% unnecessary extra braces in the sub and superscript are needed:
%\begin{verbatim}
-% \[ X = \color{red} \sum
+% \[ X = \color{red} \sum
% _{{\color{black} i=1}} % without {{ the superscript is misplaced
% ^{{\color{black} n}} % without {{ the \sum is black
% \color{black} % without the x_i is red
More information about the latex3-commits
mailing list.