You can use \\[<negativespace>]
like \\[-2ex]
after the last sub float in the current line.
Some example:
\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htb]
\subfloat[Some figure]{\includegraphics[width=0.48\textwidth]{example-image-a}}\hfill
\subfloat[Some other figure]{\includegraphics[width=0.48\textwidth]{example-image-b}}\\[-2ex] %%<-- in this line
\subfloat[Some more]{\includegraphics[width=0.48\textwidth]{example-image-c}}\hfill
\subfloat[Some less]{\includegraphics[width=0.48\textwidth]{example-image}}
\caption{There are example figures}
\end{figure}
\end{document}
Try
\documentclass[aps,pra,twocolumn,floatfix,footinbib,notitlepage,superscriptaddress,groupaddress,subcaption,caption,showpacs]{revtex4-2}
\usepackage{graphicx}
\usepackage{xcolor}
%\usepackage[caption=false]{subfig}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\section{Introduction}
\label{sec:introduction}
\textcolor{blue}{As Fig.~(\ref{fig1}) and Fig.(\ref{fig2}) show there is a difference between the number of the picture in text and caption}
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig1a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig1b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig1a} subfloat-1 \ref{subfig1b} subflot-2}
\label{fig1}
\end{figure}
Referencing subfigures \ref{subfig1a} and \ref{subfig1b}.
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig2a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig2a} subfloat-1 \ref{subfig2b} subfloat-2}
\label{fig2}
\end{figure}
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig3a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig3b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig3a} subfloat-1 \ref{subfig3b} subfloat-2}
\label{fig3}
\end{figure}
Referencing subfigures \ref{subfig2a}, \ref{subfig2a},\ref{subfig3a} and \ref{subfig3b}, and figures \ref{fig2} and \ref{fig3}.
\lipsum[1-3]
\end{document}
From comparison of above code and your you should observe:
- labels of figures should be after captions
- MWE for your problem can be significantly shorter
- It works also with recent
subcaption
package (version 1.3 or newest)
- You not need to load
graphics
package (it is load by graphicx
).
- Please for images load example-image`s, which available to all
Addendum:
In the cases, that you like to have for example for image in figure, which span bot document columns, than you need to use figure*
float. For example:
\documentclass[aps,pra,twocolumn,floatfix,footinbib,notitlepage,superscriptaddress,groupaddress,subcaption,caption,showpacs]{revtex4-2}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\section{Introduction}
\label{sec:introduction}
\textcolor{blue}{As Fig.~(\ref{fig1}) and Fig.(\ref{fig2}) show there is a difference between the number of the picture in text and caption}
\begin{figure}[!ht]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig1a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig1b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig1a} subfloat-1 \ref{subfig1b} subflot-2}
\label{fig1}
\end{figure}
\lipsum[1]
\begin{figure*}
\setkeys{Gin}{width=0.22\linewidth}
\subfloat[\label{subfig2a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2b}]{\includegraphics{example-image-b}}
\hfill
\subfloat[\label{subfig2c}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2d}]{\includegraphics{example-image-b}}
\caption{caption for subfloats \ref{subfig2a}, \ref{subfig2b},
\ref{subfig2c} and \ref{subfig2d}.}
\label{fig2}
\end{figure*}
\textcolor{blue}{Referencing subfigures \ref{subfig2a}, \ref{subfig2a},\ref{subfig2c} and \ref{subfig2d} in figure \ref{fig2}.}
\lipsum[2-11]
\end{document}
Figure will appear at the top of the next page from point of it insertion.
Best Answer
There are two problems with your code.
Each image has a normal interword space on either side, generated by the endlines inside
\subfloat
and you should watch out for them.Second, the working of
\subfloat
ends with\ignorespaces
, so the endline after the closing brace of the first\subfloat
doesn't generate space between the two parts.You can insert instead
\hfill
so the two images will be pushed to the margins leaving0.1\textwidth
space in the middle. Or you can use\hfil
and you will have three equal spaces, left, center and right.With the help of
showframe
we can see the boundaries of the text block. Choose a style and stick to it.Don't forget the
%
bits in the places I added them.There is a third possibility: setting some margin for the subcaptions.