我遇到了一个问题。我有一个子小节,其中包含 2 张图片和一段文字。这段内容重复了 10 多次。问题是,当最后一个子小节以文字结尾时,接下来的几页是:第 6 个子小节的图片、第 7 个子小节的 2 张图片、第 8 个子小节的 2 张图片、第 9 个子小节的 2 张图片和第 10 个子小节的 2 张图片。如何让它等待图片。
下面是我目前所拥有的表示。当我继续文本时,它不应该将这两幅图像分开,尤其是当这两幅图像一个接一个地声明时。
当我只有 1 个图而不是 2 个图时,情况就更糟了。然后几乎所有图像都在所有子节结束后。
\subsubsection{1.000 elements}
\subsubsection*{Web}
\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=25pt,
enlargelimits=0.20,
legend style={
anchor=north east,legend columns=-1},
ylabel={Time [ms]},
symbolic x coords={Angular, React, Vue},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(Angular,245) (React,206) (Vue,227)};
\addplot coordinates {(React,1765)};
\addplot coordinates {(Angular,132) (React,107) (Vue,134)};
\legend{list}
\end{axis}
\end{tikzpicture}
\caption{Chart 1}
\label{rys:web-1000el-cpu}
\end{figure}
\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=25pt,
enlargelimits=0.20,
legend style={
anchor=north east,legend columns=-1},
ylabel={Memory [MB]},
symbolic x coords={Angular, React, Vue},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(Angular,22.3) (React,13.7) (Vue,18.9)};
\addplot coordinates {(React,14.6)};
\addplot coordinates {(Angular,17.1) (React,11.7) (Vue,15.3)};
\legend{grid}
\end{axis}
\end{tikzpicture}
\caption{Chart 2}
\label{rys:web-1000el-mem}
\end{figure}
Lorem ipsum dolor sit amet, ius exerci libris percipitur no, ne duo dolor malorum delectus. Ad movet dicit option pro, vis at facilis perfecto posidonium. Dicta aliquid quaerendum at usu. Equidem probatus vim no, mel prima epicuri ne, mel ea magna omittam suscipiantur. Nec iusto delenit patrioque et, duo ex dictas scaevola menandri, duo integre molestiae constituto at. In tempor ponderum mel, exerci labores est et. Labores delectus posidonium cum et. Nec ut labitur signiferumque conclusionemque. Brute nulla aliquid ut nam. Altera ceteros nec in. Omnes conclusionemque eam cu, eu essent eruditi ius, illum persius inimicus duo cu. Eum pertinacia mediocritatem an, cum cu sonet epicuri. Ut per vide graecis mediocritatem, ne solum comprehensam nec, at pro aperiam gloriatur.
Lorem ipsum dolor sit amet, porro populo veritus ut eum. Te legimus denique mei, malorum vituperata ius te. Ut scripta voluptua quo, et audire inimicus inciderint duo. An facer albucius evertitur ius, menandri deseruisse consequuntur sea eu. Nec delicata gloriatur ut. Id dicat doctus insolens vel, idque vocibus admodum eam no.
Timeam omnesque te nec, id eam aliquid sapientem expetendis. Eam lorem vocent convenire ex, has ad vide adolescens, mea ea enim ferri. Sit in quem nostrum adversarium, amet fuisset percipit vim ea. Fabulas dissentiunt te has. Dictas ornatus cu nec, duis dicta legendos in cum.
答案1
与 thymaro 的评论类似,你可以\FloatBarrier
使用placeins
包来限制图形相对于子部分边界的浮动位置,并且可以使用基本[p]
放置选项来确保它们最终出现在没有文本的页面上。可能有一种巧妙的方法可以将\FloatBarrier
命令添加到\subsubsection
定义中,但目前我还没搞明白。
\documentclass{article}
\usepackage{mwe,lipsum}
\usepackage{graphicx}
\usepackage{placeins}
\newcommand{\makecontent}{%
\lipsum
\begin{figure}[p]
\centering
\includegraphics[width=0.5\columnwidth]{example-image-A}
\caption{A figure}
\end{figure}
\begin{figure}[p]
\centering
\includegraphics[width=0.5\columnwidth]{example-image-B}
\caption{Another figure}
\end{figure}
}
\begin{document}
\section{One}
\subsection{Uno}
\FloatBarrier
\subsubsection*{Web}
\makecontent
\FloatBarrier
\subsubsection*{Not Web}
\makecontent
\end{document}
答案2
我修复了这个问题。我只是[!ht]
从我的数字和图表中删除了它们,它们并没有一直消失到底部。