8

We are using the below definition to get the figure numberings automatically

\renewcommand\thefigure{\@arabic\c@figure}
\def\fnum@figure{\figurename~\thefigure}

The output is as shown below:

Figure 1. Caption

But, we need to insert the text "(Online color)" after figure number as shown below:

Figure 1 (Online color). Caption

To achieve this I again redefining the command

\def\fnum@figure{\figurename~\thefigure (Online color)}

which again I have to reset for the next captions.

Could anyone suggest how to get this automatically?

user38642
  • 315

2 Answers2

5

This should get you started. I have defined a new environment myfigure. If you want

Figure 1 (Online color). Caption

use myfigure or else use figure.

A sample code:

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}
\DeclareCaptionFormat{myformat}{#1 (Online color)#2#3}
\newenvironment{myfigure}%
{\captionsetup{format=myformat,labelsep=period}
\figure
}%
{\endfigure}%
\begin{document}
\listoffigures
  \begin{myfigure}[htb]
    \centering
    \includegraphics[width=4cm]{example-image-a}
    \caption[myfig1]{my caption here}
  \end{myfigure}

  \begin{figure}[htb]
    \centering
    \includegraphics[width=4cm]{example-image-b}
    \caption[myfig2]{my caption here}
  \end{figure}
\end{document}

enter image description here

Further adjustments are left as assignment. For details refer to caption manual.

4

Here a different solution with no need for additional packages.

Simply issue the command \onlinecap inside those figure environments where you want the modified caption.

MWE:

\documentclass{article}

\makeatletter
\renewcommand\thefigure{\@arabic\c@figure}
\renewcommand\fnum@figure{\figurename~\thefigure}
\newcommand\onlinecap{\renewcommand\fnum@figure{\figurename~\thefigure~(Online color)}}
\makeatother

\begin{document}

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

\begin{figure}[htbp]
  \onlinecap
  \caption{B}
\end{figure}

\begin{figure}[htbp]
  \caption{C}
\end{figure}

\end{document} 

Output:

enter image description here

Just in case you have figures with multiple captions, you might need a command to nullify the effect of \onlinecap for a subsequent caption. In this case you might also insert between \makeatletter and \makeatother another line which defines a command \offlinecap for this purpose:

\newcommand\offlinecap{\renewcommand\fnum@figure{\figurename~\thefigure}}
karlkoeller
  • 124,410
  • 1
    Probably also an \offlinecap command should be provided, in case a figure environment has two captions, only the first of which has the addition. – egreg Feb 11 '14 at 11:46
  • @egreg Thanks for the suggestion. Added in the answer. – karlkoeller Feb 11 '14 at 12:17