Graphics, Figures & Tablespicture centered vertically

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
modenese
Posts: 1
Joined: Sat Apr 10, 2010 2:32 pm

picture centered vertically

Post by modenese »

Hi all,

I am a new user and I am trying to include my first picture in a latex document. I have coded something like this:

Code: Select all

\begin{figure}[lineheight]
  \vspace{-20pt}
  \centering
    \includegraphics[scale=0.45]{JKR.eps}
  \vspace{-20pt}
  \caption{JKR theory versus Hertz theory}
  \label{fig:JKR}
  \vspace{-10pt}
\end{figure}
The problem is that whatever I set the parameters you see in the code above, I always obtain my picture placed in the center of the page (vertically, I mean).
How can I avoid that? I want the picture in the center but only horizontally.

Thanks for your help (sorry if the question is too basic).

Regards,
Chiara
Last edited by modenese on Tue Apr 13, 2010 2:59 pm, edited 1 time in total.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

picture centered vertically

Post by localghost »

At first, the figure environment only accepts certain placement parameters, not what you inserted. For your purpose you have to modify an internal register to get your float placed on top of a page in case that the page only contains this float [1]. (It is then call a float page.)

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{graphicx}

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

\begin {document}
  \begin{figure}[!p]
    \centering
    \includegraphics[scale=0.45]{JKR}
    \caption{JKR theory versus Hertz theory}\label{fig:JKR}
  \end{figure}
\end{document}
This modification will affect all floats that are placed on a float page, whether this placement is intended (as above) or not (caused by necessary floating).

[1] TeX Frequently Asked Questions - Vertical layout of float pages

If this solves the problem, mark the topic as solved by editing your initial post and choosing the green checkmark from the icon list.


Best regards and welcome to the board
Thorsten
Post Reply