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.

Using the following structure, how can I get the listing to stay on the same page, be it at the top or the bottom?

\documentclass{scrartcl}
\usepackage[ngerman]{babel}

\usepackage{multicol}
\usepackage{listings}

\usepackage{lipsum}

\begin{document}
    \begin{multicols}{2}
        \lipsum[1]

        \begin{lstlisting}[float=*htp, frame=tb]
very
long
listing
spanning
several
lines
        \end{lstlisting}
        \lipsum[2-7]
    \end{multicols}
\end{document}
share|improve this question
1  
Floats in multicols are only "full line" and always go on the following page. Put the lstlisting environment earlier in the input. –  egreg Jul 29 '11 at 14:29
    
@egreg: Please turn your comment into an answer. –  lockstep Aug 30 '11 at 22:27
add comment

1 Answer 1

Floats in multicols are only "full line" and always go on the following page.

Put the lstlisting environment earlier in the input, so that it can float to the desired page.

share|improve this answer
add comment

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.