-1

Here's my beamer frame:

\defverbatim[colored]\sleepSort{
        \begin{lstlisting}[language=python,tabsize=2]
    var = 3 list print
      \end{lstlisting}}
      \begin{frame}{Variáveis}

      \begin{itemize}
        \item Armazenamento de dados
        \Declaração

      \end{itemize} 

        \sleepSort

      \end{frame}

My piece of code is on the same background everything else. How can I put the code on a rectangle of another color?

4
1

As there is no MWE in the question and I don't want to find out how \defverbatim is to be used I put the listing directly in the frame.

\documentclass{beamer}

\usepackage{listings}

\begin{document}

\begin{frame}[fragile]
\begin{lstlisting}[language=python,tabsize=2,backgroundcolor=\color{yellow}]
var = 3 list print
\end{lstlisting}
\end{frame}

\end{document}

enter image description here

6
  • This does unfortunately not work for every theme. I had an occurance, where this was rendered as lines with a yellow background with the background color of the frame visible between them.
    – mat
    Oct 11 '19 at 10:43
  • 1
    @mat May be it would be nice, if you can ask a new question with your concerns, because, the samcater/user36296 is suspended from this site and therefore, she cannot answer. Oct 11 '19 at 11:45
  • @Raaja: I added a reference and expanded the solution
    – mat
    Oct 14 '19 at 8:44
  • @mat I dont completely understand your comment. Oct 14 '19 at 9:21
  • My edit was rejected. Unfortunately I cannot post the solution as a new answer, since the question is closed: To get a solid background for a listing, you can use the mdframe environment as suggested here: \begin{mdframed}[backgroundcolor=yellow] \begin{lstlisting}language=python,tabsize=2] ... \end{lstlisting} \end{mdframed}
    – mat
    Oct 14 '19 at 13:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.