As explained in Should I use center or centering for figures and tables? \centering
is recommended. It's AFAIK the standard way to do it. The center
environment should not be used because it adds vertical space and is not intended for images. \hfill
is a low-level TeX macro, not a LaTeX macro. It can be used by experienced users to get special behavior but should only be used if required.
Note that you can also center (or right align) images easily using my adjustbox
package. It allows you to add a center
key to \includegraphics
or even turn an image directly into a figure:
\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{mwe}% For example images only
\begin{document}
\blindtext
\begin{figure}
\centering
\includegraphics[width=.8\textwidth]{image}
\caption{Caption (already centered).}
\label{fig:example1}
\end{figure}
\blindtext
\begin{figure}
\includegraphics[width=.8\textwidth,center]{image}
\caption{Caption (already centered).}
\label{fig:example2}
\end{figure}
\blindtext
\adjustimage{width=.8\textwidth,center,caption=[Short Caption]{Long Caption},label=fig:example3,figure}{image}
\blindtext
\end{document}
\hfill
option, so I do not think it is a duplicate – Rainer Sep 12 '12 at 15:10\begin{centering}
is wrong. It's\centering
. The reason why it still compiles is that\begin{foo}
calls\foo
and\end{foo}
calls\endfoo
if it exists. You might have confused it with\begin{center}
, but it should not be used in floats because it is intended for normal texts and therefore adds vertical space. – Martin Scharrer♦ Sep 12 '12 at 15:10@username
(without any spaces, i.e.@MartinScharrer
in my case) to your comments if you answer other comments, so that this user gets notified. The author of the Q or A where the comments are placed under is always notified. – Martin Scharrer♦ Sep 12 '12 at 15:27