When including listings with \lstinputlisting
, spaces (or tabs) used for indentation of the code are kept, which is of course a good thing. But I want to document code line-by-line, so sometimes the context of the indentation gets lost, making it unnecessary. For long lines, this space could be used better. Is there an option to gobble spaces for input listings (the manual states that this feature is ignored for \lstinputlisting
).
Here is a MWE:
\documentclass{scrartcl}
\usepackage{listings}
\usepackage{xcolor}
\lstset{backgroundcolor = \color{blue!10!white}} % show leading space
\begin{filecontents*}{code.lua}
function()
-- indented comment
local this = "test"
end
\end{filecontents*}
\begin{document}
\lstinputlisting[firstline=2, lastline = 3]{code.lua}
\end{document}
Here is the result (the blue background is there to visualize the leading space):
I would like to remove the space on the left.
listings
or are you looking for a straight verbatim result?listings
.