Graphics, Figures & TablesChange name of figures, delete spacing

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Angelika
Posts: 4
Joined: Sat Oct 01, 2022 3:58 pm

Change name of figures, delete spacing

Post by Angelika »

Heyho!

I'd be very happy if someone of you could help me with two little problems:
I need to change the naming of figures from "Figure x" to "Figure Sx".
What I have done so far is to use \renewcommand:
\renewcommand{\figurename}{Figure~S}
This gives "Figure S x". How can I get rid of the spacing?
Moreover, when I reference the figure, I write
Figure~S\ref{fig:"LABEL"}
The result there also gives an unwanted spacing "Figure S x".
Thank you already very much in advance!

Cheers.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Change name of figures, delete spacing

Post by Bartman »

Without a Infominimal working example one could only try to guess.

Changing the \thefigure command may help. The type of customization depends, for example, on whether your class supports chapters or not.

Using the hyperref or cleveref package you can add the type of the cross-reference.
Angelika
Posts: 4
Joined: Sat Oct 01, 2022 3:58 pm

Change name of figures, delete spacing

Post by Angelika »

Minimum working example:

Code: Select all

\documentclass[journal=jacsat,manuscript=article,demo]{achemso}
\title
   {Title}
\begin{document}
\renewcommand{\figurename}{Figure~S}
\renewcommand{\theequation}{S\arabic{equation}}
\begin{figure}
    \centering
    \includegraphics{FigureS1.png}
    \caption{Figure caption}
    \label{fig:potential1}
\end{figure}
\end{document}
Last edited by Angelika on Sun Oct 02, 2022 12:10 pm, edited 3 times in total.
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Change name of figures, delete spacing

Post by Bartman »

Please use the forum editor's code tags to mark the code and allow testing.

Changing \theequation shows you the way, you just have to adjust it for \thefigure.
Angelika
Posts: 4
Joined: Sat Oct 01, 2022 3:58 pm

Change name of figures, delete spacing

Post by Angelika »

Thanks for the advice! Unfortunately it gives me twice the number now, the first without spacing, the second with spacing.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Change name of figures, delete spacing

Post by Stefan Kottwitz »

Then don't use both ;-) remove \renewcommand{\figurename}{Figure~S} or just use \renewcommand{\figurename}{Figure} if you need "figure" caoitalized.

Stefan
LaTeX.org admin
User avatar
MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Change name of figures, delete spacing

Post by MjK »

Code: Select all

\documentclass[journal=jacsat,manuscript=article,demo]{achemso}
\renewcommand{\thefigure}{S\arabic{figure}}
\renewcommand{\theequation}{S\arabic{equation}}
\title   {Title}
\begin{document}
\begin{figure}
    \centering
    \includegraphics{FigureS1.png}
    \caption{Figure caption}
    \label{fig:potential1}
\end{figure}
See Figure~\ref{fig:potential1}.
\end{document}
Should do it.

This would also work using hyperref:

Code: Select all

\documentclass[journal=jacsat,manuscript=article,demo]{achemso}
\renewcommand{\thefigure}{S\arabic{figure}}
\renewcommand{\theequation}{S\arabic{equation}}
\usepackage{hyperref}
\title   {Title}
\begin{document}
\begin{figure}
    \centering
    \includegraphics{FigureS1.png}
    \caption{Figure caption}
    \label{fig:potential1}
\end{figure}
See \autoref{fig:potential1}.
\end{document}
BTW: Adding S to every figure number looks strange and useless. But if you like so …
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
Angelika
Posts: 4
Joined: Sat Oct 01, 2022 3:58 pm

Change name of figures, delete spacing

Post by Angelika »

:lol: Oh! Now, I see. Stupid me! Thanks a lot! :D
Post Reply