4
votes
1answer
25 views

Inserting caption for listings in LyX

I'm using LyX 2.1.1 and want to put captions for listings. I can do this by using LaTeX code in ERT but would like to do by using LyX built-in capabilities of Insert > Program Listing. Any help ...
4
votes
2answers
45 views

Latex listings package, issue with caption touching the frame and junk character instead of space

I am using listings package and facing two issues Following is the LaTeX code and output \lstset{language=Java, basicstyle=\small, frame=single, breaklines=true, ...
3
votes
0answers
28 views

Using lstinline in caption of lstlistings with multicol?

Consider this MWE: \documentclass{article} \usepackage{multicol} \usepackage{listings} \begin{document} \def\extra{extra} \begin{lstlisting}[ multicols=2, caption={ [short] aaaa \extra, ...
7
votes
3answers
115 views

Only get filename and extension of listing, not whole path

I am trying to add the file name as caption. I was able to do this setting caption=\lstname but this shows the full path. I am now trying to get the name of the file and extension to show only. I ...
4
votes
1answer
66 views

Distorted caption in listings

The following code produces strange results. Everything looks fine, if I don't include the subfig package or don't use the xleftmargin parameter. It also works if I use captionpos=t. Is there a ...
7
votes
1answer
109 views

Hyphenation in listings captions doesn't work correctly

I have the problem that automatic hyphenation in listings caption doesn't work if automatic linebreaking is activated. It works if I set breaklines=false or captionpos=t, which is weird. Is there a ...
2
votes
0answers
79 views

How can I apply different custom caption styles to different listings?

In the MWE below, is it possible to define different caption formats for the two listings? In the example the first listing should use a blue caption background (like it is now) while the second ...
1
vote
1answer
63 views

Optional caption in listings (for listoflistings)

I have some cites in my captions. But I do not want to appear them in the table of figures or listings. With figures I managed to display an different caption like this: \begin{figure} \centering ...
4
votes
1answer
185 views

Final linebreak in lstlisting, and linebreak in captions (with IEEEtran)

Using: lstlisting in two columns How to add line break to caption without using caption package ... I got to the following MWE: % \documentclass[12pt,a4paper]{article} ...
5
votes
1answer
249 views

Fixing vertical spacing after \captionof as a custom caption

I'm trying to get a single caption after two columns of code. For two columns, parcolumns is the only method I've found that allows a page break in the middle and is my current favorite. Using ...
4
votes
2answers
128 views

How can I reverse the caption numbering in listing

How can I make a reverse numbered caption with listings? So the package makes ''Listing 1.1'' style captions but I need it in form ''1.1 Listing'' .
4
votes
1answer
136 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 ...
1
vote
0answers
20 views

Change language of caption in lstlisting [duplicate]

When I define a caption in lstlisting, LaTeX writes, for example, "Listing 1.1: ..." but I want to change the "Listing" to another language. How can I do this?
4
votes
1answer
116 views

How can I mimick the listing caption style for my custom “Listing (cont.)” caption?

I have the following LaTeX code which works fine: \documentclass[12pt,a4paper]{article} \usepackage[a5paper]{geometry}% just for the example \usepackage[utf8x]{inputenc} \usepackage{listings} ...
2
votes
1answer
187 views

Footnotemark in caption of listing causing problem

I have the following listing: \begin{lstlisting}[float=h,caption={Description\footnotemark.}, label={listing2}, keywordstyle=\color{blue}\bfseries, ndkeywordstyle=\color{black}\bfseries, ...
7
votes
1answer
129 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} ...
0
votes
0answers
122 views

multiple listing styles with hyperref and caption packages

This is a follow-up question to Multiple listings styles. The MWE from the accepted answer works fine. Unfortunately, when I add the hyperref package OR the caption package (or both of them), the ...
1
vote
1answer
507 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 ...
2
votes
1answer
101 views

Multiple listings in one box with sub captions and using listings counter

I am using separate counters for (graphics) figures and listings. I am using the caption and subcaption packages. I construct sub-figures using subfigure: \begin{figure} ...
3
votes
2answers
142 views

Caption package destroys center/varwidth

I have received a wonderful comment how to get listings centered: \documentclass[a4paper]{book} %\usepackage[hang,small,it,hypcap=true]{caption} % screw hypcap \usepackage[T1]{fontenc} ...
10
votes
1answer
300 views

How to force lstlisting caption names and numbers to always appear, even when captions are empty?

I noticed lstlisting environment seems to supress the caption name and number when no caption is specified. See the code below: \documentclass{article} \usepackage{listings} \lstset{language=C} ...
4
votes
1answer
236 views

Captioning an mdframed box without making unbreakable

I would like to a have a caption below my mdframed box (outside the border if possible) which sometimes span across multiple pages. I managed to create a caption several ways but the pagebreaks are ...
2
votes
1answer
216 views

Adding caption and counter to source code environment

I have a source code listing with minted environment. How can I make a counter/caption to be shown as follows. I also need to make \tableofsourcecode to enlist all the source code references. The ...
3
votes
1answer
198 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 ...
3
votes
1answer
1k views

Change caption style of listings package without “caption” package

Is there a way to change style of a caption in listings without the caption package (make it smaller and non-bold)? I am using \lstnewenvironment to create my own customized environment and then use ...
3
votes
1answer
272 views

Problems customizing listings captions

I'm trying to "decorate" source code with listings, but I'm getting some warnings and bad boxes when I compile my document. However the document compiles and looks like I want. I noticed the warning ...
6
votes
3answers
526 views

Hang caption in lstlisting

If I use the following command \usepackage[skip=20pt,hang]{caption} when a caption is very long it hangs in figures and tables, however, if the caption is of a lstlisting environment it doesn't. ...
6
votes
2answers
247 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
99 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
26 views

How to use \lstinline inside figure environment's caption argument [duplicate]

Here is the code that I have (I have removed parts which I think are not relevant): \documentclass[12pt]{article} \usepackage{listings} % Python style for highlighting ...
2
votes
2answers
394 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
1answer
4k views

Styling a lstlisting caption using caption package

I'd like to style a caption in a specific way, but I can't seem to figure out the proper settings to do so. First off, I'd like to change the label from "Listing" to "Algorithm" when I use ...
4
votes
1answer
415 views

listings caption gray box meaning of code

Some time ago I copied this code from Stackexchange to have a nice gray box at the top of my imported source code which I displayed with listings: \DeclareCaptionFont{white}{\color{white}} ...
6
votes
1answer
369 views

Multiple listings styles

In using the listings package, how can I have a distinct \lstlistingname value for each type of listing. Lets say my document has C++, R and Pseudo listings, and I would like the \lstlistingname ...
5
votes
1answer
245 views

Wider caption for listing using multicol

I am using the multicol and listings packages. I would like to have the caption spread across the entire listing for multi-column listings. Here is a MWE of what I am attempting, however the output ...
4
votes
1answer
236 views

Command to insert filename in caption of a listing

I would like to have a command to insert listings that contain the filename in the caption. This works well as long as there is no "_" etc. in the filename. I also tried the suggestion from a ...
2
votes
1answer
133 views

Getting lbr frame lines in a listing up to the caption box above it

I have a document similar to this: \documentclass[twoside,11pt,titlepage,a4paper]{report} %unterscheidung zwischen gerade und ungerade seite, 11pkt, kp, kp \usepackage[T1]{fontenc} %inputcodierung ...
11
votes
2answers
778 views

Center caption in listing

I want to put the caption of my listing in the center but I can't do that. Do you have any idea how I could achieve this? The code: \documentclass{report} \usepackage{color} \usepackage{xcolor} ...
4
votes
1answer
155 views

Caption for a listing

I have captions on each of my listings. Each caption is prefaced with "Listing # [text]" where # is the number of the listing. Each caption is centered over my listing. How can I modify the options of ...
2
votes
0answers
240 views

Page break before caption in lstlisting [closed]

I have the following settings for a lstlisting: \lstset{ language=XML, numbers=left, numberstyle=\tiny\color{gray}, stepnumber=1, numbersep=5pt, ...
1
vote
1answer
108 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 ...
1
vote
0answers
61 views

How to setup the caption and listings package to insert code? [duplicate]

Possible Duplicate: Caption parbox 6.0 pt too wide I used caption and listings package in my .tex file as below: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \lstset{ ...
5
votes
1answer
3k views

How to change listing caption?

I have some listings that contain pseudo-code of algorithms. And I use this: \lstset{caption={Descriptive Caption Text},label=DescriptiveLabel} to add captions to them. My problem is that the ...
4
votes
2answers
775 views

Listings package with caption legend in spanish

I'm using the listings package and would like to translate the caption text displayed to Spanish, so instead of Listing 1: Dummy label it will display Listado 1: Dummy label. This is my code: ...
4
votes
1answer
810 views

How to center listings caption?

I would like to know how to center the listings gerenated caption in LaTeX. It always go to the left of the code. The rest of the captions (tables) are OK. \documentclass[11pt,a4paper,oneside, ...
6
votes
1answer
884 views

Adjusting Vertical Spacing between a listing and its Caption

I am very new to LaTeX. I am inserting a listing as follows: \lstinputlisting[float=hk, caption=My Caption comes here, captionpos=b, ...
1
vote
1answer
2k views

How to customize the caption format for \lstinputlisting

I know how to customize the caption format of lstlisting environment. But how to do this if I used the \lstinputlisting command to import code? My document contain below snippet. \begin{framed} ...
5
votes
1answer
1k views

cite in caption of listings

I am trying to cite a paper in the caption of listings. I have the following code: \begin{lstlisting}[caption=Example of something (Adapted from \cite{abc})] example \end{lstlisting} But this is ...
4
votes
1answer
305 views

listings caption is distorted

I used listing for listing the codes like: \documentclass[prodmode,acmtecs]{acmsmall} % Package to generate and customize Algorithm as per ACM style \usepackage[ruled]{algorithm2e} ...
6
votes
3answers
449 views

Invisible listing captions

Short version: how can I make a listing's caption show up in the List of Listings but not in the body of the document where the listing is? I'm writing a university report, and many of my subsections ...