LaTeX forum ⇒ Graphics, Figures & TablesFigure references all have same number Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
adamant
Posts: 3
Joined: Thu Jul 19, 2018 8:25 pm

Figure references all have same number

Postby adamant » Thu Jul 19, 2018 8:34 pm

I have a paper of about 35 pages. It has about 8 figures, which while writing, I embed in the text. For submission the journal wants me to put the figures on separate pages at the end of the text.
When the figures are embedded in the text, the numbering and referencing is correct. When I simply move the lines embedding the figures (see below) to the end of the text, the figures are numbered correctly in the captions under the figures, but all references in the text are to Figure 5. I can see this in the .aux file.

Here is as sample of the lines to insert the figures. [removing \singlespacing makes no difference]

\begin{figure}[p!]
\centering
\includegraphics[width=0.5\textwidth]{ModalValues.pdf}
\singlespacing{ \caption{Modal values of the limit distribution.}
\label{fig:mode}
\end{figure}

adamant
Posts: 3
Joined: Thu Jul 19, 2018 8:25 pm

Postby adamant » Thu Jul 19, 2018 10:18 pm

After several hours of trial and error, I discovered that when the figures are in a separate file (input at the end of the document) or just moved to the end of the document, the \singlespacing to control the layout of the \caption matters.
Removing that got the referencing right. Though at the expense of having double spaced captions.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9106
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Jul 19, 2018 10:45 pm

Hi Adamant,

welcome to the forum!

The command \singlespacing is a simple switch. It switches to single spacing. It is not a command that takes an argument. By using the curly braces, the \caption command got its own local scope, grouped in braces. So it did not step up the figure counter, since the caption command effect stays local within the braces.

This would be different:

  1. \begin{figure}[p!]
  2. \centering
  3. \includegraphics[width=0.5\textwidth]{ModalValues.pdf}
  4. \singlespacing
  5. \caption{Modal values of the limit distribution.
  6. \label{fig:mode}
  7. \end{figure}


Stefan
Site admin

adamant
Posts: 3
Joined: Thu Jul 19, 2018 8:25 pm

Postby adamant » Fri Jul 20, 2018 8:54 am

Thanks for that.
The odd thing is that when the figures were embedded in the text, rather than all put together at the end, that syntax (error) for \singlespacing{\caption{...}} didn't matter---caption still stepped up the counter. Only when the figures were bunched at the end did it matter.
But thanks---that was the problem.

kaiserkarl13
Posts: 599
Joined: Tue Mar 25, 2008 5:02 pm

Postby kaiserkarl13 » Tue Jul 24, 2018 8:43 am

Sorry to reply to a "solved" post, but you might check out the endfloat package, which would satisfy your journal's request without you having to do essentially anything at all with the figures. (Now that you have solved the singlespace scoping problem.)


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests