2

I have some text and after that I want to insert a figure. The text almost finishes on the second page, so I want to place the figure on the top of the third page (right after the text), but I cant. I've read the placement commands frome here: http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions and I tried all the different options (i.e. \begin{figure}[t!], \begin{figure}[t], \begin{figure}[b], \begin{figure}[h], ...) but the figure stays on the same place in the middle of the third page. I want it to go at the top. What I am missing? Here is the code:

    \documentclass[11pt]{article}

\usepackage{amssymb,amsmath}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{amsthm}
\usepackage{graphicx}
\graphicspath{ {img/} }
\usepackage{fullpage}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\newtheorem{thm}{Theorem}
\newtheorem{thm1}{Theorem}
\theoremstyle{definition}
\usepackage{float}
\newtheorem{defn}{Definition}[section]
\floatname{algorithm}{Algorithm}
\newcommand{\euler}{e}
\newenvironment{claim}[1]{\par\noindent\underline{Claim:}\space#1}{}
\newenvironment{claimproof}[1]{\par\noindent\underline{Proof:}\space#1}{\hfill $\blacksquare$}

\begin{document}

\title{some titlw}
\author{me}
\date{\today}
\maketitle
\section{Some section}
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVv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end{figure}
asasdasdadsads
\end{document}
  • Welcome to TeX.SX! Please help us to help you and complete your code to make a minimal working example (MWE) that illustrates your problem. (Something we can copy-paste-compile to see the problem.) You probably don't want t!, though. – cfr Dec 14 '14 at 1:54
  • @cfr I added the code. – user3371223 Dec 14 '14 at 2:15
  • Thanks, but it is on the maxi- end of minimal, don't you think?! – cfr Dec 14 '14 at 2:21
  • Are you going to add more text after the figure? – cfr Dec 14 '14 at 2:24
4

As it stands, your document does not contain enough text for LaTeX to put the figure at the top of a page. On the first page, floats at the top are banned. There is no second page (of text). So, having the figure left at the end of the document, LaTeX does whatever it must to place it: it puts it on a page of floats and, by default, that means the floats are vertically centred on the page.

If you have more text after the figure, this won't happen:

\documentclass[11pt]{article}
\usepackage{kantlipsum}% for the demo
\usepackage{amssymb,mathtools}% fixes/enhancements for amsmath (loads amsmath)
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usepackage{amsthm}
\usepackage{fullpage}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\newtheorem{thm}{Theorem}
\newtheorem{thm1}{Theorem}
\theoremstyle{definition}
\usepackage{float}
\newtheorem{defn}{Definition}[section]
\floatname{algorithm}{Algorithm}
\newcommand{\euler}{e}
\newenvironment{claim}[1]{\par\noindent\underline{Claim:}\space#1}{}
\newenvironment{claimproof}[1]{\par\noindent\underline{Proof:}\space#1}{\hfill $\blacksquare$}

\begin{document}

  \title{some titlw}
  \author{me}
  \date{\today}
  \maketitle
  \section{Some section}
  sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx
  sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcV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dxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx


  asdszdszd
  \begin{figure}[t]
    \includegraphics[width=0.25\textwidth]{graphic1}
  \end{figure}
  asasdasdadsads

  \kant[1-2]
\end{document}

float to top

If you want the figure to be centred, add \centering at the start of the figure environment`.

float to centre top

If that's the end of your document, you can add \newpage\vfill\mbox{ } at the end to force a new, otherwise empty page for the figure to float to the top of.

float to centre top on empty page

0
\usepackage{float}

\begin{figure}[H]

This will force LaTex to put your figure where you want it to be.

  • This won't help. The OP doesn't want LaTeX to put it at the insertion point. The figure needs to float to the next page. At least, that's how I understood the question. – cfr Dec 14 '14 at 2:36
  • If OP wants the figure to be on the top of the third page, instead of the centre of the third page, forcing the figure with [H] will allow it to work as the text finishes at the end of the second page. – Eugene Dec 14 '14 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.