Math & ScienceProblem with Summation and colours

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
gfink
Posts: 3
Joined: Mon May 30, 2011 11:18 pm

Problem with Summation and colours

Post by gfink »

Hi, I am trying to display a summation with different colours.
I have defined something like

Code: Select all

\newcommand{\a}[1]{\color{blue}#1\color{black}}
\newcommand{\b}[1]P\color{red}#1\color{black}}
Throughout my document when I want a red varible or blue varible I put

Code: Select all

$x = \a{b} + \b{r}$
But when I want an equation with a summation as in

Code: Select all

\begin{equation}\sum\limits^{\a{b}}_{\b{r}}\end{equation}
It wont put the r below the summation sign.
Any ideas?
Thanks!
Geoff
Last edited by gfink on Tue May 31, 2011 12:14 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with Summation and colours

Post by localghost »

An example derived from the »Math mode« document.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}

\newcommand*{\tcb}[1]{\textcolor{blue}{#1}}
\newcommand*{\tcr}[1]{\textcolor{red}{#1}}

\begin{document}
  \begin{equation}
    \sum^{\tcb{b}}_{\tcr{r}}
  \end{equation}
\end{document}

Thorsten
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Problem with Summation and colours

Post by Stefan Kottwitz »

Hi Geoff,

I can confirm that it already works when you use \textcolor instead of \color, such as

Code: Select all

\newcommand{\a}[1]{\textcolor{blue}{#1}}
\newcommand{\b}[1]{\textcolor{red}{#1}}
Stefan
LaTeX.org admin
gfink
Posts: 3
Joined: Mon May 30, 2011 11:18 pm

Re: Problem with Summation and colours

Post by gfink »

Thanks for the fast response!
It's working for me now too :)
Post Reply