我有一些文本,之后我想插入一个图形。文本几乎在第二页上结束,所以我想将图形放在第三页的顶部(紧接着文本),但我不能。我已从这里阅读了放置命令:http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions我尝试了所有不同的选项(即 \begin{figure}[t!]、\begin{figure}[t]、\begin{figure}[b]、\begin{figure}[h] 等),但图形仍然停留在第三页中间的同一位置。我想让它位于顶部。我遗漏了什么?以下是代码:
\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
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVx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\textwidth]{graphic1}
\end{figure}
asasdasdadsads
\end{document}
答案1
目前,您的文档中没有足够的文本供 LaTeX 将图形放在页面顶部。在第一页上,顶部的浮动是被禁止的。没有第二页(文本)。因此,如果将图形留在文档末尾,LaTeX 会尽一切可能将其放置:它会将其放在浮动页面上,默认情况下,这意味着浮动在页面上垂直居中。
如果图后有更多文字,则不会发生这种情况:
\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
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVxcvcvxxcVxcVvcx
sdfsdfdsfsdfsdfsdfdfvdxffvdxvxdvcdFvSDFdxfvdxfvxfcvxdfvxcfvxcvxcVxCVxcVxcVx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idth]{graphic1}
\end{figure}
asasdasdadsads
\kant[1-2]
\end{document}
如果您希望图形位于中心,请\centering
在环境的开始处添加figure
`。
如果这是文档的末尾,您可以\newpage\vfill\mbox{ }
在末尾添加一个新页面,否则将空白页,以便图形浮动到顶部。
答案2
\usepackage{float}
\begin{figure}[H]
这将强制 LaTex 将图形放在您想要的位置。