0

I have a problem. I have a subsubsection with 2 images and a text. This piece of content is being repeated over 10 times. The problem is that when the last subsubsection ends with a text, then the next couple of pages there are: image from 6th subsubsection, 2x images from 7th, 2x from 8th, 2x from 9th and 2x from 10th. How to make it so that it for example waits for images.

Below there is representation what I currently have. When I continue a text it should not separate that 2 images especially when that 2 images are declared one after another.

When I have only 1 figure instead of 2 it's even worse. Then almost all images are after all subsection ends.

\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.

what i have what i have

  • Please make your snippet compilable. That's much more useful. As it is, I'm unlikely to produce the same output you're getting because I don't know how to complete the code as you have. What do you want to happen? You've told LaTeX that, if there isn't room here, then the image can be placed only at the top of a page. That's pretty limited. Anything which won't fit gets pushed to the end of the document and any image after that one gets pushed there too. Do you really want them to float? – cfr May 31 '18 at 23:46
  • 1
    Put them in the same float if you want them to stay together. – cfr May 31 '18 at 23:48
  • 1
    you have used [!ht] to specify that floats have to go on pages with text and can not be on float pages with just floats. – David Carlisle May 31 '18 at 23:51
  • 2
    You can specify float barriers in your code. I don't have a system ready here, but search for terms like 'latex float barrier' or 'latex prevent floats certain limit' or 'latex block float beyond' or something like that. Should be one command like \floatbarrier (not it's actual name) with no argument you can write just before \subsection. – thymaro Jun 1 '18 at 0:01
2

Similar to thymaro's comment, you can use \FloatBarrier from the placeins package to constrain where the figures can float with respect to subsection boundaries, and can use the basic [p] placement option to ensure that they end up on pages without text. There's probably a clever way to add the \FloatBarrier command to the \subsubsection definition, but that's beyond me at the moment.

\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}

enter image description here

0

I fixed this issue. I simply removed [!ht] from my figures and charts don't go away all the way to the bottom.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.