I'm writing an article with the IEEEtran template, which have two columns.

I'd like to have a listing with source code that spans the two columns of the article, like in the attached figure.

I'm using the following command: \lstinputlisting[frame=single, caption={blablabla}, label={blablabla}]{listings/blablabla.java}

Does anybody know how to do it?

enter image description here

  • by span you mean continuing in the second column from first or occupying the space that is pagewide instead of using only one column? It's much easier to work with an example if you include a short and compilable one
    – percusse
    Oct 6, 2014 at 23:00
  • in an analogy with a figure, this is a code that spans two columns: \begin{figure*}...\end{figure*} i'd like to have a listing that behaves like that. sorry if a didn't put a code, but it's exactly what I want to discover.
    – csfb
    Oct 6, 2014 at 23:10
  • You can at least put the listing code that you want to make it span instead of us making up random nonsense.
    – percusse
    Oct 6, 2014 at 23:11
  • \lstinputlisting[frame=single, caption={blablabla}, label={blablabla}]{listings/blablabla.java}
    – csfb
    Oct 6, 2014 at 23:12
  • Related: IEEE-Template: Algorithm over both columns
    – Werner
    Oct 7, 2014 at 0:51

3 Answers 3

\usepackage{listings,multicol}  % <--- multicol only required, if the multicols= option shall be used
\usepackage{filecontents}       % <--- only needed to provide example code
\usepackage{lipsum}             % <--- only needed to provide dummy text

\lstset{language=Java, basicstyle=\ttfamily\footnotesize}

package awt;

import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Hello {

  public static void main(String[] args) {
    Frame f=new Frame("Hello World example of awt application");
    Label label1=new Label("Hello World", Label.CENTER);

    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent event) {


\lstinputlisting[float=*t, caption={A wide listing float, single column}]{stuff.java}
\lstinputlisting[float=*, multicols=2, caption={A wide listing float, itself dobule-column}]{stuff.java}

enter image description here

  • float=*t worked for me.
    – vineeshvs
    Sep 27, 2021 at 18:15
  • Is there a way to use float=*t and also allow page breaks?
    – Eran H.
    Jun 19, 2023 at 9:14

Until now I didn't find a way to make a listing span two colums using the command that reads the code from a file (\lstinputlisting).

However, I managed how to do it by putting the code in the latex document, as follows:

code goes here

Actually this can be done using \lstinputlisting. Here is the example for a C file:



Change the language and basicstyle according to your source file and document requirements.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .