[Tex/LaTex] 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 ?

Best Answer

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:


 Some code.

which yields the following output:

enter image description here

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!