3

I'm using the xcolor package, and for changing the color of any selected of any figure or table in the document I use.

\captionsetup[figure]{labelfont={color=blue},font={color=blue}}

but this did not work with the table!

Any suggestion would be highly appreciated.

Here is a sample of the code of the table where the caption color needed to be changed (caption:label and description).

\captionsetup[table]{labelfont={color=blue},font={color=blue}}
\begin{table}[!ht]
\caption{Caption of the table \label{table:test table}}
\end{table}
\clearcaptionsetup{table}
mhdella
  • 289

1 Answers1

5

From what I can understand, you want figure captions to be blue, but table captions generally black, with an occasional table caption blue.

\documentclass{article}
\usepackage{caption}
\usepackage{xcolor}

\captionsetup[figure]{labelfont={color=blue},font={color=blue}}

\begin{document}

\begin{figure}[htp]
\caption{A figure}
\end{figure}

\begin{figure}[htp]
\caption{A figure}
\end{figure}

\begin{table}[htp]
\caption{A table}
\end{table}

\begin{table}[htp]
\captionsetup{labelfont={color=blue},font={color=blue}}
\caption{A table}
\end{table}

\begin{table}[htp]
\caption{A table}
\end{table}

\end{document}

enter image description here

If you want all captions to be blue, use

\captionsetup{labelfont={color=blue},font={color=blue}}

However, note that pure colors should not be generally used. Possibly better is doing \colorlet{mildblue}{blue!80!green} and changing all blue into mildblue.

Production note. The picture was produced with \setcounter{totalnumber}{100} so LaTeX allows more than three floats in a page.

egreg
  • 1,121,712
  • Thanks egreg, I have used your code sample and it works but with other document class (rather than article) it is not work with the journal template that I am working on! An occasional Table caption did not change its color in that class of document! – mhdella Jan 28 '18 at 00:23
  • @mhdella Without a full example with the class you use it's not easy to help more. – egreg Jan 28 '18 at 00:30
  • documentclass{cta-author} this is the class I am using for Elsevier journal and I don't know how to upload it here! – mhdella Jan 28 '18 at 00:32
  • @mhdella If you use a class for a journal submission, why are you changing their setup? – egreg Jan 28 '18 at 00:35
  • Good question, for the second revision draft... I have to make some parts with another color to show the reviewers that the corrections have taken a place. – mhdella Jan 28 '18 at 00:36
  • @mhdella Sorry, but, again, without a minimal example and a pointer to where the class can be examined, it's impossible to say more. – egreg Jan 28 '18 at 00:49
  • Here is the link of a compressed zip folder that has the template file of the document class which its name is: cta-author.cls. I hope you can use it in your code example and find a way to change the color of an occasional table caption as you did with article class document. http://digital-library.theiet.org/files/IET_Author-doublecolumn-submission.zip – mhdella Jan 28 '18 at 04:44