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]
{./pictures/zadani.jpg}}\sffamily\Huge\centering\ 
    {\sffamily\centering }

I am using TeXmaker.



Answers 2


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,
                 keepaspectratio]{./pictures/zadani.jpg}
\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
Mico
January 14, 2018 02:51 AM

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

\centerline{\includegraphics...}}
Will Robertson
Will Robertson
January 14, 2018 03:17 AM

Related Questions


Arrange multiple TikZ pictures

Updated July 31, 2015 13:10 PM


Trouble with Inserting Graphic

Updated September 28, 2017 05:23 AM


Image aspect ratio changing

Updated January 18, 2018 00:23 AM