0

Caption of the following figure is coming Figure 1: abc

\begin{figure}[!h]
\centering
\includegraphics[width=12cm]{Fig.jpg}
\caption{abcd}
\label{fig}
\end{figure}

I want to change caption as Figure S1: abc

1
  • What packages are you loading, what is your document class? More information is required to be able to answer this, please extend your code in your question
    – JamesT
    Feb 26, 2023 at 13:35

2 Answers 2

1

I completed your code to an MWE (please always do that yourself). Your goal can be achieved by the following:

\documentclass{report}
\usepackage{graphicx}
\begin{document}
   \let\oldthefigure\thefigure % Store old \thefigure-command.
   \renewcommand{\thefigure}{S\oldthefigure}  % Create new \thefigure-command by prepending an "S".
   \begin{figure}[!h]
      \centering
      \includegraphics[width=12cm]{example-image-duck}
      \caption{abcd}
      \label{fig}
   \end{figure}
   See Figure~\ref{fig}.
\end{document}

enter image description here

1

If you load the caption package, you can make adjustments to captions with \captionsetup. How you want the changes depends on where you put this macro. If you want all captions in figures to be changed, add the lines in your preamble

\DeclareCaptionLabelFormat{<<the name>>}{#1 S#2}
\captionsetup[figure]{labelformat=<<the name>>}

However, if you want only a selected figure to be affected, keep \DeclareCaptionLabelFormat in the preamble and add the other command in the figure environment without optional argument

\captionsetup{labelformat=<<the name>>}

The full code with global settings:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}

\DeclareCaptionLabelFormat{labelwiths}{#1 S#2}
\captionsetup[figure]{labelformat=labelwiths}


\begin{document}
\begin{figure}[!h]
  \centering
  \includegraphics[width=12cm]{Fig.jpg}
  \caption{abcd}
  \label{fig}
\end{figure}

\begin{figure}[!h]
  \centering
  \includegraphics[width=12cm]{Fig.jpg}
  \caption{Sample sample sample}
  \label{fig}
\end{figure}
\end{document}

enter image description here

You must log in to answer this question.

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