1

I need to color a portion of a displayed equation, but when I do that the equation gets turned into \textstyle instead of \displaystyle. Here is a minimal working example:

\documentclass{amsart}
\usepackage{amssymb, xcolor}
\begin{document}
\[
\prod_{a\in A} a
\]
\[
\textcolor{red}{\prod_{a\in A} a}
\]
\[
\textcolor{red}{\prod}_{a\in A} a
\]
\end{document}

In the third example (where the error appears) I tried to insert \displaystyle at the beginning, to no avail. I am confused; your help is most appreciated. Thanks!

underflow
  • 559
  • 1
    use \mathcolor. – Ulrike Fischer Nov 25 '23 at 16:08
  • Thanks @fischer, but the second-last comment in https://tex.stackexchange.com/questions/21598/how-to-color-math-symbols seems to suggest that \mathcolor should not be used --- perhaps I misunderstodd that comment? – underflow Nov 25 '23 at 16:15
  • That is old. In a current latex \mathcolor is predefined. – Ulrike Fischer Nov 25 '23 at 16:27
  • Thanks @fischer. Could you provide a MWE? I tried to use [ \mathcolor{red}{\prod}_{a\in A} a ] in my MWE and got the error "Undefined control sequence" for \mathcolor. I am using TeX Live 2022. – underflow Nov 25 '23 at 16:35
  • the code was added 2022/06/12 v2.14 to xcolor, and im 2022/06/01 to latex, so it should work in a texlive 2022 which has been updated. – Ulrike Fischer Nov 25 '23 at 17:07
  • Thanks @fischer. I am using pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2022) and still got the error. If you could provide a MWE I'd be most appreciative. – underflow Nov 25 '23 at 17:10
  • the pdftex version is not relevant. Check in the log the version of the latex format and of xcolor. – Ulrike Fischer Nov 25 '23 at 17:11
  • @fischer: Aaah my log file says: Package: xcolor 2021/10/31 v2.13 and (preloaded format=pdflatex 2023.5.30). This is a work machine and it would be difficult to get the packages updates. Could you offer an alternative solution? Thank! – underflow Nov 25 '23 at 17:30
  • 1
    In older versions, you can just copy paste the definition of mathcolor from this answer https://tex.stackexchange.com/a/261480/250119 . – user202729 Nov 26 '23 at 02:00

0 Answers0