[Tex/LaTex] Minipage overlapping with text that follows

minipagevertical alignment

I'm trying to replicate the following layout that I have in a Word version of the paper:

This is what I want to get in LaTeX.

There are two code sections side by side with the code balanced between the two. The code won't fit into a single column, so I used this way to get it to stay on the same page. The caption would be under.

I tried doing this, but unfortunately, that kind of works, but not quite. It produces the two columns, but there are issues:

LaTeX version of what I got.

So first thing is the columns do not align with the text columns (red lines). I think it probably has to do with my minipage somehow.

Secondly, it overlaps with text that follows (that biography box should be later on!). Makes me feel like it does not recognize that the minipage is there and renders the text anyways.

Here is a code snippet that does this (I use same syntax in my file):

\documentclass[10pt,journal,compsoc]{IEEEtran}

\newcommand{\us}{\char`_}
\usepackage{listings}
\lstdefinestyle{base}{
    language=C,
    basicstyle=\footnotesize\ttfamily,
    multicols=2,
    breaklines=true
}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{blindtext}
\begin{document}


\noindent
\begin{minipage}[5cm]{\textwidth}
\begin{lstlisting}[language=C++,caption=Migration,style=base,captionpos=b]
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;



\end{lstlisting}
\end{minipage}%


\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}

I hope someone can hint which way I should proceed here.

Best Answer

Get rid of the minipage and enclose the listing inside a figure*; it will be moved to the top of the following page but you won't have the problems that you are experiencing now:

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{listings}
\lstdefinestyle{base}{
    language=C,
    basicstyle=\footnotesize\ttfamily,
    multicols=2,
    breaklines=true
}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{blindtext}

\newcommand{\us}{\char`_}

\begin{document}

\begin{figure*}
\begin{lstlisting}[language=C++,caption=Migration,style=base,captionpos=b]
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
int a;
\end{lstlisting}
\end{figure*}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document}

enter image description here