[Tex/LaTex] Smaller frame with listings


I am using listings to put java code in my beamer slides.

Sometimes, I want to frame the code but I do not want the frame to occupy
the whole width of the page. I want the frame to occupy only the width of
my code and no more.

Is there a way to do that?

Best Answer

Here is a solution with fancyvrb and output with listings:



static void main () {
  int foo;
  string baz;


enter image description here