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 ?


1 Answer 1


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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .