7
votes
2answers
138 views

highlight line numbers in listings

I would like to highlight the line numbers of the lines I refer to with lstlistings. I use escape characters to define labels in my Listing to which I refer later in my document (e.g. see Line X of ...
6
votes
1answer
45 views

Actual line numbers for listings: firstnumber=\inputlineno is off by one

I would like to have the actual line numbers next to my code listings but if I use firstnumber=\inputlineno, this gets evaluated one line too early: \documentclass{article} \usepackage{listings} ...
3
votes
1answer
36 views

Append characters after line numbers when using the `listings` package?

Is it possible to add some characters, like colons, to the line numbers when these are displayed in the listings package? There is the numberstyle option, but that only seems to affect stuff before ...
4
votes
1answer
67 views

Changing side of line numbering in two columns documents part two

I have the same question as this one: tex.stackexchange.com/questions/9510/changing-side-of-line-numbering-in-two-columns-documents/ I'd like to use the listings package in a twocolumn document. An ...
11
votes
1answer
424 views

Using listings: “zebra effects” AND line numbers

I just made a code listing with a "zebra effect", just like here: Creating a zebra effect using listings But afterwards, the line numbers at the left side of the listing don't appear any more. This ...
1
vote
0answers
118 views

Listings: spacing between linerange and numbering [closed]

This is a combination of hacks, and only of interest for those who want hacks down to the detail. It is actually a two part question. I was going through some listings setups and hacks: Firstly ...
1
vote
0answers
28 views

Is it possible to automatically set numbers=none for single-line lstlisting environments? [duplicate]

I apologise if the answer to my question can be found in the listings documentation and I missed it. Essentially I would like line numbers to be set only if the number of lines is greater than one.
0
votes
1answer
196 views

Only Select Code without Line Numbers [duplicate]

I'm writing a LaTeX document and want to include several listings for source code examples. Is there a way to disable the selection of line-numbers when selecting the source code? My prof just wants ...
6
votes
1answer
391 views

Listings line numbers that match the linerange specification

This is a follow-up question to First line number in lstinputlisting environment. Consider the MWE: \documentclass{article} %\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox ...
4
votes
2answers
1k views

Continue line numbers in listings package?

I have been using the listings package to present my source code in LaTeX. However, I can't get the line numbers to continue between two separate user-defined listings that have been given the same ...
7
votes
2answers
385 views

How can I use line numbers with leading zeros?

I use the listings package for source-code and have read all documentation. However, it appears that leading zeros for line numbers are not implemented as standard option yet. How can I redefine the ...
3
votes
1answer
100 views

how to better control the number display of listings?

I'm using the listings package for my sourcecodes, and among other things to control the display of those, I'm using \lstset, obviously. Now, When setting numberstyle, I've set them to ...
11
votes
1answer
556 views

Line numbering using listings package starts at random number

I'm using the listings package to include code directly from a file. In the first instance my code is numbered as I want it 1 at the 1st line, 11 at the 11th, ... However, the second block of code it ...
3
votes
2answers
1k views

Listings line numbers and figure

I'm using listings to typeset some C inside a figure environment next to a diagram, and I have the numbers on the left. My problem is in two-column mode the line numbers appear in what should be the ...
6
votes
1answer
158 views

Is it possible to change the font of line numbers in a code listing?

Using LyX I can add line numbers to my code listing. However, these are in the document (serif/Roman) font and look strange next to code blocks (Typewriter font). Is it possible to change the font of ...
8
votes
2answers
305 views

How do I prevent conflicts between accsupp and hyperref?

This question is related to the answer to the question Is there a LaTeX trick to prevent a PDF viewer from copying the line number? Unless you turn hyperref off, the following MWE ...
61
votes
3answers
2k views

Is there a LaTeX trick to prevent a PDF viewer from copying the line number?

A PDF output is obtained by compiling the following code. \documentclass{article} \usepackage{xcolor} \usepackage{listings} \lstset { language={[LaTeX]TeX}, numbers=left, ...
5
votes
1answer
491 views

Shared line counter with \lstinputlisting

Using the listings package, you can name your listings to make them share a line counter: On the other hand you can use firstnumber=auto and name your listings. Listings with identical names ...
4
votes
1answer
875 views

Custom line numbers in lstlisting environment

I am using the lstlisting environment to display code and it works great, however for my current application I need something like: line 1; 3.1: line 2; line 3; 3.1.5: line 4; ...
4
votes
1answer
799 views

Suppress line numbering for specific lines in listings package

I would like to suppress the line numbering for specific lines in listings package by identifying the specific lines using some kind of command.
6
votes
2answers
1k views

Suppress line numbering for empty lines in listings package

The listings package quite nicely formats my pseudo code listings. Is there a way that one can specify that line numbering should be suppressed for empty lines?
2
votes
2answers
318 views

Wrong numbering of lines in lstlistings when using escaped commands

I'm using the listings package to format some Java code in my document. I want it to number lines (1 number every 5 lines), and I need to highlight some keywords inside the code with the following ...
5
votes
1answer
2k views

In listings, how to show referenced linenumbers instead of standard ascending linenumbers

I'm just writing on my master thesis and have a (specific) problem with lstlisting package in LaTeX. I'm referring to the Random.class-file in Java and only want to print some specific line-ranges, ...
7
votes
1answer
2k views

Listing with line numbers inside a table

I typeset a lot of listings (using the listings package) inside (array-based) tabular environments. This works like a charm, however, breaks when I pass the numbers= option to the listing: ...
8
votes
1answer
3k views

How can I start the line numbering of my listing by an arbitrary number?

This is what I want: 15 <servlet> 16 <servlet-name>udpListener</servlet-name> 17 <servlet-class>oli.servlet.UdpServlet</servlet-class> 18 <!-- UDP Port fuer ...
3
votes
3answers
975 views

Changing side of line numbering in two columns documents

I'm trying to type some report and I have a small problem with the twocolums document class and the line numbering in listings. The document is on two columns : ...
1
vote
1answer
427 views

line numbering of minipages

I can't manage to add linenumbers left of the boxes. Can anybody help me? \documentclass{article} \begin{document} \fbox{\fbox{ \begin{minipage}{0.8\linewidth} \textbf{def} mapper (key, value): ...
6
votes
1answer
4k views

First line number in lstinputlisting environment

I use the following code to display line 23-45 of sort.cpp: \lstinputlisting[language=C++,linerange=23-45]{sort.cpp} However, the line numbering starts with 1 while I want it start at 23. I found ...