3
votes
1answer
39 views

Change Character Color in listing

I want to change some special character's color in listing for example all Parenthesis be red. I don't want to make them keywords they should have different color. is it possible?
3
votes
1answer
59 views

How to define colors in style file (lstlang0.sty)

Per the listings package documentation, I have a file lstlang0.sty in the same directory as my .tex file (well, .lyx file) which defines a new language. I used to have this language definition in my ...
4
votes
0answers
77 views

Issues using listings package [closed]

I am using LaTeX to write my internship report (I started to learn it one month ago), and I have some issues using the package listings. I'm not sure if everything is possible: How can I add a ...
6
votes
1answer
100 views

Change the background color of line numbers in a lstlisting?

Consider the following code which deals with a lstlisting. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{listings} \usepackage{xcolor} ...
6
votes
1answer
136 views

Listing with two columns in a single fancy frame

I am playing a little with lstlistings and I wonder whether such a thing would be achievable for all my listings: How to achieve this kind of things? Note : I am searching for a solution I can ...
2
votes
2answers
63 views

XeTeX \color runaway argument

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

Can the listings package be set up to highlight Prolog code like minted does?

I am interested to know how listings can be customized to mimic the Pygments's Prolog lexer (i.e. make Prolog code represented by listings look the same as it is done with minted) I previously asked ...
6
votes
2answers
180 views

How can you highlight a C compiler directive spanning multiple lines?

In my \lstset{...} I have morecomment=[l][{\color[rgb]{0.1, 0.2, 0.8}}]{\#}, which I've seen used to give preprocessor commands colour. This works just fine but I'd like to get multi-line macros to be ...
11
votes
1answer
423 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 ...
2
votes
1answer
89 views

Add coloring rules for specified language keywords in lstinputlisting [duplicate]

I would like to add coloring definition for e.g. @Override in java files. How can I do that ? So far I have the following coloring definitions : \documentclass[a4paper,11pt]{article} ...
3
votes
1answer
203 views

How to embed special markers into the code listing that will mark certain parts of code to be colored using a custom scheme?

I would like to color my C# code listings as Visual Studio does. However, all language definitions that I found so far only color the keywords and not the user types. I understand that it requires ...
4
votes
2answers
113 views

How to colorize escaped math in syntax highlighted listings?

my listings are syntax highlighted using \lstset with escapechar=$ and commentstyle=\color[rgb]{0,0.5,0}. Now my C-code looks like int16_t speed; // calculated speed in $\(\frac{cm}{s}\)$ and the ...
3
votes
1answer
81 views

How to set a background color for a listing?

Someone who knows how to fill with color only the box? \begin{shaded} \begin{lstlisting} if (a < b) { printf("A is smaller than B!\n"); } a = b; \end{lstlisting} \end{shaded}
4
votes
1answer
200 views

How can I define multiple identifier classes and styles in listings?

I'm trying to add different styles (color, etc.) to different groups of words in the listings package. Note that my question is different from How can I use multiple declarations (\textbf, \emph) in ...
1
vote
1answer
51 views

Listing package only outputs black colored source code even though the language parameter is specified

The problem is pretty much in the title. With this code: \documentclass{report} \usepackage{listings} \begin{document} \lstset{language=Python} \begin{lstlisting} def ...
2
votes
1answer
176 views

Alternate colback and colbacklower in tcblisting

I have written a new environment based on tcblisting from package tcolorbox. I want the background color for code always in "gray" and the background color of the text compiled in "white". He held ...
4
votes
1answer
657 views

color a text line in a code {lstlisting}

I try to use the package xcolor into a lstlisting code as follows: \begin{lstlisting} \color{red}{text...} \end{lstlisting} but I can't color the "text..." comments. Someone could help me, ...
4
votes
1answer
174 views

Making Inline Code Printing Pretty

I have to include small code snippets like method and class names within continuous text. I do not want to display those snippets as complete seperated listings, they should be displayed inline, ...
5
votes
1answer
161 views

Unicode characters in a listing environment are not colorized!

When using the package listing, colorized comments will not yield colorized exotic unicode characters. This is a minimal working example: \documentclass{minimal} \usepackage{ ...
4
votes
1answer
170 views

Color lines in source code that is embedded in LaTeX

I am looking for a way to mark some lines in a source code sample that will be integrated into my LaTeX code. I already found solutions to embed source code and have syntax highlighting like this ...
5
votes
1answer
575 views

Change the color of background of code of Matlab

I use the following code in LaTeX to input the code Matlab there but I want to change the color of the background: \usepackage{textcomp} \usepackage{listings} \lstdefinestyle{customc}{ ...
1
vote
1answer
130 views

Syntax highlighting for SPARQL query in a listing? (works fine in minted environment but not in listing with mint)

I can do syntax highlighting in the minted environment, for any SPARQL query using this Pygments lexer thanks to this answer. My problem is how to get SPARQL syntax highlighting to work with mint in ...
3
votes
1answer
261 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 ...
4
votes
2answers
273 views

Various \textcolor within lstlisting?

How can you set various words in your lstlisting to various text colors? For instance, I want the word "fail" to appear in red and the word "pass" in green. I have the feeling there should be some ...
2
votes
1answer
588 views

More sophisticated syntax highlighting of Prolog code

I'm wondering, does listings allow you to define your own syntax highlighting, and if so, how sophisticated is its system? Here's a minimal example: \documentclass{article} \usepackage{listings} ...
6
votes
2answers
220 views

“Isodat” language source code syntax highlighting

Isodat language is used for Mass-spectrometers from ThermoFisher Scientific®, which is used for Stable Isotope Mass-spectrometry. Parts of the language's syntax highlighting has been explored in ...
5
votes
1answer
2k views

\textcolor within lstlisting?

I have some pseudo-code where I want to highlight some sections in a different color (this is why: in an assignment at university, I have some code given and have to adapt it. I want to highlight what ...
1
vote
1answer
156 views

XML with Listings: Different colors for attributes and elements

How can I make every attribute name in color X and every element name in color Y without adding keywords and stuff? What I did so far: \lstdefinelanguage{myXML} { morestring=[b]", ...
4
votes
1answer
796 views

lstlisting in a box?

My problem is that I am trying to write a document with coloured sections for examples. Examples can contain code listings. Somehow I can't seem to combine a background colouring with a listing, or ...
3
votes
0answers
221 views

Regular expressions in listings [closed]

I'm looking for a possibility to use regular expression in listings. I'd like to highlight each N thats followed by 4 decimal numbers for example N1234. How can I achieve that? Here is an example: ...
6
votes
1answer
950 views

Adding words to lstlisting for Python langaue

I wish to add a few keywords to some python code inserted into a latex document. I want to make 'True' & 'False' appear yellow and also some module calls such as 'ttk' appear red. I have tried ...
1
vote
1answer
205 views

lstlisting: how to align highlighted code

I want to define a couple of new commands in order to highlight parts of my code (this is actually for a trace dump, not for a programming language). My problem is that I can't seem to make the ...
4
votes
1answer
439 views

Why keywordstyle is not taken into consideration no bold, no red color?

When I have this code with .sty file from here \begin{lstlisting}[language=Go, firstnumber=1, captionpos=b, caption=Golang, label=amb] // You can edit this code! // Click here and start typing. ...
10
votes
2answers
624 views

How to highlight all words of the form [0-9][A-Za-z0-9]* immediately following an equal sign?

I am using the Latex Listings package to include code in a document. I need to implemented syntax highlighting similar to what you see in a standard IDE. I've been able to assign colors to comments, ...
7
votes
1answer
478 views

lstlisting border bug when breaking lines

I have a certain bug regarding listings. I have used the \lstset command to configure my lstlisting environment. Somehow, when I have a line that is too long to fit into one row the listing breaks ...
5
votes
1answer
1k views

Creating new colors in xcolor for use in listings

I'm trying to include some code using \usepackage{listings}. However the default look is not very pretty, so I want to customize it a bit. I've read some of the other posts about changing the layout ...
4
votes
1answer
387 views

\lstinline & \colorbox

Why the command below don't work? How can I fix it? \documentclass[11pt]{book} \usepackage[dvipsnames]{xcolor} \usepackage{listings} \lstset{language=[LaTeX]Tex, ...
6
votes
1answer
3k views

Add another color at other keywords in listings

How can I add another color at other keywords? For example: morekeywordsA={RequirePackage,ProvidesPackage}=\definecolor{keywordsA}{HTML}{8A4A0B} ...
1
vote
1answer
405 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 ...
5
votes
1answer
460 views

How to render Android listings with syntax highlighting?

I need to include the source code of a bigger Android project in the documentation written with LaTeX. Do you recommend any particular package that is capable of highlighting Java code and which also ...
4
votes
1answer
869 views

How to add color to source code under the listings environment

I would like to color a few keywords in my slides under the listings environment In the following contrived example, I would like to color the __shared__ word with orange and WIDTH with blue. How ...
8
votes
1answer
10k views

How do I add syntax coloring to my C++ source code in beamer

I have just learned how to insert source code into beamer with the listings package. However I dont know how to go about adding any syntax coloring on the C++ source code. How do I do that? Here ...
3
votes
1answer
642 views

Background color in inline code listings with linebreak

I want to highlight code inline with a gray background. Preferably with listings. This question is related to Colored background in inline listings. But as my MWE shows it doesn't work with line ...
1
vote
1answer
455 views

Using colorbox in a Listing/minipage with underscore “_”

I am having some issues with using \colorbox{}{} in combination with an underscore. The Listing will compile without issues and highlighting the text properly, but as soon as I have an underscore in ...
1
vote
1answer
355 views

Quotation mark in \lstinputlisting becomes white

How can I fix this issue with everything inside and including the "quotation mark" itself becomes white, in my case invisible due to the white background. Thanks in advance. I almost forgot that im ...
6
votes
3answers
709 views

Different background colors for lstinline

In the following code, I've decided to use the code from Colored background in inline listings so as to redefine \verb to have the possibility to use colors for the text and the background of the ...
4
votes
1answer
574 views

Avoid comment style for URLs in code listings

I using the following settings for code listings. \usepackage{listings} \usepackage{textcomp} \lstset{language=Java, keywordstyle=\color{RoyalBlue}, basicstyle=\scriptsize\ttfamily, ...
3
votes
0answers
444 views

lstlisting: how to color numbers in code [duplicate]

Possible Duplicates: How can I change the color of digits when using the listings package? Listings package: How can I format all numbers? How to color digits with the listings package ...
9
votes
1answer
2k views

Remove keywords from code 'listings'

I tried to customize a code listing to support some pseudo-code format that suited me best. It was easy to add keywords using otherkeywords or morekeywords, but the opposite, the deletekeywords did ...
4
votes
1answer
2k views

Color \ , [], {} and / in listings environment

I tried to color a source code listing as follows. I would like the \ to be the same color as the word that follows for example: \documentclass in red including "\" \usepackage in blue including "\" ...