我试图在同一页面中添加两个图形,Latex 会自动将一个放在顶部,另一个放在底部:
我想减少两者之间的空间,这样空白处就会位于页面末尾而不是中间。有什么解决办法吗?
\begin{figure}[H]
\centering
\includegraphics [width=1.0\textwidth]{ff4}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
编辑:
正如我被要求重现一个最小的例子时,问题出现在我在这前两个图之后有其他图时:
\documentclass[11pt,twoside]{mitthesis}
\pagestyle{plain}
\usepackage{graphicx}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,nccmath}
\usepackage{amssymb}
\usepackage{array,booktabs}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\usepackage[polutonikogreek,english]{babel}
\usepackage{textgreek}
\usepackage{fancyhdr}
\pagestyle{fancy}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\usepackage{emptypage}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{figure}[H]
\centering
\includegraphics [width=1.0\textwidth]{ff4}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics [width=1.0\textwidth]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
text text text text text text text text text text text text text text text
text text text text text
text text text text text text text text text text
t ext text text text text text text text text texttext text text text text
text text text text texttext text text text text text text text text
texttext text text text text text text text text text
text text text text text text text text text texttext text text text text
text text text text texttext text text text text text text text text
texttext text text text text text text text text text
text text text text text text text text text texttext text text text text
text text text text text
t ext text text text text text text text text texttext text text text text
text text text text texttext text text text text text text text text text
\end{document}
答案1
让浮筒飘浮起来。
如果您希望将这两个大浮动元素放在一个页面中,请使用选项声明它们[p]
。对于您要求的放置位置,请更改相关参数。
\documentclass[11pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{emptypage}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lipsum}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\setlength{\headheight}{13.6pt} % fancyhdr keeps asking this
\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpsep}{4ex}
%\setlength{\@fpbot}{0pt plus 1fil} % already default
\makeatother
\begin{document}
\lipsum[1-4]
\begin{figure}[p]
\centering
\includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}
\begin{figure}[p]
\centering
\includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics [width=1.0\textwidth,height=6cm]{example-image}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
\lipsum
\end{document}
答案2
这是一个典型的情况,你可以看到浮点数的优势。在你的figure
环境中,你选择了[H]
,这或多或少意味着不要漂浮。我用
\begin{figure}[H]
\centering
\includegraphics [width=0.6\textwidth]{example-image-a}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics [width=0.6\textwidth]{example-image-b}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics [width=0.7\textwidth]{example-image-c}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
您依次放置的三幅图像将被视为三个(大)字母。由于它们无法放在一页上,LaTeX 别无选择,只能将前两幅放在第一页,将第三幅放在第二页。然后是其余的文本。现在,如果您改为使用,[htb]
则允许 LaTeX 将图形放置在文本中最适合的位置。
\begin{figure}[htb]%[H]
\centering
\includegraphics [width=0.6\textwidth]{example-image-a}
\caption{Derivatives in equation \ref{eq9}.}
\label{F4}
\end{figure}
\begin{figure}[htb]%[H]
\centering
\includegraphics [width=0.6\textwidth]{example-image-b}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
\begin{figure}[htb]%[H]
\centering
\includegraphics [width=0.7\textwidth]{example-image-c}
\caption{Derivatives in equation \ref{eq4}.}
\label{F5}
\end{figure}
更多信息请查看为什么浮点数中不应该使用“H”选项?
答案3
有趣的是,这种行为只有在使用 classtwoside
选项时才会出现article
。使用article
without 时twoside
,浮动将按照您希望的位置放置。
但是,要解决您的问题,您可以手动\newpage
在每两个图表后插入一个。这将禁用通过插入空白自动填充页面的功能,每两个图表将仅位于相应页面的顶部。
\documentclass[twoside]{article}
\usepackage[demo]{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff4}
\caption{Derivatives in equation \ref{eq9}.}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\end{figure}
\newpage
\begin{figure}[H]
\centering
\includegraphics[width=1.0\textwidth, height=0.3\textheight]{ff5}
\caption{Derivatives in equation \ref{eq4}.}
\end{figure}
\end{document}