Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to use the multicols environment to display a listing beneath a table:

\begin{multicols}{2}
   \begin{lstlisting}[]
 .....
\end{lstlisting}

\columnbreak

 \begin{table}
       \centering
     \begin{tabular}{r|c|c|c|c|c}
         .....
      \end{tabular}
 \end{table}
\end{multicols}

But this only displays my listing. Am I missing something?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Why not a pair of minipage environments?

\begin{center}
\begin{minipage}[t]{.45\textwidth}
\begin{lstlisting}
...
\end{lstlisting}
\end{minipage}\hfil
\begin{minipage}[t]{.45\textwidth}
\begin{tabular}{...}
...
\end{tabular}
\end{minipage}
\end{center}

Play with the width of the minipage's.

share|improve this answer

The multicol package doesn't support normal floats, like table and figure, only page-wide floats, which are starred forms: table* and figure*.

But you do not need the table environment to create the table, that only causes it to float. You could replace the table environment with a center environment, or drop the surrounding environment altogether. If you need a caption, you can use the captionof command from the caption package.

\documentclass{article}
\usepackage{multicol,listings}
\begin{document} 
\begin{multicols}{2}
  \begin{lstlisting}[]
      .....
  \end{lstlisting}
\columnbreak
 \begin{center}
     \begin{tabular}{r|c|c|c|c|c}
         a & b & c & d & e & f 
      \end{tabular}
 \end{center}
\end{multicols}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.