0

I am writing thesis in latex and in one chapter figure labels in the text are not coming right even after labelling figures correctly.

\begin{figure*}
\vspace{0.8cm}
\begin{center}
\resizebox{0.465\textwidth}{!}{\includegraphics{eos9.eps}}
\hspace{0.15cm}
\resizebox{0.45\textwidth}{!}{\includegraphics{mrgw170817.eps}}
\caption{\small{Pressure versus energy density is plotted  for different compositions (left panel)
and mass-radius relation is exhibited for those equations of state  
(right panel) \cite{gw17}}.}
\end{center}
\label{fig:4a}
\end{figure*}

This is first figure in my chapter. It contains two figures together. When I use its label in text e.g....\ref{fig:4a}, I get ...4.2.

But I should get 4.1 because it is first figure of Chapter 4

5
  • 3
    Welcome to TeX SX! Could you please post a small comilable code reproducing the problem?
    – Bernard
    Mar 2, 2020 at 19:24
  • 5
    no one can answer the question in that form. you need to say what input you made, what output you got and what output you intended Mar 2, 2020 at 19:25
  • Welcome to TeX-SE. Please consider reading the advices in I've just been asked to write a minimal working example (MWE), what is that?. Reduce your code into the Minimum Example that's Works and still reproduces your error.
    – FHZ
    Mar 2, 2020 at 19:43
  • The label goes right after the caption. Here the center env is shielding the figure data so the label cannot get to it.
    – daleif
    Mar 2, 2020 at 21:33
  • Unrelated: don't use the center env here it introduces unwanted extra vertical space. Secondly, \small is a switch, it does not take arguments, additionally sizing like that does not belong in the caption. Captions should be configured globally, here you're just wasting your time
    – daleif
    Mar 2, 2020 at 21:36

1 Answer 1

3
  • For reproduce your problem, we need to see MWE (Minimal Working Exampe), a small complete, compilable document as it is (beginning with\documentclass{...} and ending with \end{document}.
  • Providing only fragment of code, as you do, doesn't gives information of used document class, necessary packages in document preamble, which can (mostly do) influence on your problem.
  • Regarding your code fragment:
    • it is unnecessary complicated
    • for determine size of images serve graphicx option width
    • for centering is better to use \centering command (placed after \begin{figure} (it not introduce additional vertical space as environment center does)
    • the figure label is best to be immediately after caption
  • Based on guessing about your document, the an MWE, which solve your problem, can be as follows:
\documentclass{book}
\usepackage[demo]{graphicx}
\usepackage[font=small]{caption}

\usepackage{lipsum} % for dummy text filler
\setcounter{chapter}{3}
\begin{document}
\chapter{title}
\lipsum[11]

\begin{figure*}[htb]
\centering
\includegraphics[width=0.45\linewidth]{eos9}
\hfil
\includegraphics[width=0.45\linewidth]{mrgw170817}
    \caption{Pressure versus energy density is plotted  for different compositions (left panel) and mass-radius relation is exhibited for those equations of state (right panel) \cite{gw17}.}
\label{fig:4a}
    \end{figure*}
see \ref{fig:4a} ...
\end{document}

enter image description here

You must log in to answer this question.

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