# How do I align an image to centre?

How do I align an image to centre?

In a beamer presentation I have a 2-3 items on a slide followed by an image. The image is not wide enough to cover whole slide, so it leaves around 30% space from right. How do I adjust it to leave enough space on both sides?

\begin{frame}
\frametitle{Outlook}
\begin{itemize}
\item apps
\item apps
\item apps
\includegraphics[scale=0.3]{P2P}
\end{itemize}
\end{frame}

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. – Marco Daniel Apr 30 '12 at 20:49

It is enough to use the center enviroment:

\begin{center}
\includegraphics{yourimage}
\end{center}

-
 In general you should use center only with text. It adds vertical space before and after the content, which is not really what you want most the time for images, especially not for floats. See Should I use center or centering for figures? and When should we use \begin{center} instead of \centering?. – Martin Scharrer♦ Apr 30 '12 at 22:41

Here are two ways of achieving this:

\begin{center}
\end{center}


or

\hfill\includegraphics{<your image>}\hspace*{\fill}


The former may add some vertical whitespace, while the latter centers its contents on the line used.

-
Third way \centerline{\includegraphics...}, perhaps you want to add it. Fourth way {\centering \includegraphics...\par} – Yiannis Lazarides Apr 30 '12 at 21:00
I personally think \centerline is just perfect to center single boxes like images. @YiannisLazarides – Martin Scharrer Apr 30 '12 at 22:42

The third way is to use the figure environment, which is the best way in my opinion, since it provides the right mark-up. (beamer centers the figures by default.)

\begin{figure}
\end{figure}


In this case on may also add a caption with \caption{<text>}

-

One simple way to center an image is to use the adjustbox package with the export option. It provides the center=<width> key to \includegraphics, which centers the image around the given width. It defaults to the \linewidth, so use:

\usepackage[export]{adjustbox}
% ....

\includegraphics[scale=0.3,center]{P2P}


Inside a itemize this will center the image relative to the itemize text width, not to the frame.

-