6
votes
1answer
59 views

Can listings automatically indent code? [duplicate]

\documentclass[11pt,a4paper] {article} %\usepackage{fontspec} \usepackage{listings} \usepackage{xcolor} %\setmainfont[BoldFont=黑体]{宋体} %\XeTeXlinebreaklocale "zh" %\XeTeXlinebreakskip = 0pt plus 1pt ...
14
votes
1answer
270 views

Can the listings package automatically indent source code?

The listings package automatically highlights keywords in source code and makes it look nice. Is it possible to automatically indent the program? For example, in listings, if the following code is ...
4
votes
2answers
119 views

Indent content of verbatim / lstlisting environment relative to containing environment

I want the content of \verbatim to be indented relative to the actual indent of \verbatim, not the exact number of spaces. For example, I like to indent at sections to make the LaTeX source more ...
3
votes
1answer
110 views

Change indentation depth when using spaces in lstlisting

I have an lstlisting that renders some lines of code. The code is indented by four spaces per indent. Is there any setting to change the indentation to only two spaces? I know that there is tabsize ...
4
votes
1answer
99 views

Insert section title within index in ConTeXt

Background Each recipe in a recipe book has ingredients, and those ingredients can be common for different recipes throughout the book. For example: Code I've added the comma and colours as ...
3
votes
1answer
767 views

listings: Set tabsize while using spaces for indentation in the loaded file does not work

I am writing a report where I want to include some source code. To do so I use the listings package to load the content of the source files directly. Because of coding standards I am using 4 spaces ...
1
vote
1answer
126 views

lst include has first line indented [duplicate]

When I'm including a source file, by way of \lstinputlistings{file/path/to/file} However, This results in the following below: Why is the first line not being formatted correctly? And how do i fix ...
4
votes
1answer
433 views

About autoindent and postbreak in the package listings [closed]

I am using the package listings to show my Matlab code. The code was pre-typed in a file and everything will be loaded from the file and a .tex file will be generated automatically to show the code ...
2
votes
2answers
163 views

Unindent code inserted with \lstinputlisting

Is it possible to unindent the code inserted using \lstinputlisting? In particular I'd like to be able to unindent by a fixed amount of whitespace. I have to write a relation on a OS scripting course ...
1
vote
0answers
106 views

Indenting listings in Auctex [closed]

I'm using the listings package to typeset some Python code. I don't seem to be able use the tab key in Auctex mode to indent my code within listings. I'm new to both Emacs and Auctex, but the only ...
9
votes
1answer
264 views

How to remove the indentation in list of listing

The list (from \lstlistoflistings) is indented compared to list of tables (\listoftables). How can I remove the extra indentations? \documentclass{memoir} \usepackage{listings} \begin{document} ...
8
votes
1answer
863 views

autogobble for lstinputlistings

In the manual for listings it says that gobble has no effect for lstinputlistings. Since the manual is about four years old now and after reading How to automatically skip leading white spaces in ...
16
votes
4answers
2k views

How to automatically skip leading white spaces in listings

This question led to a new package: lstautogobble (lstaddons bundle) For my programming lecture slides I heavily use the listings package with \lstnewenvironment to typeset source code. It's a ...
9
votes
3answers
3k views

How to make listings code indentation remain unchanged when copied from PDF?

So I am using listings package for code examples. But there is a problem. When I copy the code examples from the final PDF document, they are usually not the same - the indentation is gone, there are ...
14
votes
2answers
7k views

Indent a code listing in LaTeX

For a little LaTeX document I am writing I would like to insert source code fields (in SQL) into my paper. I found out that I can use the listings package for this, which works well so far: ...
9
votes
2answers
5k views

How to align source code produced by listings package with main paragraph text

I'm using the latex listings package for the first time to format some HTML. I'm noticing that by default, the html code is being pushed further left than the main paragraph text of my document. Is ...