MikTex lstlisting package with quotes

108 views Asked by At

I'm using the beamer class to create slides and using the lstlisting package inside a colorbox. Below is a reproducible example showing my problem when using pdflatex. I'm trying to use quotes (") as in the line read.csv(c:'//path') and the compiler breaks. Things works when the quotes are removed.

Does anyone see a way to solve that problem?

\documentclass[]{beamer}
\usepackage{colortbl} 
\usepackage{bm}
\usepackage{color}
\usepackage{amssymb,amsmath}
\usepackage{mathtools} 
\usepackage{float}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{listings}
\lstset{basicstyle=\ttfamily} 
\usepackage{tcolorbox}
\usepackage{graphicx}
\usepackage{fancybox}
\usepackage{hyperref}
% For formatting R code
\lstset{language=R,
    basicstyle=\small\ttfamily,
    stringstyle=\color{DarkGreen},
    otherkeywords={0,1,2,3,4,5,6,7,8,9},
    morekeywords={TRUE,FALSE},
    deletekeywords={data,frame,length,as,character},
    keywordstyle=\color{blue},
    commentstyle=\color{DarkGreen},
    xleftmargin=.0in,
    breaklines=true,
    xrightmargin=.25in
}
\newcommand{\qq}{\symbol{34}}

%\documentclass[handout]{beamer}
\mode<handout>
{
  \usetheme{default}
}
\mode<presentation>
{
  \usetheme{Madrid}
  %\usetheme{default}
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
%\usepackage{SweaveSlides}
\usepackage{bm}
\usepackage{graphicx}
\usefonttheme[onlymath]{serif}
%\logo{\includegraphics[width=3cm]{logo.jpeg}}
\title{Title}
\author {Name\\Place}
\institute[Place]{
  }
\date[Test]{Test}
\subject{OP}
\AtBeginSubsection[]%
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}
\begin{document}
\begin{frame}
  \titlepage
  \end{frame}


\begin{frame}[fragile]
\frametitle{Title}
\begin{itemize}
\item Item 1
\end{itemize}
\begin{tcolorbox}[colback=red!5,colframe=red!75!black,title=Reading in a .csv File]
\lstset{tabsize=2}
\begin{lstlisting}
read.csv('c://test')
\end{lstlisting}
\end{tcolorbox}
\end{frame}

\end{document}
0

There are 0 answers