Questions tagged [listings]

{listings} is a package that extends LaTeX's {verbatim} features. A variety of syntax highlighting options are available. For general questions about {verbatim} or {highlighting} use the respective tag. For the unrelated concept of list structures, use {lists} instead.

Filter by
Sorted by
Tagged with
2
votes
1answer
20 views

Is it possible to indent the line numbers in algorithmicx the same as in Listings?

By default, the line numbers in algorithmicx are inside the float rules. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{algorithm, algpseudocode} \begin{document} \begin{algorithm} ...
0
votes
0answers
11 views

Long commentaries lst (R)

I am making a Latex docuemnt where I have to input some code in R with the command \lstinputlisting. I have my own style defined with the following configuration: \lstdefinestyle{mystyle}{ ...
2
votes
2answers
542 views

How to get a monospaced sans-serif font for the source code when using lstinputlisting

I have a document similar to this: \usepackage{listings} \begin{document} \lstset{language=Matlab,% basicstyle=... } \subsection*{Matlab code} \lstinputlisting{../myScript.m} \end{document} I ...
1
vote
0answers
42 views

Pretty displaying code in beamer

I am currently making my first beamer presentation, so forgive if this is a very trivial question. I have tried to research how to display code on a beamer presentation. I have managed to do this ...
0
votes
0answers
12 views

Listings define language in a separate file

I'm currently working on a paper where i want to showcase some JavaScript Code Snippets. I am using the listing package and defined JavaScript with \lstdefinelanguage. Since the command with its ...
0
votes
0answers
11 views

lstlistings in a two column setup

How can I use lstlisting in a two column setup, meaning that the code block is spreading over both columns? (lstlisting* is not valid.) - I dont want two listings side by side!
0
votes
1answer
37 views

Listing not fully filling background with escape inside

I made this minimal example to showcase the problem I am having: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{background}{HTML}{EEEEEE} \definecolor{xmlOrange}{HTML}{...
0
votes
0answers
12 views

Top/bottom margins in Listings

As seen in the screenshot below, the text is way too close to the background borders, the problem is solved on the left side using framesep but as I don't want to change the appearance of my framing, ...
1
vote
1answer
24 views

remove the dashes that appear at the top

Using the listings package I tried to mimic the Matlab R2016a environment with the following code: \documentclass[12pt,letterpaper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \...
1
vote
1answer
31 views

Why using @ inside \newcommand gives “Undefined control sequence” error?

I'm trying to create a command that temporarily changes the size of a lstinline, so that I can properly use it in a footnote. The following commands seem to work fine: \makeatletter \lst@AddToHook{...
0
votes
1answer
12 views

Postbreak token for listings not working in beamer

I have the following latex code: \documentclass{beamer} \usetheme{Frankfurt} \usepackage{listings} \lstset{ basicstyle = \linespread{1}\ttfamily, breaklines=true, postbreak=\raisebox{0ex}[0ex]...
0
votes
3answers
140 views

Listings: consistently colouring numbers

I have been using this solution found here at LaTeX Stack Exchange for colouring numbers in my code excerpts: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \makeatletter %%% ...
1
vote
1answer
40 views

Automatic line break with backslash in listings

I would like to use listings to format bash commands in such a way that overly long lines are automatically broken with a backslash. I know about the prebreak option, but it appears as though it is ...
0
votes
1answer
38 views

Using listings, copy bash command in 1 line

Im trying to insert in my PDF some long bash commands like this one: I like how it looks but, when trying to copy, it splits the command into 3 lines, which obviously is not how I would like it to ...
0
votes
1answer
12 views

Break longer word into lines to fit the box (inputminted?)

I would like to fit the long string (as it is labelled url in the json file) inside the box without overflowing. As far as I understand, breaklines option only helps when strings consist of separated ...
3
votes
1answer
65 views

How to use bicaption and how to define bilingual names for lstlisting?

I need to write bilingual captions for codes in a paper, but I do not know how to use \bicaption for lstlisting. Also, I want to change the name of lstlisting to Code in the bicaption. I know I can ...
1
vote
1answer
34 views

How to make at operator while listing program?

When I am inserting mathematica codes with the package listing, I find that it recognize at as a letter rather than an operator. This comes into a result that, for example when typing N@Table[10,5], ...
0
votes
1answer
42 views

How can I use commands in a listlisting

I have the following latex code \begin{lstlisting}[escapechar=\%] begin begin \alpha; i = 5 ... \end{lstlisting} and I would like to have the \alpha be rendered as a ⍺ but it seems to ...
1
vote
0answers
15 views

Listings morekeywors is no adding special caracters like ::, + etc [duplicate]

when i use morekeys in the lstdefinestyle it succesfully adds any word but it doesn't work with some characters like +,<, etc. this is the style: \lstdefinestyle{ligth}{ morekeywords = [1]{}, ...
0
votes
1answer
26 views

Change listing colors and allow auto-indent

This is my listing whose code is: \lstset{ inputencoding=utf8/latin1, language=Java, % choose the language of the code numbers=left, % where to put the line-...
2
votes
2answers
39 views

Change font only used in listing and not in rest of document

I created a \lstdefinelanguage command for some JSON blocks I'd like to add into my document, I followed the answer to this question: How to improve listings display of JSON files? In the answer the ...
1
vote
1answer
32 views

Is there a way to use the listings package together with mathpartir's mathpar

I'm trying to typeset a small-step semantics for a programming language. My plan was to use the mathpartir package for writing the inference rules and the listing package to typeset the language ...
0
votes
0answers
30 views

Color in lstlisting is black to different language

I am new to XeLaTeX and I want to display python code using listings package. The problem is that greek characters in comments or strings are colored black. This is a MWE: \documentclass[a4paper,11pt]{...
1
vote
1answer
40 views

Listings custom counter

I've wanted to create custom listings style with its own counter. The problem I have right now is that the counter is not increased by 1 but by 2. Here is an example: Output: First listings counter is ...
0
votes
1answer
24 views

Use custom delimiter for inline minted environment

Using the listings package, we can do the following to create a | (pipe)-delimited inline code environment: \lstMakeShortInline| I am interested in using the minted package instead, however it doesn'...
1
vote
2answers
23 views

lstinline puts space before dot

I am trying to use \lstinline to style filenames in my document, but it puts some random whitespace befor the dot. I presume it has to do with autosettings for punctuation? Can I deactivate this with ...
5
votes
2answers
1k views

IPython Notebook input and output cells with listings

I would like to include both input and output cells that look like Jupyter IPython cells. The "IPython Notebook cells with listings" at IPython Notebook cells with listings shows how to do a single ...
0
votes
0answers
18 views

Rule above caption of lstlisting too long inside itemize

I want to use the caption package to insert a horizontal bar above the caption/title of a lstlisting environment (+ some other stylings which are not relevant here). The minimal example below shows a (...
9
votes
2answers
8k views

How can I highlight JSON string values but not attributes?

example { "name" : "alan", "alias" : "nala" } If I use morecomment=[s][\color{red}]{"}{"}, How can I highlight JSON string values (on the right side) but not the attributes (left side)?
1
vote
1answer
34 views

Degree symbol and \lstinputlisting

How can I print a degree symbol (°) in a listing with \lstinputlisting? I have noticed the questions based on the lstlisting environment but it does not work with \lstinputlisting. This illustrate the ...
1
vote
1answer
31 views

decrease monotype letter spacing in lstlisting

I'm using listings to display code in my document and tgheros font. How can I decrease the monotype letter spacing for code listings? % in my preamble \usepackage{listings} \usepackage{tgheros} % ...
0
votes
0answers
24 views

Command that would treat all arguments as string

I have this command that makes gray boxes around text. How do I make sure that eveything I put as an argument there is treated as a string and gets rendered like an inline gray box? \documentclass{...
26
votes
4answers
8k views

The 'listings' package and UTF-8

Please, do you know if there's any possibility how to use the listings package together with XeLaTeX? I have to use XelaTeX and therefore I have UTF-8 encoded files. This is not compatible with ...
1
vote
0answers
13 views

listing pre- and postbeak gives error in beamer slide

Following this answer, I've tried to embed a listing with long lines into a beamer frame. I'd like to have a nice red arrow at the line break (as show here). The parameters prebreak and postbreak give ...
7
votes
2answers
12k views

How to change the font style and size for the \lstinputlisting

I am trying to insert some piece of code into my document, using the \lstinputlisting command. However the fonts displayed do not look too good. Is it possible to change the font size and style?
0
votes
0answers
18 views

Solidity listing: IEEE Conference Template

I am trying to display solidity code in IEEE LAtex template for conference paper. The link for GitHub repository is: IEEE CPS TEST_ZIP and the file names is: IEEE CPS test.zip It is a two column ...
0
votes
0answers
24 views

How to maintain formatting when copying code from rendered PDF?

I am looking for a way to write code in a document so that the readers could easily copy the code from within and paste it in an editor without breaking the formatting (indentation, line breaks and ...
1
vote
2answers
64 views

Color problem in listings with breaklines=true

I'm trying to highlight a specific comment type with lstsliting, and the option breaklines messes things over. Here is the faulty output : The color purple (produced by the keyword name) takes over, ...
0
votes
0answers
40 views

What is the best way to add the results of the Master thesis in the Latex report

I am writing my Master thesis report. My thesis was research and development of a test data generator for a particular domain in an organization. The developed application will generate test data in ...
1
vote
1answer
55 views

Positioning listings in itemize

Minimal Example \documentclass{report} \usepackage{listings} \usepackage{xcolor} \usepackage{caption} \definecolor{captioncolor}{rgb}{0.7, 0.7, 0.7} \definecolor{backgroundcolor}{rgb}{0.95, 0.95, 0....
0
votes
1answer
58 views

Can I make an entire listing a hyperlink rather than just the code?

Using the method explained in https://tex.stackexchange.com/a/213413/218142 I can click on the code in a listings environment defined with lstnewenvironment. Students cut and paste their code from ...
2
votes
0answers
34 views

gobble option of listing when used via tcolorbox

I use tcolorbox + listings to display code in a box. I pass a gobble option to listings, which seems to be plainly ignored: \documentclass{article} \usepackage[listings]{tcolorbox} \begin{document} ...
1
vote
1answer
21 views

How can I add string formatting for listings code?

How do I make sure that string-like code like "file" below (on line 7) gets same formating (purple/muave) like strings below? \documentclass{article} \usepackage{verbatim} % code \...
0
votes
0answers
8 views

How to remove formatting for some of the keywords in listings?

How do I remove (or change) the formatting for end on line 8 while not removing it for end that closes the for-loop? \documentclass{article} \usepackage{verbatim} % code \usepackage{listings} ...
1
vote
1answer
39 views

lstlisting: Box numbered variables in matching colors

Is it possible to match numbers, prepended by a %, e.g. variable %101 and surround every occurrence of that number in color-matched boxes? I am trying to make it easier for readers to follow the ...
2
votes
1answer
27 views

Nesting listings in an environment

I'm trying to define an outer environment around lstlisting (using quotation as an example). I tried: \newenvironment{quotelst}{% \begin{quotation} \begin{lstlisting}[] }{% \end{lstlisting} \end{...
0
votes
1answer
32 views

How can I draw in an existing tikzpicture from an lstnewenvironment?

The below example works fine if I move the tikzpicture environment into the after command of the lstnewenvironment. However, if I want to draw in an existing tikzpicture, the node content is not shown....
0
votes
2answers
33 views

listings package und set lstinline style?

I set 3 styles in my lecture notes for 3 different code style enviroments (\lstdefinestyle and \lstnewenvironment). How can I set the \lstinline style to one of these? Or is it not possible? Because ...
0
votes
1answer
62 views

Remove trailing period from captions in ToC

Every figure, table, formula and listing in my document has a caption that ends with a period. The problem is, that these periods are also displayed in the ToC, which they shouldn't. I found a ...
0
votes
0answers
19 views

How to fit long strings that goes out of page using lstlisting?

I am finishing my thesis in Overleaf and need to add an XML file in the appendix. I use lstlisting package. The problem is that the file contains strings with many characters and does not fit in the ...

1
2 3 4 5
64