# Listing is mixed up with the text in second column [closed]

I have the following long listing. I used an adjustbox to fit the lines and added [float=*] to the listing properties in order to fit it into two columns. I am using this template which is a two column based article. The problem is shown in the photo below. How to prevent this to happen?

MWE

   \documentclass{comjnl}

\usepackage{lipsum}
\usepackage{listings}
\usepackage{url}
\usepackage{amsmath}
\usepackage{cuted}
\usepackage{hyperref}

\shortauthors{jd}

\begin{document}

\lipsum[50]
\lstset{
frame = single}
\begin{lstlisting}[caption={Regular expression used to extract links within HTML code of Web pages},label=Pattern,linewidth=12cm]

"https?://(?:www\\.)?[^\\n<>\"]+(?:\"[^<]*>([^<]*))?"

\end{lstlisting}
\lipsum[50]
\begin{strip}
\centering
\centering

\begin{lstlisting}[caption={A demonstration of a hierarchical XML file used in this experiment to evaluate our framework.},label=Layers,linewidth=20cm][float=*]
<?xml version="1.0" encoding="UTF-8"?>
<crawledURLs>
-<URL adr="http://ss.cs.tsinghua.edu.cn" id="2" info="2017 Deep Learning Summer School">
</URL>
-<URL adr="http://thu-cmu.cs.tsinghua.edu.cn" id="3" info="Tsinghua-CMU Double Master Degree Progra...">
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="2" INFO="Tsinghua University Introduction"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="6" INFO="Carnegie Mellon University"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="7" INFO="Tsinghua CS Department"/>
</URL>
</URL>
<URL adr="http://www.csai.tsinghua.edu.cn/homepage.shtm" id="5" info="State Key Lab of Intelligence Techonoly ..."/>
<URL adr="http://media.cs.tsinghua.edu.cn/en/" id="6" info="Institute of HCI & Media Integration"/>
-<URL adr="http://soft.cs.tsinghua.edu.cn/English/index.html" id="7" info="Institute of Computer Software">
<url ADR="http://166.111.68.91" ID="3" INFO="Design Automation of Computer and VLSI Circuits"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="4" INFO="Visualization and Computer Graphics"/>
<url ADR="http://soft.cs.tsinghua.edu.cn/soft/" ID="5" INFO="Software Engineering and System Software"/>
<url ADR="http://166.111.68.91" ID="8" INFO="Design Automation of Computer and VLSI Circuit"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="9" INFO="Visualization Technology and Computer Graphics"/>
</URL>
<URL adr="http://network.cs.tsinghua.edu.cn" id="8" info="Institute of Computer Networks"/>
</URL>
</crawledURLs>
\end{lstlisting}
}
\end{strip}

\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\end{document}


EDIT

Based on the answer provided below, the result will be like this. That is the whole point of using adjustbox to let the listing to be adjusted in a box~!

EDIT 2

When I replace the answer of Zarko with the code in my original project, the adjustbox appears to be rendered as below:

EDIT 3 I have checked my original project and I have realized that the problem is caused due to the fact that I have another listing before it. I have edited MWE and added the first listing to it. Compiling new MWE will result into the following snapshot:

## closed as unclear what you're asking by Zarko, Stefan Pinnow, Schweinebacke, TeXnician, MicoJul 11 '17 at 20:19

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• seems like the float* isn't quite working, could you post a complete MWE with \begin{document} and all ? – Elad Den Jul 11 '17 at 10:51
• @EladDen sure but you need to download the package as I mentioned within my question. – lonesome Jul 11 '17 at 10:53
• No problem, as long as we have something we can compile and check :) – Elad Den Jul 11 '17 at 11:08
• @EladDen take a look now, please. – lonesome Jul 11 '17 at 11:09
• @Zarko but it will be limited to one column. I want it to occupy both column. Just like figure* or table*. – lonesome Jul 11 '17 at 11:22

There is no need for \adjustbox, the float=* should be in the lstlisting definition. It is a big float, so LaTeX pushes it to a page of its own. I used the floatbarrier just to show it is a floating float.

\documentclass{comjnl}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{placeins}
\usepackage{url}
\usepackage{amsmath}
\usepackage{hyperref}

\shortauthors{jd}
\begin{document}

\lipsum

\lipsum[1-3]

\lstset{frame = single,
language=XML,
framexleftmargin=10pt,
basicstyle=\footnotesize\ttfamily,
breaklines=true}

\begin{lstlisting}[caption={A demonstration of a hierarchical XML file used in this experiment to evaluate our framework.},label=Layers,float=*]
% <?xml version="1.0" encoding="UTF-8"?>
<crawledURLs>
-<URL adr="http://ss.cs.tsinghua.edu.cn" id="2" info="2017 Deep Learning Summer School">
</URL>
-<URL adr="http://thu-cmu.cs.tsinghua.edu.cn" id="3" info="Tsinghua-CMU Double Master Degree Progra...">
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="2" INFO="Tsinghua University Introduction"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="6" INFO="Carnegie Mellon University"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="7" INFO="Tsinghua CS Department"/>
</URL>
</URL>
<URL adr="http://www.csai.tsinghua.edu.cn/homepage.shtm" id="5" info="State Key Lab of Intelligence Techonoly ..."/>
<URL adr="http://media.cs.tsinghua.edu.cn/en/" id="6" info="Institute of HCI & Media Integration"/>
-<URL adr="http://soft.cs.tsinghua.edu.cn/English/index.html" id="7" info="Institute of Computer Software">
<url ADR="http://166.111.68.91" ID="3" INFO="Design Automation of Computer and VLSI Circuits"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="4" INFO="Visualization and Computer Graphics"/>
<url ADR="http://soft.cs.tsinghua.edu.cn/soft/" ID="5" INFO="Software Engineering and System Software"/>
<url ADR="http://166.111.68.91" ID="8" INFO="Design Automation of Computer and VLSI Circuit"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="9" INFO="Visualization Technology and Computer Graphics"/>
</URL>
<URL adr="http://network.cs.tsinghua.edu.cn" id="8" info="Institute of Computer Networks"/>
</URL>
</crawledURLs>
\end{lstlisting}

\FloatBarrier

\lipsum[50]

\lipsum[50]

\lipsum[50]

\lipsum[50]

\lipsum[50]
\end{document}


EDIT:

AND THE RESULT

• did you even compile it? if so, you will notice the reason for using adjustbox.however, I have updated my question. – lonesome Jul 11 '17 at 12:46
• I did compile it, and it worked out just fine. Try my MWE AS IS, see what happens, then put it in your code, there might be something else there – Elad Den Jul 12 '17 at 8:30