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 have the following code that displays a listing in a paragraph. However, because there are not so many line of code, I would like to move it to the right and the paragraph be on the left hand side. I'm wondering how I can do this.

\begin{minipage}{0.5\linewidth}
  \vspace{-0.2cm}
  \begin{lstlisting}[basicstyle=\scriptsize,label= mylabel, caption = mycaption}
     LOC1 
     LOC2
     LOC3
     LOC4 
  \end{lstlisting}
  \vspace{-0.2cm}
\end{minipage}
share|improve this question
    
wrapfig is probably the package you are looking for –  David Carlisle Dec 17 '12 at 16:01
add comment

1 Answer

up vote 3 down vote accepted

You can use the wrapfig package; a little example:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{listings}
\usepackage{lipsum}% just to generate text for the example

\begin{document}

\begin{wrapfloat}{lstlisting}{O}{5cm}
\begin{lstlisting}[basicstyle=\scriptsize,label= mylabel, caption =mycaption]
LOC1 
LOC2
LOC3
LOC4 
\end{lstlisting}
\end{wrapfloat}
\lipsum[1-3]

\end{document}

enter image description here

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.