Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [code]

{code} is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the {programming} tag.

0
votes
0answers
13 views

Extracting code, uploading code and typeset result [migrated]

I have difficulties working with TeXSE. My OP system is Ubuntu and I use Firefox as my browser. Folk ask questions and and supply a MWE but I haven't found a way to get the MWE so I can try it out ...
1
vote
1answer
23 views

How to write inline code with semiverbatim in beamer

I use semiverbatim to write code block, now I want to use the same format to write inline code, how can I do this? \documentclass{beamer} \begin{document} \begin{frame}[fragile] \begin{...
7
votes
2answers
147 views

Two lstlistings side by side with refering arrow

SE I am trying to draw the image below in LaTeX using lstlisting, tikzpicture, minipage, and tabular The code that I got so far can be seen below \documentclass{article} \usepackage[utf8]{inputenc} ...
1
vote
1answer
48 views

Use code-style font

Just a quick question, I want parts of my document to be on this particular font which resembles a code, like this with mclust and FactoMineR: How can I do this?
1
vote
1answer
34 views

lstlisting - macro only for specific language

I am currently using following code for G-code formatting. Unfortunately I have no idea how do I enable the macro just for the new "gcode" language. \usepackage{xcolor} \usepackage{listings} \...
4
votes
1answer
62 views

How to type — or >> in minted?

If I try to type -- or >> (resp. <<), LaTeX puts them together and makes one big -, respectively guillemets. How can I change that behavior? I have to use LuaLaTeX to compile my source. \...
2
votes
1answer
43 views

Listing inside a frame using beamer

I want to use listing inside a frame. I know that I have to specify: begin{frame}[fragile] ..... However my code has not the row elements i.e. on the left the numbers related to the rows are ...
6
votes
2answers
75 views

Weird Vertical Spacing of '*' with Fira Code in Listings

I am recently getting started with LuaLaTeX and I was trying to set up a custom listings style for C++. Consider the following MWE: \documentclass{scrartcl} \usepackage{fontspec} \usepackage{xcolor} ...
1
vote
1answer
36 views

executable code containing symbol `^` inserted with verbatim on pdf. Error while copying back into a text editor

I'm trying to insert Octave code in a pdf containing the character ^. However when I copy the code from the generated pdf, the code doesn't run: The I already posted similar question and could solve ...
2
votes
1answer
56 views

Combine code and math mode

So i want to insert some line of codes in a formula like in the picture below. What is the best way to do this properly?
2
votes
1answer
86 views

How to produce colored code blocks in latex?

How can I write code block like this in Latex?
4
votes
0answers
35 views

Typesetting MAGMA code with minted?

I enjoy highlighting my Python code with minted. However I now would like to do the same with my Magma code (Magma is a commercial computer algebra system of broadly similar scope as GAP). However ...
-1
votes
0answers
29 views

Listing, break line when displaying it in PDF, but paste is as one line after copying it from the PDF. Possible?

I am trying to display one long line of characters on a latex report using the listing package. I use breaklines=true to avoid the line going outside the margins of the page. My problem is that if I ...
0
votes
1answer
22 views

executable code containing symbol `'` inserted with verbatim on pdf. Error while copying back into a text editor

I'm trying to insert Octave code in a pdf. However, there is a problem with the sign ' (which means transposition in Octave code). However when I copy the code from the generated pdf, the code doesn't ...
1
vote
1answer
42 views

How to insert inline `code` in Lyx

I want to add an inline text formatted as code in Lyx. For example: "The gradient is calculated via math::gradient(v)" I am aware of the Insert List command, but it is not what I'm looking for since ...
1
vote
1answer
32 views

Code using verbatim doesn't work when copied back in a text editor

I'm trying to use verbatim to copy the implementation of an algorithm written in octave. For this I introduced the following lines in latex \begin{verbatim} F = @(z) [z(1) + 2*z(2) - 2; 2*z(2)*z(3)^2 ...
5
votes
1answer
50 views

Sinusoidal wire arrangements

I have to draw this one where we can see the one wire are of one color and the other are of other color joining at the square shape box, each wire has a name associate to it and then repeats(repeated ...
1
vote
1answer
67 views

Draw a figure (cut-off functions) in tikz

Please I need the code tikz for this figure. I have this code but it's not correct : [![\begin{figure} \begin{tikzpicture}\[x=1.5cm,y=1.5cm\] \draw\[thick\] plot\[domain=-100:40,samples=100\] ({3.5*...
1
vote
1answer
50 views

Changing font color in listing numbers

I want to change the font color in a listing. I want only several lines in the listing to change its color (e.g. 1, 2, 9, 10, 12, 13). That is, I want to apply the color to individual lines of the ...
0
votes
0answers
29 views

Change the font style of a specific math block

Let's say I have some math block where I specifically want to write pseudocode. \begin{math} \end{math} Is there a way I can change the font so it's not cursive, and maybe a mono type font to look ...
3
votes
3answers
1k views

What font to use for source code in a document? [closed]

I'm currently writing some text where I discuss a python script. So naturally, there's a lot of code in the document and it seems like listings is the default way to do so. However, unlike what I'm ...
0
votes
0answers
26 views

There's no line here to end. {\theintro}?

please can you help to solve this error. I recived this project latex by mail and when extracting it and launch it I got this error : There's no line here to end. {\theintro} Here is the code :
1
vote
2answers
21 views

How to include/mark code in the middle of the text line

I want to include short code for in a single line that is marked by a grey background. Here is an example: I want to include code of this form that is in the middle of the text.
0
votes
0answers
20 views

program code typesetting with math in it? [duplicate]

The listings package can be used to typeset code blocks into a latex document. However, I'd like to include standard latex math symbols into the code. (I want to use it to write pseudocode that ...
3
votes
1answer
185 views

How do I set a background color and font for inline verb text?

I wish to customize the verb command such that I can customize the font and color, as well as set a rounded colored rectangle as background. I found this in the Tcolorbox manual: \DeclareTotalTCBox{\...
4
votes
1answer
229 views

Advanced customization of Minted code?

I'm a newbie to LaTeX, especially the minted package. I would like to customize it such that the code has a similar style to the attached screenshot. Specifically, I wish to be able to customize: The ...
3
votes
1answer
55 views

Use `code` syntax to insert some code [duplicate]

Instead of using \usepackage{listings} ... lstinline{for} or \lstinline{while} or \lstinline{main} Here you \codeword{see} an \codeword{example} of \codeword{code} how is it possible to define this ...
0
votes
1answer
76 views

Escaping HEX-characters source code in \lstinputlisting

I am currently writing a paper where I need to put full Python source code files into the appendix. Since I do not want to bloat my TeX file, I include source code with \lstinputlisting. The source ...
1
vote
1answer
38 views

Highlighting Java Code like Bitcoin Whitepaper

In Bitcoin Whitepaper ( https://bitcoin.org/bitcoin.pdf ) on page 7, there is a C code snippet. The style, font and the size is very neat and proper. How can I apply this kind of style for my java ...
0
votes
1answer
91 views

How to write a block of a real code (and not pseudo-code) in Latex?

I want to write the following code in latex, such that in pdf, we see the same format of writing (except background color and font colors). However, by algorithmic, output format is different. Is ...
0
votes
0answers
42 views

Add bibliography with usepackage{biblatex}+addbibresource+printbibliography: not working in Texmaker, working in ShareLatex [duplicate]

I wrote the code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{biblatex} \addbibresource{bibliografia.bib} \title{\textbf{Template}} \date{\vspace{-10ex}} \begin{document} \...
0
votes
1answer
251 views

Bibliography does not appear - BibTex

I read a lot of posts about this topic (Question mark or bold citation key instead of citation number, Latex references and bibliography not working etc), but they don't meet the needs. I followed the ...
0
votes
0answers
36 views

Ghost blank page in classicthesis template

I'm trying to delete the white page at the end of chapter1 of classicthesis template, but I don't find it in the code (I commented all \cleardoublepage). https://ctan.org/tex-archive/macros/latex/...
0
votes
0answers
63 views

Using of \null command alone [duplicate]

I'm trying to understand what is the purpose of \null command. To do this I wrote the code: \documentclass[11pt]{article} \begin{document} Ciao ciao \null \null \null \null ciao ciao \end{document} ...
2
votes
0answers
56 views

A weird box in the code styled with minted [closed]

I use minted to style my codes in a document. But in some cases, there is a weird box in the code in which most of the time a quotation mark is encircled. The following MWE shows my problematic ...
0
votes
2answers
233 views

How to insert normal-font text inside verbatim?

In the ISO C++ standard papers, blocks of code are displayed in a verbatim-like environment, but the comments inside the code are in normal font. For example: The comments "7.3.5, CommonReference:" ...
2
votes
1answer
79 views

Listing customization

I'm really new to latex and I would like to insert code snippet to look like this: But I really don't know where to start. I just managed to set the background color, but I can't figure out how to ...
3
votes
2answers
95 views

Trying to understand the code and failing to manipulate it for new network

I have a code for 3 wires network. But I'm not able to manipulate it new figure. This is because I'm not able to understand the code completely. This is my code \documentclass[border=2mm]{standalone} ...
0
votes
1answer
125 views

Use Dev-C++ style to write code using listings package

I would like to write this piece of code using listings package: However I have some problems: I cannot set the grouper symbol; The 0 does not have the diagonal slash. The size of the code has to ...
1
vote
2answers
124 views

Equals signs merging together in lstlisting

I am using a lstlisting environment in several spots in some stuff I'm writing up, with the language being set to either Python or Mathematica. In both cases, the equals signs merge together to look ...
3
votes
2answers
100 views

Can I enter columns instead of rows in LaTeX tables?

I use tabular environment in LaTeX. I want to write a column in a table as a row in the LaTeX code. For the problem I am writing in LaTeX, it is natural to think of a column at a time. For ...
0
votes
0answers
231 views

Coq syntax highlighting

I'd like to get a decent syntax highlighting for Coq code in LaTex. Does anyone know what package, .sty or whatnot is commonly used for this? I tried minted and got a syntax highlighting that's too ...
0
votes
0answers
62 views

Graphics are not inserting

I am trying to do some practice problem for my class and I wanted to insert graphs from R.I typed in \documentclass[12pt]{article} \usepackage{graphicx} \title{Week 1 Practice} \date{5/30/2018} \...
0
votes
1answer
69 views

Missing \endgroup inserted when using \mint in caption?

I'm using minted for code syntax highlighting in my document and it's been working great: In my caption, I want to refer to some variables and format them: \begin{figure} \inputminted{js}{...
0
votes
0answers
47 views

Monospaced font with italic support that closely matches libertinus

I have been using Libertinus for all the text and math content of my PhD thesis, compiled using luatex. Now, I have come to a section where I have code listings. The pygmentize stylesheet that I am ...
1
vote
1answer
86 views

Problems setting up minted and tcolorbox to include source code and set title

For my PhD thesis, I am using minted package for source code listings. I'd like to have a custom command \mylisting something along the lines of \mylisting[Name in title]{filename of source code} or ...
1
vote
1answer
74 views

How to present my code output in LaTeX?

I try to create an application that takes several inputs and represent them in a comprehensive manner. Let's say I have the following script: x = 5 y = 'meters' z = 'second' and I want to get a pdf/...
0
votes
2answers
65 views

How to align columns in lstlisting with breaklines=true?

The issue is indicated in red below. I can guess the right indent with breakindent in pt, but there has to be a better way. \documentclass{article} \usepackage{listings} \lstset{basicstyle=\...
1
vote
0answers
155 views

How to display colors of Octave code in latex with listings?

In my paper I include Octave code with \usepackage{listings} No I want that the text and numbers be written in the same colors as the are represented with in Octave. Everything is fine, except that ...
0
votes
1answer
32 views

Delete comment on input with listing [duplicate]

How i can deledete comment from listings code? I included source code file with \lstinputlisting{file.m} where file.m is matlab file. I want delete comment from file. % This is a comment function var =...