I need to intersperse my text with several figures, and I want them to be placed between correct paragraphs of text and in correct sections. For that reason I used \begin{figure}[!htb]. This worked. However since I needed to place many figures I wanted to cut out the boilerplate and wrote the following macro:
\newcommand{\SideBySide}[4] {
\begin{figure}[!htb]
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=\linewidth]{#1}
\caption{#3}
\end{minipage}%
\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=\linewidth]{#2}
\caption{#4}
\end{minipage}
\end{figure}}
Now it appears that [!htb] has lost its effect and figures are placed all over the place once again.
Why is that and how can I fix it?
[!htb]means allow the figure here (h) or at the top of a page (t) or bottom of a page (b) and ignore the usual constraints on good placement (!) so it sounds as if it is working as designed. if you do not want the figure to float just use\includegraphicsthe only reason to usefigureis to allow floating, – David Carlisle Aug 14 '21 at 14:55%after the first{(but this will only affect the placement in very rare cases) – David Carlisle Aug 14 '21 at 14:57