# How to force an image to be centered?

by Jan Pisl   Last Updated January 14, 2018 03:23 AM

I cannot make an image to be centered no matter what I do. I have searched through similar questions but did not find any useful answers for this case.

I get this when compiling even though the image itself is perfectly centered.

This is the command I use (I am using a template file)

\stranka{}%
{\includegraphics[scale=0.45]
{\sffamily\centering }


I am using TeXmaker.

Tags :

By all means, do get rid of the \stranka "wrapper" and use the following code instead:

\begin{figure}[p!]
\centering
\includegraphics[width=\linewidth, height=\textheight,
\end{figure}


Encasing the graphic in a figure environment and using the p placement specifier ensures that it'll be placed on a page by itself. (Incidentally, absent further information, I can see no good reason for running \thispagestyle{empty}.)

Mico
January 14, 2018 02:51 AM

To centre an image that is larger than the textwidth, write

\centerline{\includegraphics...}}

Will Robertson
January 14, 2018 03:17 AM