# \centering not working in latex

This is my code, but my picture is on the left!!! Can anyone share a better code? thanks a lot

\begin{figure}[H]
\centering
\includegraphics[width=25cm,height=25cm,keepaspectratio]{1.eps}
\caption{Aerial view}\label{fig:1}
\end{figure}

• Almost certainly your picture is too wide for the page Sep 27 '14 at 7:51
• If you do \includegraphics[width=\linewidth]{1} the image will become as wide as the text block. If it looks off-center then, it is likely because of white borders in the image file itself. Sep 27 '14 at 8:27
• @Zay you haven't given much information, but basically before you can centre it you need to make it fit on the page. You haven't said how big your page is, which makes answering difficult. If the image is wider than the text width you need to make the image smaller, make the page wider, or make the image overlap into the margins, all are possible but you have given no indication which you need. centering is not the issue, it wil centre automatically once it fits Sep 27 '14 at 9:05
• Sep 27 '14 at 9:14
• @Zay if you specify 10cm it will centre with the commands you show. As I comment above the only issue in the code you posted is that the image is so wide. Incidentally it's best not to include the .eps extension then it will work with pdflatex as well as latex if you have a pdf version of the image Sep 27 '14 at 9:18

\centering will not centre anything that is wider than the page (as is the case with an image scaled to 25cm wide) all excess width will stick into the right margin (and TeX will issue overfill box warnings). The code shown will centre the image if it was scaled to a smaller width.
• @HiI'mfrogatto just hide the width for example \makebox[0pt]{\includegraphics{..}} has width 0pt with the image centred in it, so if you centre that, the image will stick into both margins Nov 8 '15 at 19:41