0
votes
1answer
151 views

How to place the caption of a lstlisting in the margin? (scrreprt, floatrow)

In the following mwe I am using the floatrow package to place the figure captions in the margin. How can I do the same for listings? Update: Some listings are spread over two pages. ...
7
votes
0answers
48 views

Adding color package destroys listing centering

I am using @egreg's answer to make listings centered: \documentclass[a4paper]{book} \usepackage[T1]{fontenc} \usepackage[ hang, small, it, hypcap=true ]{caption} \usepackage{fancyvrb} ...
1
vote
0answers
28 views

How to display a code using lstinputlisting that isn't separated with figures?

This is the code I used: \lstinputlisting[language=Python,breaklines=true]{seminar_ED.py} It works fine with displaying the code over multiple pages when I don't add other figures in the text. But ...
1
vote
0answers
55 views

Center code in a lstlisting float

Out of pure laziness, I decided to create lstlisting floats with the option offered by the package: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \begin{document} ...
11
votes
2answers
185 views

How can I move floats that aren't tables or figures to the end of a document (endfloat for listings)?

I use endfloat to move all figures and tables to the end of my document. I want to apply the same to other floats that I have in my document, for example listing environments. Is there some hack that ...
2
votes
1answer
99 views

Listings float with sublistings

I want to have 2 listings side-by-side in a float environment with its own name (i.e. Listing 1 instead of Figure 1) and counter (so that I can have a separate listoflistings besides listoffigures). I ...
3
votes
1answer
173 views

Code listing in subfigure using lstlisting

I am trying to use the subfigure package of LaTeX to display a piece of SQL code. The purpose is similar to Code listing in subfigure, but I'd like syntax highlighting using lstlisting environment ...
4
votes
1answer
139 views

How to handle listings, fancyvrb, newfloat and caption?

I am planning a "small thesis" for university which will need to display lots of code (C, C++, gnuplot, LaTeX, ...) - thus I spent this evening reading about listings and fancyvrb. The latter I've ...
3
votes
1answer
141 views

Floatable centered and non-splittable lstlisting

I've been looking around and tried various setups but have yet to found the solution. I'm trying to define a lstlisting environment that is a float, is centered in the page, and cannot be broken ...
7
votes
1answer
135 views

Equal spacing for figures and listings

I want to include figures and listings in my document and I want them to have the same spacings to text and captions. \documentclass[a4paper,12pt,openany,parskip,oneside,ngerman,headsepline]{scrbook} ...
5
votes
1answer
76 views

Preventing a code listing of multiple pages to be split to several parts

I have a lstlisting that doesn't fit on one page. It continues correctly on another page but instead of putting the last lines in the beginning of the next page it actually splits into three parts on ...
1
vote
0answers
38 views

Listing Moved to End of Document / Other Locations [closed]

I have a listing that is pretty long and it's forced to the end of my document. If I shorten the code, I've noticed it allows it to stay where it should be, otherwise it gets pushed behind/in front of ...
12
votes
1answer
215 views

How to make figure and listing share their counter

I'm using the "listings" package to write pieces of code (XML, RDF, Java, etc) and I want them to have the same counter of the Figure environment. For example, Listing 1: blablabla Listing 2: ...
1
vote
1answer
611 views

Caption below lstinputlisting in multicols + redefining lstlisting caption format

I have 2 problems with caption for lstlisting. I can't get the caption of lstlisting to go below the list when it's in a multicols environment. Although I've added ...
3
votes
1answer
211 views

How to have center title in listings when you have subcaption (workaournd conflict between listing caption and subcaption class)?

I want to use listings package (\usepackage{listings}) to show a matlab code in a paper (using elsarticle class) but the title is not aligned in center below the code. This happened after I added ...
8
votes
2answers
178 views

Allow source code to wrap around a figure

I would like to be able to wrap source code around a figure. Here's a MWE that should make it clear what I have in mind: \documentclass{article} \usepackage{wrapfig} \usepackage{listings} ...
4
votes
1answer
274 views

Placing listing and figure side by side in memoir

I am writing a document using the memoir class where I want to place listings (with the listings package) and figures side by side. My first approach was to save the listing in a box and use subbottom ...
4
votes
1answer
124 views

custom float (newfloat): entry in listoflistings is not indented

I'd like to use a custom floating environment for lstlistings so as to be able to draw frames around the listings using mdframed. My float uses the same counter as lstlisting, and also appears in the ...
6
votes
2answers
268 views

`listings` and `sidecap` - Side captions for listings

I am using the package sidecap for captions which appear left or right of a picture/table, like so: \documentclass[a4paper,twoside,11pt,openright]{scrbook} \usepackage{graphicx} ...
1
vote
1answer
103 views

How to set identifier “Listing 1” in listing in bold

I use figures and listings in a document. By default, the identifier "Figure 1" is set in bold, while "Listing 1" is normal. For consistent looks I would like to have either everythin bold or normal. ...
1
vote
0answers
123 views

LaTeX places a float in the middle of my script. How do I prevent this? [closed]

I have a multi-page script in my thesis, and I have used the listings package to format the source code. This works really well, however LaTeX wants to put a float in the middle of this code, which ...
2
votes
2answers
418 views

Code listing spanning multiple pages with captions at top

Is it possible to span a lstlisting environment or lstlistinginput on multiple pages, such that the caption is repeated on each page (the listing counter stays the same), as well as being able to ...
3
votes
2answers
402 views

Subfigure with lstlisting: what am I doing wrong?

It keeps telling me: \begin{document} ended by \end{figure}, but I do not understand why. I tried to follow the guidelines for the subfigure package. Here is my MWE: ...
4
votes
1answer
142 views

Dirtree and lstset side by side

A \dirtree and a \lstset should be shown side by side. With the code below the \dirtree is vertically not on the same level as the \lstset (above the \dirtree is some empty space). How can I fix that? ...
1
vote
0answers
57 views

How to add a caption to a listing with minted? [duplicate]

Package minted provides a way to add captions and labels to a listing wrapping it around with listing environment. With this environment the code block is put inside a floating box which won't break ...
2
votes
1answer
152 views

resizebox fails for tikzpicture when used in conjunction with listing package

Here is the example that fails \documentclass{standalone} \usepackage{tikz} \usepackage{float} \usepackage{listings} \usepackage{color} \usepackage{textcomp} \usetikzlibrary{shapes,positioning} ...
5
votes
2answers
104 views

How to combine listing and figure into a single figure?

I am using package listings, and I would like to combine a listing and a figure into a single float. As an example, I am using listings as follows: ...
3
votes
1answer
2k views

Set my lstlisting at the exact place in my code (like “h” for figure)

When using lstlisting, my displayed code is sent back on the top of my page. I would like to have the same kind of option as: \begin{figure}[h] ... \end{figure} ie having displayed my code exactly ...
1
vote
0answers
565 views

How to force LaTeX to place a figure exactly where I want [duplicate]

Possible Duplicate: Force figure placement in text How to influence the position of float environments like figure and table in LaTeX? How can I force LaTeX to insert a figure exactly ...
5
votes
1answer
207 views

Floating text around listing

I can't manage to let my text float around an listing. Assuming I have a text paragraph and I want the listing to be at the top right place with a certain width, and to be floated by the text. ...
2
votes
1answer
263 views

Picture breaking listing

When putting long code using lstlisting on a page it breaks, which is fine. When placing a picture in a floating figure environment, it gets between the two parts of the listing, which obviously is ...
2
votes
1answer
250 views

How to prevent figures from floating 'into' listings [closed]

I have a problem with floats and listings. Sometimes it happens that a listing is split over two pages and when a figure is near the listing it happens that the listing starts on the first page, on ...
12
votes
3answers
4k views

Avoid page breaks in \lstlistings

I'm trying to avoid page breaks in my lstlisting (seen in section 0.0.2) I know I can remedy this by floating my lstlisting, but it adds some unwanted white space (seen in section 0.0.1). Is ...
1
vote
1answer
109 views

Order of `float` and `caption` packages in preamble

I am using float and caption packages in my document, and also packages like tabularx, listings, algorithm... that (as far as I know) define floating elements or elements that have captions ...
2
votes
1answer
185 views

How to define different spaces below float and non float listing?

I am using listings from the listings-package. I'm having a problem with spaces below the listings. I use both, float- with h and non-float listings. The problem now is, that the spaces below the ...
6
votes
2answers
938 views

How to make a float that is not labelled 'Figure' but 'Listing'

I would to include my listings as floats, pretty much as Figures, but I don't want to call them Figures. I want to call them listings. How can I do that?
0
votes
1answer
443 views

Incorrect page number in List of Listings

The problem I'm having is that page numbers, in a List of Listings, are frequently off by one page. I'm using the listings package and I have a List of Listings in the beginning of the document, ...
4
votes
1answer
1k views

lstlisting ignores float setting

My document starts with: \begin{document} \lstset{ % language=Java, float=tb } However all listings appear exactly just where they have been defined, e.g. this one: ...
7
votes
1answer
2k views

Figure breaks listing, how to avoid that?

I have a listing in my document and some lines before it I'm inserting a figure, doing the following: \begin{figure}[htbp] \begin{center} \includegraphics[scale=0.7]{filename.png} \caption{Caption} ...
3
votes
1answer
767 views

multicols, lstlisting and float

Using the following structure, how can I get the listing to stay on the same page, be it at the top or the bottom? \documentclass{scrartcl} \usepackage[ngerman]{babel} \usepackage{multicol} ...
7
votes
1answer
2k views

How to change “Listing 1. Caption” to “Figure 1. Caption”?

I have a listing like so: \lstset{language=Python,caption={Caption}} \begin{lstlisting} some Python code goes here \end{lstlisting} In the PDF this appears as Listing 1. Caption. How can I make it ...
8
votes
1answer
350 views

How do I create a new command \listofcodes in latex?

In addition to tables and figures, I have a bunch of code pieces. Just like follows: \begin{figure} \lstinputlisting[ language=C++, breaklines=true, keywordstyle=\color{blue}, ...
2
votes
1answer
593 views

Changing Listing and Figure caption system in Platex

I'm working with platex (the Japanese latex compiler) and I'm trying to change the caption system for Listings and Figures. For both I would like the numbering to be based on section so if its a ...
2
votes
1answer
140 views

Increase listings spacing through the package listings or use figure instead?

This is more a conceptional question on how to use LaTeX in the right way. So far I have striven to customize only those things in LaTeX which are supposed to be without messing to much with print ...
7
votes
3answers
6k views

Rename “Algorithm” to “Listing”

Background Syntax-highlighted source code image listings are being used as Algorithm floats with the lst: prefix for captions. Problem The following LaTeX code in the preamble renames the caption ...
5
votes
2answers
458 views

Which package for In-line and float algorithms?

I am using LyX to describe algorithms. A common scenario is that I have a snippet of pseudo code (in a float, for example) and a block of text which makes references to keywords in that pseudo code. ...
10
votes
2answers
2k views

Splitting a float with code listings

Using the floats and listings packages, I have defined a float for code listings and a shortcut for using it as follows: \usepackage{floats} \usepackage{listings} ...
11
votes
3answers
584 views

Why can't I use \newfloat more than once?

I've found the float package, which lets me specify \newfloat{program}{...} to get other named floats than Table and Figure. However, if I try to use this more than once, I get a cryptic error: ! You ...
4
votes
1answer
259 views

Combining a userdefined float inside a shadowbox

Is it possible to combine the "program" part in a shadowbox? \documentclass{article} \usepackage{float} \floatstyle{ruled} \newfloat{program}{thp}{lop} \floatname{program}{Program} ...