显示图形的另一个问题

显示图形的另一个问题

我有我的文档的完整代码(我希望它现在是正确的):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{placeins,listings}

\begin{document}
\lstset{language=Java, breaklines=true, basicstyle=\small, columns=fullflexible}
\tableofcontents
\newpage
\section{Title}
\subsection{Title}
Text 1
\\ Text 2:
\begin{figure}[htp]
\centering
\includegraphics[scale=0.5]{image1.jpg}
\caption{Caption 1} 
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=0.5]{image2.jpg}
\caption{Caption 2}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=0.5]{image3.jpg}
\caption{Caption 3} 
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=0.5]{image4.jpg}
\caption{Caption 4}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=0.5]{image5.jpg}
\caption{Caption 5}
\end{figure}

\FloatBarrier

Text 3

\FloatBarrier

\begin{figure}[htp]
\centering
\includegraphics{image6.jpg}
\caption{Caption 6}
\end{figure}
\begin{figure}
\centering
\includegraphics{image7.jpg}
\caption{Caption 7}
\end{figure}
\begin{figure}
\centering
\includegraphics{image8.jpg}
\caption{Caption 8}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics{image9.jpg}
\caption{Caption 9}
\end{figure}
\end{document}

我得到了这个:第1页- 图像6在Text3之后,另一张图片(图像7,图像8,图像9)在下一页,不在图像6之后第2页

答案1

由于我不知道图像的尺寸,只能graphicx使用演示模式,因此我尝试了一种解决方案,即删除图 6 和图 7 的浮动部分,并将图 8 和图 9 合并为一个浮动部分。图 8 和图 9 出现的位置当然取决于文本等。

\documentclass{article}%
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{caption} % My addition
\usepackage{placeins}
%\usepackage{listings} % Not needed here!

\def\myscalingfactor{0.5} % Better for many images!

\begin{document}
%\lstset{language=Java, breaklines=true, basicstyle=\small, columns=fullflexible} % Not needed here
\tableofcontents
\clearpage % or \cleardoublepage if necessary is better in my point of view

\section{Title}
\subsection{Title}
Text 1
\\ Text 2:
\begin{figure}[htp]
\centering
\includegraphics[scale=\myscalingfactor]{image1}
\caption{Caption 1} 
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=\myscalingfactor]{image2}
\caption{Caption 2}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=\myscalingfactor]{image3}
\caption{Caption 3} 
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=\myscalingfactor]{image4}
\caption{Caption 4}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[scale=\myscalingfactor]{image5}
\caption{Caption 5}
\end{figure}

\FloatBarrier

Text 3

%\FloatBarrier

\begin{center}
\includegraphics{image6}%
\captionof{figure}{Caption 6}%
\includegraphics{image7}%
\captionof{figure}{Caption 7}%
\end{center}%
\FloatBarrier
% Now floating pictures
\begin{figure}  % Combine two graphics in one figure...
\centering
\includegraphics{image8}
\caption{Caption 8}
\includegraphics{image9}
\caption{Caption 9}
\end{figure}
\end{document}

在此处输入图片描述

相关内容