I have a follow up question to this post
I am using listings in beamer
. The content in listings
is being pushed further left than the other contents on my slides. I am using the code below to correct for it and it works fine. However, within columns the code is now also shifted to the right even though it was perfectly aligned within a comment. How can I prevent this?
Here is a minimalist document:
\documentclass{beamer}
\usepackage{remreset}
\usepackage{comment} % end and begin comment
\usepackage{dtklogos} % for \BibTeX
\usepackage{graphicx} % importing figure
\usepackage{caption}
\usepackage{subcaption}
\usepackage{verbatim} % writing code
\usepackage[english]{babel}
\makeatletter
\@removefromreset{subsection}{section} % creates navigation circles for every slide not section
\makeatother
\setcounter{subsection}{1} % creates navigation circles for every slide not section
\usepackage{listings} % display code on slides; don't forget [fragile] option after \begin{frame}
\usepackage{bera} % font for code in slides
\usepackage{color}
\definecolor{lightgrey}{rgb}{0.92,0.92,0.92} % defining color for listing
\definecolor{darkgreen}{rgb}{0,0.6,0} % defining color for listing
\lstset{language=[LaTeX]TeX,
basicstyle=\small\ttfamily,
texcsstyle=*\bf\color{blue},
numbers=left,
numberstyle=\scriptsize\color{gray},
breaklines=true,
keywordstyle=\color{darkgreen},
commentstyle=\color{red},
morekeywords={},
otherkeywords={$,\{ ,\} , [ , ], & },
frame=leftline,
tabsize=2,
backgroundcolor=\color{lightgrey},
escapeinside=<>,
moretexcs={maketitle, subsection, subsubsection, appendix, tableofcontents,
includegraphics},
}
\usepackage{calc}
\newlength\listingnumberwidth
\setlength\listingnumberwidth{\widthof{00} + 1em}
\lstset{
numbers=left,
xleftmargin=\listingnumberwidth,
numbersep=1em
}
% move text box
\setbeamersize{text margin left=0.5cm}
\setbeamersize{text margin right=0.5cm}
\usetheme{Frankfurt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%****************************************************
\begin{frame}[fragile]
\frametitle{Tables}
\framesubtitle{The Body}
\begin{enumerate}
\begin{columns}[t]
\begin{column}{3.5cm}
\item The Preamble
\begin{lstlisting}
\documentclass{}
...
\usepackage{}
...
\title{}
\author{}
\date{}
\end{lstlisting}
\end{column}
\begin{column}{6.5cm}
\item The Body
\begin{lstlisting}
\begin{document}
\maketitle
% Body of document
\end{document}
\end{lstlisting}
\end{column}
\end{columns}
\end{enumerate}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Best Answer
This shifting to the right is due the additional blank space at the beginning of the line. This can be removed by adding
[gobble=12]
option to delete the first 12 spaces to yield:Notes:
Code