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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10360
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