2

By adding the following package with parameters, all captions for tables, figures etc. change color, font-size and distance between label and text:

%Caption formatting
\usepackage[font={color=red,footnotesize},labelsep=quad,width=.75\textwidth]{caption}

If I still want the text to be black and only the "Figure 1" label to change color, then I simply set it back to black manually in every caption at the moment:

\caption{\color{black} test caption text }

The result is perfect:

enter image description here

but can I make these different colors automatic along with the package parameters in the preamble so I don't have to add \color{black} in every single caption?


A code example:

\documentclass[11pt,a4paper]{article}

\usepackage[utf8x]{inputenc}    %Character set
\usepackage{graphicx}           %Figures 
\usepackage{caption}            %Main caption for subfigures
...

%Caption formatting
\usepackage[font={color=red,footnotesize},labelsep=quad,width=.75\textwidth]{caption}

\begin{document}

\begin{figure}[p]
    \centering
    \includegraphics[width=0.8\textwidth]{image.png}
    \caption{Test caption text}
    \label{fig:test}
\end{figure}

\end{document}
  • 1
    It would really nice to post minimal but compilabel examples. It saves a lot of time for a helper to write an answer. – Johannes_B Jun 17 '15 at 12:11
3

Use labelfont to control the font of the label. You can also use captionsetup to treat figures and tables (and all compaitble self-defined floats) differently.

steevenCaptionFont

\documentclass{article}
\usepackage[font={color=red,footnotesize},labelsep=quad,width=.75\textwidth,labelfont={color=blue}]{caption}
\captionsetup[table]{labelfont={color=blue},font={color=green!50!black}}
\usepackage{xcolor}
\begin{document}
    \captionof{figure}{Buzy bee}
    \captionof{table}{pogo penguin}
\end{document}
  • Johannes, you solve all my questions today. Thank you very much. This works: \usepackage[font=footnotesize,labelfont={color=red},labelsep=quad,width=.75\textwidth]{caption} – Steeven Jun 17 '15 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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