# Colored “sum” in display math mode

The line

$\textcolor{green}{\sum}_{k=0}^n$


makes the k=0 and n parts go to the right of Sigma instead of at the top and bottom, as it should be. Can we retain k=0 and n at the top and bottom?

-
If you often use color in math-mode you may be interested in \mathcolor (avoids problems with spacing): Colored symbols – Qrrbrbirlbel Mar 2 '13 at 21:50

The \textcolor macro will undo the operator status of \sum so that both subscript and superscript are placed like they would at an ordinary symbol.

The macro \mathop makes the whole sequence (the green sum symbol) an operator again.

When you often use colored operator symbols, define a new macro, say

\newcommand*{\opcolor}[2]{\mathop{\textcolor{#1}{#2}}}


and use it as \opcolor{green}{\sum}.

I have also defined a \csum macro based on \opcolor.

## Code

\documentclass{article}
\usepackage{xcolor}
\newcommand*{\opcolor}[2]{\mathop{\textcolor{#1}{#2}}}
\newcommand*{\csum}[1]{\opcolor{#1}\sum}

\begin{document}
$\mathop{\textcolor{green}{\sum}}_{k=0}^n$

$\csum{green}_{k=0}^n$

$\opcolor{green}{\sum}_{k=0}^n$
\end{document}


## Output

-

Declare the green symbol as an operator via \mathop.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\begin{document}
$\mathop{\textcolor{green}{\sum}}_{k=0}^n$
\end{document}

-