Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

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

1 Answer 1

up vote 8 down vote accepted

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.


enter image description here


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}

\newcommand{\alert}[1]{\textcolor{red}{#1}}

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

enter image description here

share|improve this answer
    
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
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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