Center two images using multiple \hfills
An extra \hfill
will do it. Also, \centering
not needed in this case. And, technically speaking, one should end lines with %
signs, in order to avoid the insertion of small spaces.
\documentclass{article}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{float}
\usepackage{mwe}
\begin{document}
\blindtext
\begin{figure}[H]
%\centering
\hfill%
\includegraphics[width=4cm]{example-image-a}%
\hfill%
\includegraphics[width=4cm]{example-image-a}%
\hfill%
\hfill%
\end{figure}
\blindtext
\end{document}
Alternately (and more naturally), \hfil
all around will do it with a single. However, in this case, \centering
cannot be used, without the addition of an \hfilneg
(negative infinite glue) at the beginning of the line (or else added asymmetric \hfil
s).
\documentclass{article}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{float}
\usepackage{mwe}
\begin{document}
\blindtext
\begin{figure}[H]
%\centering\hfilneg
\hfil%
\includegraphics[width=4cm]{example-image-a}%
\hfil%
\includegraphics[width=4cm]{example-image-a}%
\hfil%
\end{figure}
\blindtext
\end{document}
Alternatively with \centering
and \hfil
between images:
\documentclass{article}
\usepackage{graphicx}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{figure}[htb]
\centering
\includegraphics[width=4cm]{example-image-a}
\hfil
\includegraphics[width=4cm]{example-image-b}
\end{figure}
\blindtext
\end{document}