I use TexMaker. With the preamble that I have been using, I am able to get the indentation right for programs when used in a article, report, etc. But when I use the same structure within a frame in beamer, the indentation gets ignored. I have tried the fixes suggested in other posts of similar kind, but none of them work for me.
MWE:
\documentclass{beamer}
\usetheme{boadilla}
\usecolortheme{beaver}
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{%frame=tb, % to form a frame around code
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3,
}
\begin{document}
\begin{frame}[fragile]
\frametitle{Sample Program}
\begin{lstlisting}
public int increment() {
int a = 5;
int i = (++a) + (++a) + (a++);
System.out.println(a);
return i;
}
\end{lstlisting}
\end{frame}
\end{document}
The output that I get:

\documentclass{...}and ending with\end{document}that reproduces the issue. – karlkoeller Jan 04 '15 at 20:00