I'm writing up solutions to a book. The book already has all its contents labeled as Figure 1.5, Equation 2.13 etc. I'd like to label my own figures and equations without suffering any collisions with the main text. For example Figure S-1.5 or Equation S-2.13 might do. Is there a way to do this?

  • 1
    If you use plain \ref (so no cleveref, nameref, autoref etc) then you could just do \newcommand{\myref}[1]{S-\ref{#1}}.
    – Marijn
    Commented Jun 7, 2018 at 9:05
  • But that only relabels the occurrence of Figure 1.5 to Figure S-1.5 in the text, doesn't it? The figure itself will still be titled Figure 1.5. Commented Jun 7, 2018 at 9:14
  • You're right, I didn't think of that - maybe tex.stackexchange.com/questions/305302/… can help you?
    – Marijn
    Commented Jun 7, 2018 at 9:17
  • What do you mean by "my own figures and equations"?
    – Werner
    Commented Jun 7, 2018 at 18:34
  • My solutions contain figures and equations. And sometimes I want to reference an equation in the main text, sometimes I want to reference a figure in my own solutions. I don't want to use the same referencing scheme for both. In case it wasn't clear: I'm not the author of the book. Commented Jun 7, 2018 at 18:38

1 Answer 1


The number that appears in both figure captions and references is determined by the macro\thefigure. It is effectively defined as \arabic{figure} if you are using article, and as \ifnum\value{chapter}>0 \thechapter.\fi\arabic{figure} if you are using book or report. The macro \theequation does the same thing for equations.

You can thus accomplish what you want by prepending S- to the definitions of \thefigure and \theequation, like this:


\usepackage{amsmath} %% <- for \eqref, optional

\let\theequationWithoutS\theequation %% <- store old definition
\let\thefigureWithoutS\thefigure %% <- store old definition

%% Alternative:
% \usepackage{etoolbox}
% \pretocmd{\theequation}{S-}{}{}
% \pretocmd{\thefigure}{S-}{}{}


    \int_{-\pi/2}^{\pi/2} \frac1{1+\cos(x)^{\sin(x)}} \, \mathrm{d}x = \frac\pi2

    \rule{2cm}{2cm} %% black box
    \caption{\label{myfig}This is a figure.}

This sentence contains references to Figure~\ref{myfig} and Equation~\eqref{myeq}.


enter image description here

You must log in to answer this question.

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