[Tex/LaTex] Inserting figures messes up two column layout

floatsmulticol

This is literally my first attempt at creating a LaTeX document, so I'm incredibly new to this.

I try to create a two-column article with a lot of figures inserted at column width. But, for some reason, the whole alignment of the page is messed up after some figure. There is either a huge gap between the figure and the text, or between paragraphs.

I tried re-creating it in the code below. As you can see, the distance between Figure 1 and text is pretty big. As well as between the paragraphs themselves.

Is there a way to get rid of this extra distance?
Thanks.

EDIT: got the Figure environment from here: multicol and figures

\documentclass{article}
\usepackage[a4paper,margin=2cm]{geometry}
\usepackage{lipsum,multicol,caption}
\usepackage[demo]{graphicx}
\title{My Document}
\author{me}
\newenvironment{Figure}
    {\par\medskip\noindent\minipage{\linewidth}}
    {\endminipage\par\medskip}
\begin{document}
\maketitle
\begin{multicols}{2}

\lipsum[1-2]

\lipsum[1]
\begin{Figure}
\centering
\includegraphics[width=\textwidth, height=5cm]{img/img1}
\captionof{figure}{my caption}
\end{Figure}
\lipsum[2]
\lipsum[1]
\begin{Figure}
    \centering
    \includegraphics[width=\textwidth, height=6cm]{img/img1}
    \captionof{figure}{other caption}
\end{Figure}
\lipsum[1]
\subsection{New}
\lipsum[1]
\subsection{New}
\lipsum[1]
\end{multicols}
\end{document}

Best Answer

My suggestion is to use the twocolumn option of the article class, which is (in contrast to multicols) compatible with the standard floats (figure, table etc.) - then let latex do the rest for you :)

Please also only specify either the width or the height of images, otherwise they will be distorted (or use keepaspectratio).

\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=2cm]{geometry}
\usepackage{lipsum}
%multicol,
%\usepackage{caption}
\usepackage{graphicx}
\title{My Document}
\author{me}
%\newenvironment{Figure}
%    {\par\medskip\noindent\minipage{\linewidth}}
%    {\endminipage\par\medskip}
\begin{document}
\maketitle
%\begin{multicols}{2}

\lipsum[1-2]

\lipsum[1]
\begin{figure}[htbp]
\centering
\includegraphics[width=\columnwidth]{example-image}
\caption{my caption}
\end{figure}
\lipsum[2]
\lipsum[1]
\begin{figure}[htbp]
    \centering
    \includegraphics[width=\columnwidth]{example-image}
    \caption{other caption}
\end{figure}
\lipsum[1]
\subsection{New}
\lipsum[1]
\subsection{New}
\lipsum[1]
%\end{multicols}
\end{document}