7

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.

  • 1
    You could use \tag* and add the () manually to it – daleif Jul 17 '19 at 11:18
  • 1
    You could write either \tag*{\textcolor{red}{(E1)}} (as already suggested by @daleif) or \tag*{\color{red}(E1)}. – Mico Jul 17 '19 at 11:28
9
\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!

| improve this answer | |
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}
| improve this answer | |
  • Approved all the answers and the question. – Sebastiano Jul 17 '19 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.