LyXCentering image on page

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

Centering image on page

Post by johnny7 »

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 ... esentation

Code: Select all

\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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Centering image on page

Post by Stefan Kottwitz »

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:

Code: Select all

\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
LaTeX.org admin
Post Reply