Linked Questions

7
votes
2answers
3k views

How to mark whole line or part of line with background color in a listing (listings package)?

I want to highlight either a whole line of code in a listing, or a part of line (a subexpression) using background color (to not interfere with syntax highlighting). I use lstlistings environment ...
12
votes
1answer
3k views

Recent issues with lstlinebgrd package with listings after the latter's update[September 02,2018]

I could run the program without any problem while highlighting few lines of code using listings and lstlinebgrd packages. But the recent update of listings package v1.7 is giving me error even on the ...
13
votes
1answer
1k 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 ...
10
votes
1answer
2k views

Highlighting line ranges in a lstlisting: partial solution, but expansion issues

In my quest for a better solution for How to change appearance of a particular line when using \lstincludelisting, I came across the linebackground= option Martin Scharrer added to the listings ...
13
votes
1answer
549 views

Test if a number is in a comma separated range/list of numbers

Martin Scharrer posted a very elegant answer for the question "Creating a zebra effect using listings". I want to extend that code to highlight only lines given in a comma separated list. The ...
4
votes
2answers
3k views

change background color for some lines inside a `listings` block

I need to change background color for some lines inside a listings block. This is an example: \documentclass{article} \usepackage{listings} % Include the listings-package \usepackage{...
7
votes
1answer
924 views

Listing, zebra effect and broken lines

In Creating a zebra effect using listings, I've found one solution to produce a zebra effect for listing. Unfortunately, this only works if the lines are not broken. Is there a way to fix this? Here ...
7
votes
1answer
760 views

Alternate text style for odd and even line

I want to make someting like the lstlinebgrd package to creating a zebra effect. \documentclass{article} \usepackage{lstlinebgrd} \usepackage[english]{babel}%If not an error occurs \begin{document} \...
2
votes
1answer
977 views

lstaddons: Dynamic linewidth calculation

I use the package called "lstaddons" (creator, initial question) to get colored line backgrounds on listings. I want to color the whole line to the frame. What I miss there is a dynamic calculation ...
1
vote
1answer
948 views

Highlighting line ranges in listings

I've put here one adaptation for "no-beamer" documents of this code. Thanks a lot for the indications given below by Daniel. % Sources : % 1) https://tex.stackexchange.com/questions/18969/creating-...
0
votes
1answer
192 views

How can I add code highlighting for listings with different colour lines?

How can I create a listing design in LaTeX, with numbers on the left, and each line separated with colours like in the picture? I could not find such listing style for LaTeX.