I'm trying to create a LaTeX document that contains mostly images (but occasionally some text after an image). I currently have the following in the preamble:
\def \ifempty#1{\def\temp{#1} \ifx\temp\empty }
\newcommand{\image}[2]{
\ifempty{#2}
\begin{figure}[H]
\includegraphics[width=\textwidth]{#1}
\end{figure}
\else
\begin{figure}[H]
\includegraphics[width=\textwidth]{#1}
\caption*{\textit{\Large{#2}}}
\end{figure}
\fi
}
and then when I add an image I use:
\image{imageName}{optionalText}
This inserts a lot of whitespace in between images. What I want is for each image to be right after the next unless the image cannot fit on the page, in which case a new page is created (basically, I want the images to flow the same way anything else would by default).
I have tried changing the [H]
option on the caption
as suggested in this question as well as tried out various suggestions from OverLeaf as well as this WikiBooks article, but have been unable to get the images to flow properly.
How can I get images to flow normally?
\setlength{\floatsep}{0pt}
at the beginning of the document has no effect either, which is what that answer seems to say.\begin{figure}
environments they are doing nothing useful and adding vertical space\textit{\Large{#2}}
should be{\Large\textit{#2}\par}