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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 views

How to display two screen sessions in palallel?

I'm trying to produce something like the following in LaTeX - just the general layout, illustrating the flow of communication between two command line sessions: I have tried variations over: \...
j4nd3r53n's user avatar
  • 497
1 vote
0 answers
40 views

Inserting code environment in an endnote

I am currently writing a report in which I have to include many bits of code in endnotes on a different page. Doing every reference manually seems unnecessarily tedious. I found a way to insert python ...
Galou's user avatar
  • 33
0 votes
2 answers
59 views

Combine two codes of codehigh

I'm having a hard time trying to have one code giving the full code and its output, side by side. Please help. Thank you. \documentclass{article} \usepackage{codehigh} \usepackage{amsmath} \...
Rafiq's user avatar
  • 63
1 vote
1 answer
93 views

Python code in two-column document

I want to put my python code in a two-column document. I am using the listings package with the following preamble: \usepackage{listings} \usepackage{xcolor} \definecolor{codegreen}{rgb}{0,0.6,0} \...
curious_direwolf's user avatar
0 votes
1 answer
34 views

Help with bar chart

I need to make a graph similar to the photo. I have the beginning of the code in LATEX, but it does not work correctly, you also need to add inscriptions like in the photo, you can write in your own ...
benderrr's user avatar
0 votes
2 answers
71 views

Help to complete the graph in Latex using tikz

I would like to ask for help in building a graph, I really need your help My code: \documentclass[tikz,border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{angles,quotes} \begin{document} \...
benderrr's user avatar
1 vote
2 answers
39 views

Set code font style for words in table

MVP: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{lmodern} \usepackage{color} \usepackage{tcolorbox} \usepackage{float} % Better figure and table ...
Alix Blaine's user avatar
0 votes
1 answer
30 views

Coloured subsection AND text right after the subsection name

I'm facing a problem due to the incompatibility between the packages TITLESEC and SECTSTY. What I want is to have a coloured subsection name, which I provided with \usepackage{sectsty} \subsectionfont{...
Henry's user avatar
  • 378
5 votes
6 answers
613 views

How to mimic StackExchange-style inline code in LaTeX

I love the way StackExchange formats inline code, using both a fixed width font and a gray background. How can I mimic the above sentence in LaTeX? One possibility might be using a combination of the ...
Andrew's user avatar
  • 1,249
0 votes
1 answer
55 views

how can a reproduce a code snippet that looks tabular

Here is the image I cropped from an article. I would like to know how to reproduce the overall structure of this code snippet.
Mosh Geb's user avatar
1 vote
1 answer
114 views

Custom language lexer alias not found by pygments for minted

Problem I've made a custom lexer for a pseudocode language in Python (3.11). The file is saved in the same directory as my TeX project. I am using pdflatex to compile my project, and it has the --...
BrightBulb123's user avatar
0 votes
0 answers
92 views

How to render a PDF with selectable indentation whitespace for a code block?

I'm trying to create a PDF that will contain code snippets, and since they will mostly be in Python, the indentation is important. I found the fancyvrb package, which looks great in the PDF, but my ...
vee's user avatar
  • 1
2 votes
1 answer
84 views

Plot a sequence to show the limit, improving the code

I wanted to generate a good figure to show the visual definition for the limit of a sequence. This is an idea so far, but I would like to improve it, for example: How can I delete the thicks on the $...
Henry's user avatar
  • 378
1 vote
1 answer
66 views

Change color to all items in enumerate: only the "indicator"

I don't know the right terminology, but what I am looking for is this: say I write \begin{enumerate}[(1)] \setcounter{enumi}{-1} \item blabla \item $x - 3 = 0 \iff x = 3$ \item The End. \end{enumerate}...
Henry's user avatar
  • 378
6 votes
2 answers
337 views

LaTeX3 - Advice on a code to validate an ISO date

The following code is a POC showing a way to validate one Julian date in "pure" LaTeX3: it is related to this question. There is no doubt that this code contains some clumsiness. Any advice ...
projetmbc's user avatar
  • 13.8k
0 votes
0 answers
33 views

New Install Problem (TeXShop)

I just bought a new Mac. So I downloaded TeXShop and tried to typeset a test file. I got this error: xelatex: Command not found. Is there something wrong with in my preface? Yes, I'm sure there's ...
Epimanes's user avatar
  • 101
1 vote
0 answers
28 views

Caption alignment issues with lstlistings environment inside lists

The alignment of the caption of the my lstlistings environment for code is not correct when inside lists. The code to generate the image is given in the working example... \documentclass{article} \...
user41177's user avatar
  • 355
0 votes
1 answer
70 views

How can I restyle the listings caption to a tcblistings environment?

I am trying to define a tcblistings environment that should work under the following syntax... \begin{code}{TITLE}{LANG}{CAPTION}{OPTS} code here \end{code} Everything but the language should be ...
user41177's user avatar
  • 355
0 votes
0 answers
22 views

How to load keywords from two languages in lstlisting? [duplicate]

I know how to define two different styles for two different languages in lstlisting package. I want to include keywords from Lua as well as LaTeX in the same style. Is it possible? \lstdefinestyle{...
user61681's user avatar
  • 1,739
2 votes
1 answer
63 views

How to get the QED symbol without using the proof environment

I want to get the QED symbol at the right end of the proof without using the proof environment and I want the QED symbol inside \begin{itemize}... \end{\itemize} environment. Is it possible? Thanks ...
Ali Shadhar's user avatar
1 vote
0 answers
51 views

Wrapping inserted code from MATLAB

I am attempting to insert a very long code that I wrote in MATLAB into my thesis document written on Overleaf. Several of the lines have long equations or comments that extend beyond the page and I ...
Jah's user avatar
  • 11
1 vote
2 answers
58 views

Why are my theorems not numbered by letters?

I'm trying to enumerate the main theorems from my paper using letters instead of numbers. I've tried using the following code but it's not working (at least the counter is!) \documentclass[11pt]{...
Marra's user avatar
  • 225
11 votes
2 answers
700 views

Replicating a chronodex in TikZ

I've tried to make a chronodex in TikZ and I have a basic skeleton. I need to add a few more things to it (ticks, labels, nodes). Besides, the code itself could be optimised using loops but I'm still ...
crypto's user avatar
  • 757
0 votes
2 answers
70 views

How do you use minted to render a code block in monospaced font with all black text?

How do you use minted to render a code block in teletype font (monospace fixed width font) and all text is the same color (probably black)? What would you write if you wanted all text to be black ...
IdleCustard's user avatar
0 votes
0 answers
17 views

Hiding extra string space in pdf document by using latex - overleaf [duplicate]

I am trying to type Python code by using LaTeX. The code is not being formatted properly Example: #PDF var = function(data, parameter= 'compile') #Copy it on my terminal var = function(data, ...
Lola's user avatar
  • 1
-2 votes
3 answers
110 views

How can I draw top right corner trimmed rectangle in tikz? [duplicate]

If possible I want to draw a code figure (looks like rectangle but right-top corner is trimmed) in tikz. Basic sample would be: ____ | \ |< >| |___| Is there any sample for this? Original ...
alper's user avatar
  • 1,379
0 votes
0 answers
20 views

How can minted (or something similar) work with automatic alignment of code? [duplicate]

I typeset Lisp code in a proportional typeface, and it relies on alignment. An example of the typesetting can be seen here: If I ignore font selection, it was typeset using this code: \begin{tabbing} ...
matj1's user avatar
  • 109
1 vote
1 answer
101 views

Continue code on the next page with line numbering (minted, tcolorbox)

Here is my code: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{listings} \usepackage{minted} \usepackage{xcolor} \usepackage{tcolorbox} \tcbuselibrary{listings, minted, skins} \tcbset{...
WinnieNotThePooh's user avatar
0 votes
1 answer
134 views

How can I export a txt table to latex? [duplicate]

I have txt file with table format, I did it in python but now I have to export this table to Latex but I don't know how. I'm not good at all in latex so I'll appreciate if you help me. Thank you!
Hache 99's user avatar
0 votes
0 answers
208 views

Modifying existing Latex code to put Python codes in the Cheatsheet

I want to make a cheatsheet for Pandas which has Python codes. I googled and tried to find a free online site that help to get built easily. I'm unable to find except overleaf which uses Latex codes ...
Display Name is missing's user avatar
0 votes
0 answers
57 views

How can I align code listing with a propotional font?

I'd like to typeset some code with a proportional code with alignment. How can I do it? The capabilities of listings to align are limited, and I was using tabbing, but it causes problems because every ...
matj1's user avatar
  • 109
0 votes
1 answer
50 views

Best way to indicate that some lines are left out

Assume I wrote a class myclass in Matlab with many properties and methods, and now I want to display its most important properties (foo and bar), the headers of its most important methods (myclass ...
Οὖτις's user avatar
  • 2,887
1 vote
0 answers
61 views

Words going off the page, why?

I'm using LaTeX to turn in a school assignment which contains code snippets. The code snippets themselves look visually appealing, but the text unfortunately goes off the page if there's too much code ...
Anish G.'s user avatar
0 votes
1 answer
60 views

Minted: colorize variable in inline mode

Is it possible to specify how to color a variable with mintinline? What I mean is, for instance, to use \mintinline{python}{myClass} and color myClass as a Class variable, or as a function. If I use ...
PerroNoob's user avatar
  • 641
1 vote
1 answer
114 views

Use lmodern package for minted code and palatino package for the rest of the report

I am writing a technical report and I need to use the palatino package for it. However, the minted code font is not very legible since it doesn't use deep black but slight gray instead. Hence I want ...
yolo_ML's user avatar
  • 11
1 vote
0 answers
21 views

Figures Breaking Code [duplicate]

I am writing a report where I have figures (floats) and also code snippets. I am using graphicx and minted, respectively for the figures and code. I know that you aren't supposed to use [h] for ...
Robert's user avatar
  • 11
1 vote
0 answers
47 views

How can I list code with alignment and syntax highlighting?

I would like to effectively typeset code in a proportional font with syntax highlighting and horizontal alignment. How can I do that? The package listings offers syntax highlighting but not alignment. ...
matj1's user avatar
  • 109
2 votes
1 answer
281 views

LaTeX is not letting me add spaces in strings in lstlistings

I am trying to add some code to my document, but whenever there is a space inside a string in the code, it shows up with a bucket(?) thing. I have provided the code and the output below: \...
mudders's user avatar
  • 23
0 votes
0 answers
27 views

Is there a way to prevent line numbers for minted code blocks from being selectable/copy-able? [duplicate]

I have seen solutions for this issue for listings (eg. this and this) using \lstset, but is there a similar solution for the minted environment?
user432111's user avatar
1 vote
1 answer
80 views

Trimming common leading whitespace in an environment

I have an executable that performs semantic highlighting of files containing literate code. It outputs a .tex file that I can source snippets from using catchfilebetweentags. One issue I am facing is ...
gallais's user avatar
  • 195
1 vote
1 answer
410 views

How do I import a picture in LaTeX?

I am new to latex. I want to import a picture but failing. The picture is .jpg format.
user avatar
0 votes
0 answers
55 views

How to write table in overleaf?

I hope you are doing very well. I am writing a report for my class. I need to add code like this in my latex report. But I haven't found any similar example from google. I just recently started using ...
ya xi er's user avatar
4 votes
1 answer
56 views

Displaying an arrow underneath a symbol

This is probably easily answered, but how can I get this image in code? I have got something like this: \begin{gathered} A=(\circ, \bullet, \bullet).\\ \underset{\text { Position } 1}{\uparrow} \...
calculatormathematical's user avatar
1 vote
2 answers
930 views

How to add orcid link to given ieee access latex code template? [duplicate]

https://ieeeaccess.ieee.org/wp-content/uploads/2022/01/LaTeX.zip \documentclass{ieeeaccess} \usepackage{cite} \usepackage{amsmath,amssymb,amsfonts} \usepackage{algorithmic} \usepackage{graphicx} \...
Esaias Abera's user avatar
1 vote
1 answer
53 views

How to create a new environment with mdframed and lstlisting? [duplicate]

I want to create a new environment that wraps mdframed and lstlisting together as shown below, however that does not work for me as it does not compile. Any ideas what the issue is and how to define a ...
pixel's user avatar
  • 1,357
0 votes
1 answer
63 views

How to define custom code listing?

I have the following custom listing but it throws error for lstset part that the keys are undefined. Any ideas how to fix this? \documentclass{llncs} \pagestyle{plain} \usepackage[utf8]{inputenc} \...
pixel's user avatar
  • 1,357
0 votes
2 answers
450 views

Which font should I use to get Julia's code with bold letter using minted in xelatex/lualatex?

I've searched on how to create Julia's code on LaTex and I found very good references. However, the code does not compile properly when it has bold letters, e.g., \documentclass{article} \usepackage{...
Rubem Pacelli's user avatar
1 vote
1 answer
588 views

How to properly format an included docker-compose.yml file

How do I properly format and highlight a docker-compose.yml file when including a code snippet into a latex document. I want to do something like: \documentclass{article} \usepackage{listings} \lstset{...
NameVergessen's user avatar
0 votes
1 answer
38 views

Small number of programming instructions [duplicate]

I am writing an article and I need to insert a small number of code instructions for a topic related to computer science. I know the existence of many packages, such as Listing, Algorithmic and so on, ...
Ospite007's user avatar
1 vote
1 answer
400 views

pandoc template $if$ statement for fenced code snippets in markdown [closed]

I am wondering if it is possible to do in a latex.template for Pandoc: \begin{document} $if(fencedcode)$ \begin{lstlisting} $content within fenced code$ \end{lstlisting} $endif$ \end{document} ...
Louis's user avatar
  • 303

1
2 3 4 5
15