3

I am trying to colour the figure caption of my report and also change the label separator from

Figure 1: This is a figure.

to

Figure 1 - This is a figure.

So far I had success changing the colour of the caption, however, when changing the

-

remains black. How can I achieve that everything is the same colour?

My MWE is the following:

\documentclass[12pt,twoside,titlepage]{article}

\usepackage{float}
\usepackage[table]{xcolor} 
\usepackage{graphicx} 
\usepackage[labelfont={color=gray!50,md},textfont={color=gray!50,md},labelsep=endash]{caption}

\begin{document}

 \begin{figure}[H]
          \centering
    \includegraphics[width=\textwidth]{fig1.jpg}
  \caption{This is a Figure.}
  \label{fig:fig1}
  \end{figure}

 \end{document}

1 Answer 1

2

You could use the \DeclareCaptionLabelSeparator command in order to define your own colored variant of endash and use the \captionsetup command in order to use this separator:

enter image description here

\documentclass[12pt,twoside,titlepage]{article}

\usepackage[table]{xcolor} 
\usepackage{graphicx} 
\usepackage{caption}

\DeclareCaptionLabelSeparator{myendash}{ \textcolor{gray!50}{\space\textendash\space}}
\captionsetup{labelfont={color=gray!50,md},textfont={color=gray!50,md},labelsep=myendash}

\begin{document}

\begin{figure}
  \caption{This is a Figure.}
  \label{fig:fig1}
\end{figure}

\end{document}
1
  • 1
    Just \DeclareCaptionLabelSeparator{myendash}{\space\textendash\space} should be sufficient. (The original definition of endash uses the starred variant \DeclareCaptionLabelSeparator* to define the label separator, therefore it does not use the label font.)
    – user2574
    Jul 10, 2018 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .