[Tex/LaTex] Centering with \includegraphics not with \begin{figure}

graphicshorizontal alignment

I mess up with things when I try to use the figure-thing: the picture is not appearing with the correct alignment (apparently because I forget the float package). Now I want to use only the graphicx package with \includegraphics. How can I center the \includegraphics without figure?

Not working or doing centering to the document afterwards.

\includegraphics[width=0.5 \textwidth]{./Pictures/r.png}{\centering}
\includegraphics[width=0.5 \textwidth]{./Pictures/r.png}\centering

Best Answer

Put \includegraphics into a center environment -- this also adds some space before and after your picture.

\documentclass{article}

\usepackage[demo]{graphicx}% "demo" to make example compilable without .png-file

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{center}
\includegraphics[width=0.5\textwidth]{mypicture.png}
\end{center}

\lipsum[1]

\end{document}
Related Question