# Verbatim inside a minipage inside a tikz node — beamer class

I am trying to get a boxed text as part of a tikz node. I found an example here that I am trying to follow, but it is giving me an error: Argument of \@xverbatim has an extra }. I can't figure it out. Any help would be greatly appreciated. My code is below. One interesting thing is that if I change the documentclass to article, it works. However, I need this in a beamer environment.

\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}

\usepackage{tikz}

\usetikzlibrary{shapes,snakes}

\begin{document}

\begin{frame}
\frametitle{Testing verbatim}
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=2pt, inner ysep=2pt]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.4\textwidth}
\tiny
\begin{verbatim}
<list title="MOVIES">
<film>
<title>The Shining</title>
<release_date>1980-05-23</release_date>
<director>Stanley Kubrick</director>
<actor>Jack Nicholson</actor>
</film>
<film>
<title>Spartacus</title>
<director>Stanley Kubrick</director>
</film>
<film>
<title>The Passenger</title>
<actor>Jack Nicholson</actor>
</film>
...
</list>
\end{verbatim}
\end{minipage}
};
\end{tikzpicture}
\end{frame}
\end{document}

-

You have to add [fragile] option to \begin{frame}. I have also added the options font=\tiny,text width=0.45\textwidth to the mybox style.

Code:

\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}

\usepackage{tikz}

\usetikzlibrary{shapes,snakes}

\begin{document}

\begin{frame}[fragile]
\frametitle{Testing verbatim}
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=2pt, inner ysep=2pt,font=\tiny,text width=0.45\textwidth]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.4\textwidth}
\begin{verbatim}
<list title="MOVIES">
<film>
<title>The Shining</title>
<release_date>1980-05-23</release_date>
<director>Stanley Kubrick</director>
<actor>Jack Nicholson</actor>
</film>
<film>
<title>Spartacus</title>
<director>Stanley Kubrick</director>
</film>
<film>
<title>The Passenger</title>
<actor>Jack Nicholson</actor>
</film>
...
</list>
\end{verbatim}
\end{minipage}
};
\end{tikzpicture}
\end{frame}
\end{document}


Here is another option with tcolorbox:

\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}

\usepackage{tcolorbox}
\tcbuselibrary{listings,breakable,fitting}

\newtcblisting{myverbatim}{
arc=3mm,
top=0mm,
bottom=0mm,
left=0mm,
right=0mm,
boxrule=1pt,
colframe=red,
colback=blue!20,
listing only,
listing options={
basicstyle=\tiny
},
hbox,
%width=0.6\textwidth,  %%For fitting library
breakable
}

\begin{document}

\begin{frame}[fragile]
\frametitle{Testing verbatim}
\pause
\begin{myverbatim}
<list title="MOVIES">
<film>
<title>The Shining</title>
<release_date>1980-05-23</release_date>
<director>Stanley Kubrick</director>
<actor>Jack Nicholson</actor>
</film>
<film>
<title>Spartacus</title>
<director>Stanley Kubrick</director>
</film>
<film>
<title>The Passenger</title>
<actor>Jack Nicholson</actor>
</film>
...
</list>
\end{myverbatim}
\end{frame}
\end{document}

-
Wonderful, thank you very much for your assistance. –  ozsu Aug 13 at 1:39
Spoke too soon... I need to put the entire \begin{tikzpicture} ... \end{picture} inside an \only<2>{...}. When I do that I get the error again. I left that part out because I thought that would be simple. Any ideas to fix this please? –  ozsu Aug 13 at 1:53
–  JPi Aug 13 at 8:04
@ozsu Put a \pause before \begin{tikzpicture}. –  Harish Kumar Aug 13 at 9:57
Thank you very much. I would have never thought of it. –  ozsu Aug 13 at 10:34