# display both an image and a code, side-by-side

I'd like to display both an image and a code using pdflatex, side-by-side to illustrate a concept. The code uses listing package.

How could I do that ?

If what you are looking for is to display an image with its corresponding source code, then the showexpl package might be what you are looking for.

But since I suspect you just want to use any picture next to some code, then I sugest using the minipage environment. For example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}

\begin{document}
\begin{minipage}{0.5\textwidth}
\begin{lstlisting}
Some code.
\end{lstlisting}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\includegraphics{some_picture}
\end{minipage}
\end{document}


which yields the following output:

Of course, you can then adjust the parameters of the minipage as you see fit, but I find this basic structure to be sufficient.

Note that you can't put a float inside the minipage environment. For more information, see How to use figure inside a minipage?

Hope it helps!