Stack Exchange Network

Stack Exchange network consists of 175 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.

2
votes
1answer
10 views

Listings color context sensitive keywords (Matlab)

In Matlab there's two ways to use end: to end ifs, whiles etc. to refer to the last item in an array/vector (example: v(end) or v(end-1)). I want to use listings to include some matlab code in my ...
1
vote
0answers
32 views

How can I hide (or blur) some code in a pythontex environment?

My question is directly related to this one. Does there exists a solution for pythontex ? At least for the verbatim environment. More precisely, let us consider the following MWE : \documentclass[...
0
votes
0answers
28 views

Post break hook Arrows not working on native mac LaTex Clients

I tend to use overleaf for most of my latex porjects, but recently have been forced to work on a local tex editor. I work a lot with R code and use the following settings on overleaf: \usepackage{...
0
votes
0answers
44 views

What does \fi means? [duplicate]

I want to know the meaning of \fi in LaTeX. I don't understand the use. And don't find an easy definition online.
0
votes
1answer
75 views

Execute code during beamer presentation

I am preparing a beamer presentation which includes demo of some C, C++ or similar code. As these are demo, the execution time is very little. I was wondering if it is possible to execute the code ...
0
votes
2answers
75 views

how to present python snippet code efficiently in latex

I am quiet new to Latex and do not know how to present a simple python code like this in Latex in a professional way.. having your solutions and examples will help me a lot to learn and progress. ...
0
votes
3answers
48 views

Inline environment shortcut (like $blah$)

I want to be able to format code with a monospaced font. Right now I'm using \texttt{} but it's kind of a pain to keep typing that everywhere. Is there any way to use a shortcut instead? For example, ...
1
vote
1answer
40 views

is there a package for schematic representation of Arduino?

i need to represent a circuit containing Arduino, i'm new to circuitikz and to latex, so i'm not able to code a complex circuit component.
1
vote
0answers
30 views

Click to copy code snippets to clipboard in Latex-generated PDF

The Rust documentation has a wonderful feature where you can click an icon for the source code examples and it will copy it to the clipboard. Can this functionality be emulated in a LaTeX-generated ...
1
vote
0answers
45 views

How can I highlight text in the middle of sentences

I want to be able to present short code in the middle of a sentence. How can I highlight text in the middle of sentences in Latex so it they appear as code. Consider this example For this purpose ...
3
votes
2answers
103 views

Hexadecimal line numbers in listings

Is it possible to introduce hexadecimal line numbers in steps of two using the listings package? In the MWE \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{...
0
votes
0answers
91 views

How can I beautify LaTeX code? [duplicate]

Is there any shortcut (or something else) that beautify the code, like ctrl+shift+f does in Eclipse or ctrl+k+d in Visual Studio?
1
vote
1answer
63 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
169 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
53 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
46 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
77 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
49 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
91 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
39 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
71 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
99 views

How to produce colored code blocks in latex?

How can I write code block like this in Latex?
5
votes
0answers
45 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 ...
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
100 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
53 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
80 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
56 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 ...
4
votes
3answers
2k 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 ...
1
vote
2answers
23 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.
3
votes
1answer
218 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
328 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
69 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
98 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
40 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
116 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
337 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
42 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
97 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
60 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
313 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
83 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
100 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
186 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
180 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
107 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
303 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
66 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} \...