避免文字溢出图片下方

避免文字溢出图片下方

我在一页上有多张图片(像这样的一页接一页有 2-3 页)。除了每页的标题外,我不希望图片下方有任何文字。但是,下一节或上一节的标题和文字会自动调整到它们下方。

有没有办法修改下面的代码,以便我可以确保只有图像占据工作表而不占据其他任何内容?

\documentclass{article}
\usepackage{subfigure}
\usepackage[demo]{graphicx}
\usepackage[utf8]{inputenc}

\begin{document}


\begin{figure}[ht!]
     \begin{center}
%
        \subfigure[Caption of First Figure]{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{FirstFigure.png}
        }%
        \subfigure[Caption of Second Figure]{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{SecondFigure.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure[Caption of Third Figure]{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{ThirdFigure.png}
        }%
        \subfigure[Caption of Fourth Figure]{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{FourthFigure.png}
        }%
%
    \end{center}
    \caption{%
        The l-o-n-g caption for all the subfigures
        (FirstFigure through FourthFigure) goes here.
     }%
   \label{fig:subfigures}
\end{figure}

\end{document}

为了在图片前添加节标题,我修改了下面的代码。但是它不起作用。请帮忙。

\documentclass{article}
\usepackage{subfigure}
\usepackage[demo]{graphicx}
\usepackage[utf8]{inputenc}

\begin{document}

\section{Heading-1}

\begin{figure}[hp]
     \begin{center}
%
        \subfigure[Caption of First Figure]{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{FirstFigure.png}
        }%
        \subfigure[Caption of Second Figure]{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{SecondFigure.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure[Caption of Third Figure]{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{ThirdFigure.png}
        }%
        \subfigure[Caption of Fourth Figure]{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{FourthFigure.png}
        }%
%
    \end{center}
    \caption{%
   Subheading 1
     }%
   \label{fig:subfigures}
\end{figure}





\begin{figure}[p]
     \begin{center}
%
        \subfigure[Caption of First Figure]{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{FirstFigure.png}
        }%
        \subfigure[Caption of Second Figure]{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{SecondFigure.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure[Caption of Third Figure]{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{ThirdFigure.png}
        }%
        \subfigure[Caption of Fourth Figure]{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{FourthFigure.png}
        }%
%
    \end{center}
    \caption{%
      Subheading 2.
     }%
   \label{fig:subfigures}
 \end{figure}


\section{Inference}
From the above figures we infer x y z



\section{Heading-2}

\begin{figure}[hp]
     \begin{center}
%
        \subfigure[Caption of First Figure]{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{FirstFigure.png}
        }%
        \subfigure[Caption of Second Figure]{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{SecondFigure.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure[Caption of Third Figure]{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{ThirdFigure.png}
        }%
        \subfigure[Caption of Fourth Figure]{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{FourthFigure.png}
        }%
%
    \end{center}
    \caption{%
      subheading 3.
     }%
   \label{fig:subfigures}
\end{figure}





\begin{figure}[p]
     \begin{center}
%
        \subfigure[Caption of First Figure]{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{FirstFigure.png}
        }%
        \subfigure[Caption of Second Figure]{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{SecondFigure.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure[Caption of Third Figure]{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{ThirdFigure.png}
        }%
        \subfigure[Caption of Fourth Figure]{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{FourthFigure.png}
        }%
%
    \end{center}
    \caption{%
        subheading 4.
     }%
   \label{fig:subfigures}
 \end{figure}

\section{Inference}
From the above figures we infer x y z


\end{document}

答案1

或多或少,ht此处使用的唯一效果\begin{figure}[ht!] 是删除默认允许的选项p,这意味着将浮动元素单独放在没有文本的页面上。因此,删除[ht!]或明确强制将其放在浮动页面上,请使用[p]

相关内容