9

I have a math equation with a \tag operator.

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}

\begin{document}

This is my favorite equality:
\begin{align*}
    \color{red}\sum_{n=1}^\infty\dfrac{1}{n^2}=\dfrac{\pi^2}{6}.\tag{E1}
\end{align*}

\end{document}

I would like to color the tag (E1) in red.

What I did is I added \tag{\textcolor{red}{E1}} but this only colored the E1 without the parentheses.

2
  • 1
    You could use \tag* and add the () manually to it
    – daleif
    Commented Jul 17, 2019 at 11:18
  • 1
    You could write either \tag*{\textcolor{red}{(E1)}} (as already suggested by @daleif) or \tag*{\color{red}(E1)}.
    – Mico
    Commented Jul 17, 2019 at 11:28

2 Answers 2

10
\documentclass{article}
\usepackage{amsmath,amssymb}

\usepackage{mathtools}
\usepackage{xcolor}
\newtagform{red}{\color{red}(}{)}
\usetagform{red}
\begin{document}

\begin{align*}
   \color{red} \sum_{n=1}^\infty\dfrac{1}{n^2}=\dfrac{\pi^2}{6}.\tag{E1}
\end{align*}


\end{document}

You can redefine the tag

Hope this helps!

6

CODE with newcommand

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\newcommand{\TAG}[1]{\tag*{\textcolor{red}{(#1)}}}
\begin{document}

This is my favorite equality:
\begin{align*}
    \color{red}\sum_{n=1}^\infty\dfrac{1}{n^2}=\dfrac{\pi^2}{6}.\TAG{E1}
\end{align*}

\end{document}

CODE based on the comments by daleif and Mico

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}

\begin{document}

This is my favorite equality:
\begin{align*}
\color{red}\sum_{n=1}^\infty\dfrac{1}{n^2}=\dfrac{\pi^2}{6}.
\tag*{\textcolor{red}{(E1)}}
\end{align*}

\end{document}
1
  • Approved all the answers and the question.
    – Sebastiano
    Commented Jul 17, 2019 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .