When I write latex I usually indent my sections like this (it allows easier folding in vim, is like reading code, etc).
section{section}
bla bla bla bla bla
subsection{a}
bla bla bla bla bla
subsection{b}
bla bla bla bla bla
The problem is when I insert code (see below) into my document if I indent the all of the code 3 tabs it will be be indented 3 tabs in the document. I want to preserve the relative indenting but I don't want that extra three tabs of indentation.
For example this latex:
subsection{a}
bla bla bla bla bla
\begin{lstlisting}
public static void main(String [] args){
bla bla
}
\end{lstlisting}
Produces:
*a*
bla bla bla bla bla
/* code is indented 3 tabs */
public static void main(String [] args){
bla bla
}
I would like it to produce:
*a*
bla bla bla bla bla
public static void main(String [] args){
bla bla
}
This is the code that is responsible for the code formatting (thanks Cloudanger).
\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,
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},
breakatwhitespace=true
tabsize=3
}