LaTeX forum ⇒ Text FormattingUse of Color in Sub-Figure Caption

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
alanaj5
Posts: 3
Joined: Thu Oct 13, 2011 4:57 pm

Use of Color in Sub-Figure Caption

Postby alanaj5 » Thu Oct 13, 2011 5:09 pm

Hi

I wonder if you can help me.
I'm trying to use \textcolor in the caption of a subfigure, but it keeps throwing an error.

!Argument of \@subfloat has an extra }.

Any way to make text appeared coloured in the subfigure caption would be of great help.

I have \usepackage{color} together with
  1. \begin{figure}
  2. \subfigure[Observations \textcolor{red}{$\mathbf{y}_j$}.]{
  3. \includegraphics[scale=0.8]{obs1.png}
  4. }
  5. \subfigure[An estimate \textcolor{blue}{$\mathbf{X}_b$}.]{
  6. \includegraphics[scale=0.8]{background1.png}
  7. }
  8. \end{figure}

If I take out the \textcolor commands, the figures compile perfectly. I also use \textcolor outside of the subfigure captions and that compiles fine for the same colours.

I don't know what I should be using to have coloured text in the caption of a subfigure.

Many thanks for any help.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Thu Oct 13, 2011 5:49 pm

It seems that you use the obsolete subfigure package [1]. To clarify that please submit a minimal example. Nevertheless you should about using one of the suggested alternatives [1]. It's not guaranteed that the problem then will disappear. A code example to look at will be helpful.

[1] View topic: Obsolete packages and document classes — Avoid usage!


Best regards and welcome to the board
Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

alanaj5
Posts: 3
Joined: Thu Oct 13, 2011 4:57 pm

Postby alanaj5 » Thu Oct 13, 2011 6:33 pm

Thanks localghost, I am using the obsolete package subfigure.

I have since changed it to the package \usepackage{subfig} as you suggested and changed all my \subfigure to \subfloat. However I now get an error reading

\renewcommand\@makecaption [2]{%

which was a known error when using beamer http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=389467, which appears to have been fixed. Would I just need to update my packages to ones containing the fix in order to get it to compile correctly?

I read something about needing \usepackage{caption2} as well. Do I need this to fix it?

Thanks for your help.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Thu Oct 13, 2011 6:44 pm

alanaj5 wrote:[…] Would I just need to update my packages to ones containing the fix in order to get it to compile correctly? […]

That is very likely.
alanaj5 wrote:[…] I read something about needing \usepackage{caption2} as well. Do I need this to fix it? […]

This information is wrong. So forget that. Just use the caption package.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

User avatar
sommerfee
Posts: 498
Joined: Mon Apr 09, 2007 4:20 pm

Postby sommerfee » Thu Oct 13, 2011 6:59 pm

alanaj5 wrote:However I now get an error reading

\renewcommand\@makecaption [2]{%


What document class are you using? Are you using the beamer document class or a different one?

alanaj5
Posts: 3
Joined: Thu Oct 13, 2011 4:57 pm

Postby alanaj5 » Fri Oct 14, 2011 9:50 am

I'm using beamer and the beamerposter package.

LexConstantine
Posts: 1
Joined: Fri Aug 23, 2019 5:45 pm

Postby LexConstantine » Fri Aug 23, 2019 5:52 pm

Hi, it may be too late to provide this answer... But I was having this exact issue and figured out that the solution was to protect the caption like so:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \subfigure[Observations \protect\textcolor{red}{$\mathbf{y}_j$}.]{\includegraphics[scale=0.8]{obs1.png}

Hope this helps!


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 12 guests