# Can I get a shadowbox with rounded corners? (using listings package)

I'm using the listings package as below:

\usepackage{listings}

\lstnewenvironment{pythoncode}[1][]
{\lstset{language=Python,
basicstyle=\ttfamily\footnotesize,
frameround=tttt,
rulecolor=\color{black},
rulesepcolor=\color{gray},
#1}
}{}


I wanted to get a rounded corners together with a drop-shadow (shadowbox). Is it possible? While the frame border itself had rounded corners, the shadow had square corners, which is kinda ugly.

-
Do you have to use listings to create the box? Could you place the listing inside a tikz node? Then you could use something like this: texample.net/tikz/examples/boxes-with-text-and-math – Jan Hlavacek Jan 15 '11 at 1:04
Well... I don't need. I just didn't know any other way. Maybe you could submit an answer (instead of a comment) containing a sample code? ;) It should work with pdflatex and beamer package. – Denilson Sá Jan 16 '11 at 20:53

do you mean something like this?

\documentclass{beamer}

\usepackage{listings}

\begin{document}

\begin{frame}[fragile]{demo}
\begin{lstlisting}
foo
bar
baz
\end{lstlisting}
\end{beamerboxesrounded}

\end{frame}

\end{document}

-
 +1 Nice beamer feature – xeroc Jan 26 '11 at 10:36

This is an example using TikZ. Also working with beamer

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}

\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%

\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
{$\sum\limits_{i=1}^N (x_i-\mu_i)^2$};
\end{tikzpicture}
\end{document}


Would have posted a picture, but I dont have enough rep. to do so, yet.

Using a listing could look like this:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{listings}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%

%%%%%%%%%%%%%%%%%%%%%
% Code Listing
%%%%%%%%%%%%%%%%%%%%%
\lstnewenvironment{CODEENV}{
\lstset{
language=Matlab,
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=1em,
tabsize=1,
}
}{}

%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
\begin{CODEENV}
N = 128;
sigma_r = 1;

% Leistungsdichte nach Clark
nu_max      = 1;
nu          = (-nu_max):(2*nu_max/(N-1)):(nu_max);

% Bessel & Clark
xlambda = (0:2/(N-1):2);
rho_R = sigma_r^2*besselj(0, 2*pi*xlambda);

figure;
subplot(211);
plot(xlambda,rho_R/max(rho_R));
subplot(212);
plot(nu, abs(fft(rho_R)).^2);
\end{CODEENV}
};
\end{tikzpicture}
\end{document}


Note, that if you have long code snippets, you may need to increase the 'inner sep' parameter of the node, as the line numbering is done outside the listing box (as it seems).

-
The tricky part is not creating the shadow box, but making it work together with listings. – Juan A. Navarro Jan 24 '11 at 13:51
You are right. It was a little tricky – xeroc Jan 24 '11 at 17:17