0

So I have my figures labeled as "Figure section.figurenumber", meaning each caption starts with, say, "Figure 1.1", "Figure 1.2", and "Figure 2.1" if in sections 1 and 2, respectively. I've accomplished this by putting the following in my preamble:

\renewcommand{\thesubfigure}{Figure \arabic{section}.\arabic{subfigure}}

The reason I'm using subfigures is to be able to have figures side-by-side on a page. Anyway, when I reference these figures in the actual text, like, "please see figures \ref{label1} and \ref{label2}," the actual output is "please see figures Figure 1.1 and Figure 1.2".

How can I maintain the word "Figure" in my caption but suppress it when referencing the figure in the text?

Here is a minimal working example:

\documentclass{article}

\usepackage{graphicx, caption}
\usepackage{float} %Needed for the [H] after \begin{figure}.  [H] stands for "Here", 
i.e., the figures appear in the PDF in the same location as in the TeX code.

\usepackage[labelformat=simple]{subcaption}

\renewcommand{\thesubfigure}{Figure \arabic{section}.\arabic{subfigure}}

\begin{document}
\section{First section}
\section{Second section}
    \begin{figure}[H]
    \centering
    \begin{subfigure}[t]{.45\textwidth}
    \begin{center} \includegraphics[scale=0.2]{stars.jpeg} \end{center}
    \caption{A picture of the past.}
    \label{fig:stars}
    \end{subfigure}
    ~~~
    \begin{subfigure}[t]{.45\textwidth}
    \begin{center} \includegraphics[scale=0.2]{monkeys.jpeg} \end{center}
    \caption{Humans not too long ago.}
    \label{fig:primates}
    \end{subfigure}
    ~~~
    \begin{subfigure}[t]{.42\textwidth}
    \begin{center} \includegraphics[scale=0.16]{lion.jpeg} \end{center}
    \caption{Not today Satan.}
    \label{fig:predator}
    \end{subfigure}
    ~~~
    \begin{subfigure}[t]{.42\textwidth}
    \begin{center} \includegraphics[scale=0.16]{blueberry.jpeg} \end{center}
    \caption{Is this a blueberry-topped cupcake, or just a cup of blueberries?.}
    \label{fig:enigma}
    \end{subfigure}
    ~~~
\end{figure}
As we can see in figures \subref{fig:stars} and \subref{fig:enigma}, I'm not very good at making a minimal working example.
\end{document}

And this gives the output:

enter image description here

13
  • 3
    AFAIK the thexxx command should never feature the name of the float they refer to.
    – Moriambar
    Jul 1, 2017 at 18:21
  • @Moriambar Sorry, but what is 'thexxx' command?
    – layman
    Jul 1, 2017 at 18:22
  • 3
    \caption should do this ... for more, you should provide MWE.
    – Zarko
    Jul 1, 2017 at 18:26
  • 3
    show the code, that we can see what is going on. if this is case, then you have something exceptional or we don't understand each other. so, again, provide MWE.
    – Zarko
    Jul 1, 2017 at 18:28
  • 1
    why would you want to number your subfigures as section.subfigure without mentioning the figure number? isn't that going to be confusing for the reader. It is very hard for anyone to suggest how to fix your code if you do not show it. Please show a small complete document that shows the subfigure definition you are using Jul 1, 2017 at 18:57

1 Answer 1

2

From the comments it seems that you do not what subfigures at all but something like

enter image description here

\documentclass{article}

\renewcommand\thefigure{\thesection.\arabic{figure}}

\usepackage{graphicx}
\begin{document}

\section{Zzzzzz}

\begin{figure}[htp]
  \begin{minipage}[t]{.33\linewidth}
    \centering
     \includegraphics[width=.7\linewidth]{example-image-a}
     \caption{Zzzzz\label{zza}}
  \end{minipage}\hfill
  \begin{minipage}[t]{.33\linewidth}
    \centering
     \includegraphics[width=.7\linewidth]{example-image}
     \caption{Zzzzz zzz\label{zzb}}  
  \end{minipage}\hfill
  \begin{minipage}[t]{.33\linewidth}
        \centering
     \includegraphics[width=.7\linewidth]{example-image-b}
     \caption{Zzzzz zzzzzz\label{zzc}}
  \end{minipage}
\end{figure}

See figures \ref{zza} to \ref{zzc}
\end{document}
8
  • That's exactly what I want, and you posted this 2 minutes before I finished painstakingly putting together a minimal working example. Thanks for your answer. I'll read through it now.
    – layman
    Jul 1, 2017 at 19:37
  • @user46944 ah well I've done this before:-) Jul 1, 2017 at 19:39
  • So you basically used minipage, and TeX put in the word "Figure" automatically. Do you know if your solution will work across multiple pages? For example, if I have so many figures that they span multiple pages. I think I had a problem with this in the past.
    – layman
    Jul 1, 2017 at 19:43
  • 1
    @user46944 the figure environment never spans more than one page. Jul 1, 2017 at 19:44
  • So do I just create a new figure environment for the next page? Will the numbering carry on as expected?
    – layman
    Jul 1, 2017 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.