## LaTeX forum ⇒ LyX ⇒ Centering image on page

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
johnny7
Posts: 18
Joined: Fri Oct 24, 2014 12:25 pm

### Centering image on page

For now I've got enough of this random \vspace*{\fill} so I looked for another solution. I found one here: https://tex.stackexchange.com/questions/32661/how-to-locate-figures-with-x-y-specified-location-in-a-presentation

\setlength{\unitlength}{1cm}\begin{picture}(15,20)(-0.5,2)\hbox{\includegraphics[width=15cm]{\string"test\string".jpg}}\end{picture}

I still don't really understand these four numbers, I just tried around a lot. Now it's nearly in the center of the page. Does anyone care to calculate the numbers I have to insert to move an image of 15x20cm in the center of the page?

Stefan Kottwitz
Posts: 9372
Joined: Mon Mar 10, 2008 9:44 pm
Well, the first two numbers are the picture dimensions (width and height) and the other to numbers the coordinates of the bottom left corner of the image, and all are factors of \unitlength, the value you set to 1 cm.

\documentclass{article}\usepackage{tikz}\begin{document}\begin{tikzpicture}[remember picture, overlay]  \draw node at (current page.center) {\includegraphics{filename}};\end{tikzpicture}\end{document}

Such overlay pictures require two passes of compiling.

Stefan