# Center included pdf graphic

I'm having trouble to center some graphics (in pdf format) I'm including in a latex document.

I've tried with

\begin{center}
\includegraphics{mygraph.pdf}
\end{center}


and

\begin{figure}
\centering
\includegraphics{mygraph.pdf}
\end{figure}


Both giving me the same output: a graph departing significantly to the right and eating a bit of the right margin.

illustration of the result:

This is not from the original pdf file, in which the graph is perfectly cantered as it has no margins or blanks on the side.

What could I do to center it better?

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – yo' Nov 5 '14 at 10:56
• Make it \centering instead of \center. And what is \begin{caption}? – user11232 Nov 5 '14 at 11:01
• @HarishKumar : Sorry, just edited my post. I did not go back to my document to write it but used (faulting) memory: it's begin{figure} that I tried and indeed \centering without success. – Decaying Nov 5 '14 at 11:12
• @Decaying, are you sure the image behaves? That is does not add excessive white space around it self? try using \fbox{\includegraphics...} to visually show where the boundaries of the image. – daleif Nov 5 '14 at 11:55
• you just need to scale the image to be smaller, if it is bigger than the textwidth the excess space always comes from eh right margin (and TeX will complain about overfull hbox in the log) see the answer already posted. – David Carlisle Nov 5 '14 at 13:04

Here's one approach:

\documentclass{article}
\usepackage{mwe}
\begin{document}

\begin{figure}
\centering
\includegraphics[width=.4\linewidth]{example-image-b}
\end{figure}

\end{document}


This produces:

• I changed \hfil to \centering (as the former doesn't work, space is ignored at the start of a line) – David Carlisle Nov 5 '14 at 13:06