[Tex/LaTex] Change caption name of an appendix

appendicescaptionsfloatsnaming

I want to change the caption name of a figure for an appendix. For example I have

\caption{This is a supplemental figure.}

and by default the caption appears as

Figure 1: This is a supplemental figure.

However I want

Figure S1 - This is a supplemental figure.

I tried this

\renewcommand{\figurename}{Figure S}

but it adds a space in between and results in

Figure S 1 - This is a supplemental figure.

Best Answer

Add this to your document preamble:

\makeatletter
\g@addto@macto\appendix{\renewcommand{\thefigure}{S\arabic{figure}}}
\makeatother

A MWE:

\documentclass{report}

\makeatletter
\g@addto@macro\appendix{\renewcommand{\thefigure}{S\arabic{figure}}\setcounter{figure}{0}}
\makeatother

\begin{document}

\begin{figure}
\caption{Not in Appendix}
\end{figure}

\appendix

\begin{figure}
\caption{In Appendix}
\end{figure}


\end{document}