LaTeX forum ⇒ LyXCentering image on page

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

Centering image on page

Postby johnny7 » Sun Dec 17, 2017 7:45 pm

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

  1. \setlength{\unitlength}{1cm}
  2. \begin{picture}(15,20)(-0.5,2)
  3. \hbox{\includegraphics[width=15cm]{\string"test\string".jpg}}
  4. \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?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8979
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Dec 18, 2017 5:39 am

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.

How about this way, it's more straightforward:

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


Such overlay pictures require two passes of compiling.

Stefan
Site admin


Return to “LyX”

Who is online

Users browsing this forum: No registered users and 6 guests