Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX - Listings - Code Indention

Tags:

latex

listings

so I'm working on some kind of homework paper about git and I want to insert some console output examples. I'm working with TextMate. I have my LaTeX code indented like every other normal source code, to make it more readable. My question now is, why get listings in my output pdf indented and how do I prevent that.

Some example code:

\begin{lstlisting}
    $ git ls-files
    README
    TU_Logo_SW.pdf
    beleg.pdf
    beleg.tex 
\end{lstlisting} 

In my file there is one tab in front of \begin and two in the lines following. When I run pdflatex the code will be indented with two tabstops in the pdf. Quickfix is to format all the listings without indention in my tex file, but thats pretty ugly ;-(

like image 664
paraa Avatar asked Oct 11 '25 23:10

paraa


1 Answers

lstlisting has a key that lets you remove spaces: \begin{lstlisting}[gobble=4] will remove the first four characters from every input line in the environment. (I think a tab should still count as one character at that point.)

like image 52
Ulrich Schwarz Avatar answered Oct 16 '25 07:10

Ulrich Schwarz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!