Color part of text and captions

is it possible to color in red part of a text and/or of a caption (let's say, just some words)?

I tried to create the environment:

\newenvironment{redtext}{\color{red}}{\ignorespacesafterend}


following this reference. However, it cannot be used for captions.

Thank you.

-
Which class file are you used minimal or article and could you please post MWE. –  Balaji Sep 4 '13 at 9:37

For captions you can use the interface provided by the »caption« package. Have a look at this approach derived from Section 4 of the package manual.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{xcolor}

\DeclareCaptionFont{red}{\color{red!50!black}}
\DeclareCaptionFont{green}{\color{green!50!black}}
\captionsetup{
labelfont={bf,red},
textfont={green}
}

\begin{document}
\begin{figure}[!htb]
\centering
\rule{8cm}{4.5cm}
\caption{Dummy figure}
\end{figure}
\end{document}


It should be no big deal to apply that in your document.

Update

For only parts of the caption you can use the \textcolor command. It's suggestive to define a new command in this case.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}

\begin{document}
\begin{figure}[!htb]
\centering
\rule{8cm}{4.5cm}
\end{figure}
\end{document}


-
What if I have to color just part of a caption (let's say, some words)? I think the method you are proposing is coloring the whole caption. –  Eleanore Sep 4 '13 at 9:45
@Eleanore: Then you can simply use \textcolor{red}{Colored text} as described in Section 2.6 of the »xcolor« manual. Somehow I must have misinterpreted your question. –  Thorsten Donig Sep 4 '13 at 9:48