Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  Marco Daniel Apr 30 '12 at 20:49

6 Answers 6

up vote 9 down vote accepted

It is enough to use the center enviroment:

\begin{center}
    \includegraphics{yourimage}
\end{center}
share|improve this answer
1  
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
    
@MartinScharrer thanks for the clarification :) –  Edo May 30 at 12:33

Here are two ways of achieving this:

\begin{center}
  \includegraphics{<your image>}
\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.

share|improve this answer
3  
Third way \centerline{\includegraphics...}, perhaps you want to add it. Fourth way {\centering \includegraphics...\par} –  Yiannis Lazarides Apr 30 '12 at 21:00
1  
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}
   \includegraphics{<your image>}
\end{figure}

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

share|improve this answer

You could also do something like this:

\begin{figure}[!h]
    \caption{My caption}
    \centering
    \includegraphics[width=50mm]{theImage}
    \label{fig:label}
\end{figure}
share|improve this answer

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.

share|improve this answer

I always use:

\begin{center}
  \includegraphics[width=\textwidth]{image}
\end{center}

That's almost perfect for raw screenshots, as images will not overflow the visible content.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.