4

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 ;-(

1
  • 1
    listing is a verbatim environment, so everything between the \begin and the \end is included. As far as I'm aware, there's no way around that. You could try asking this on tex.stackexchange.com; it's still on-topic here, but you might get a quicker response. (I also removed the git tag, as this isn't really about git, just formatting code in LaTeX.)
    – Cascabel
    Nov 21, 2010 at 16:00

1 Answer 1

8

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.)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.