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
1k views

How can I add a matlab code (namefile.mlx) to my overleaf project?

I've exported my matlab code (a file in .mlx format) by using the option "Save" -> "export to LaTex" and I've obtained two files, one in .tex format and the other one in .sty ...
g_don's user avatar
  • 779
0 votes
0 answers
201 views

Parameter settings in listing?

How to modify the font of the code in the listing. I tried basicstyle = \sffamily and it didn't seem to work. Now I can change the font type. But How to modify the spacing between codes. For example, ...
Gerrie's user avatar
  • 271
0 votes
1 answer
270 views

How to divide lstlisting into multiple tables

I want to use lstlisting to describe two pieces of code. But how can it be divided like this? In addition, can such a list use if else or for statements? What command controls (a) and (b) above the ...
Gerrie's user avatar
  • 271
2 votes
1 answer
71 views

Couldn anyone provide a way to make two columnated minipages the same height?

So heres the code I have: \noindent\begin{minipage}{.48\textwidth} \begin{lstlisting}[caption=user/info success,frame=tlrb,label={success:userInfo}] { "data":{ "_id":{"$...
Jonah Foley's user avatar
5 votes
1 answer
627 views

Remove carriage return characters from Verbatim environment with linebreaks?

I am using the following environment for breaking long lines of code \documentclass{article} \usepackage{fancyvrb} \usepackage{fvextra} \begin{document} Here is a very long command that I want ...
First User's user avatar
3 votes
1 answer
3k views

Box around the code?

I have a piece of code written as: \begin{lstlisting} code \end{lstlisting} I want to put a box, around the code. I have already read this question Source code listing with frame around code? But I ...
MementoMori's user avatar
1 vote
2 answers
449 views

Cross-References to Listings

I am writing on texstudio, and there is a part where I want to insert a code written by me. In another part of the text I want to quote that piece of code but I don't know how. The code is written in ...
MementoMori's user avatar
2 votes
2 answers
351 views

\newtcblisting with multiple optional arguments and defaults

I have a custom environment for code like this (it is a modified version of the code here): \documentclass[12pt,a4paper]{report} \usepackage[many]{tcolorbox} \tcbuselibrary{minted,skins} \definecolor{...
Clerni's user avatar
  • 177
3 votes
1 answer
364 views

Creating a custom code environment with minted

I'm trying to make an environment for python code using minted, but I always get FancyVerb error. Here is my code: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{minted} \usepackage{...
Clerni's user avatar
  • 177
1 vote
1 answer
333 views

Finding it difficult to create a table in Authorea

I am new to LaTex and using Authorea for editing a script. When I create a table, I am getting the error. Authorea is displaying this table. However, I am unable to export it to PDF, as there is some ...
Mohanasundaram's user avatar
0 votes
1 answer
41 views

Why am I creating two pages in the title when I dont want an initial blank page?

The $1$ at the bottom of the top bage is just there- the rest of it is blank. Also I am trying to make my title go to the left and it's not working. Any help? This is my first time using LaTeX by the ...
user71207's user avatar
  • 545
-1 votes
3 answers
254 views

obsolete lines in the following code [closed]

I am using the following .tex template borrowed from my colleague: \documentclass[11pt,twoside]{book} \usepackage{a4wide} \usepackage{fancyhdr} \usepackage[dvips]{epsfig} \usepackage{palatino,float,...
Praphulla Koushik's user avatar
0 votes
0 answers
36 views

newcommand to apply mintinline for C++ breaks on include statements [duplicate]

Staying away from LaTeX for barely more than 2 years has devastating effects. I think once I knew how to protect this stuff, but I have no idea now. I defined the newcommand below to be faster in ...
Enlico's user avatar
  • 2,592
6 votes
2 answers
12k views

Configure minted style in LaTeX for code highlighting

I need to configure the minted code highlighting in LaTex. This is what I want to get: Until now, this is what I get: What is remaining is the "import" and "as" keywords to be in ...
maths soso's user avatar
0 votes
0 answers
138 views

Code listings of O'reilly books

What are the O'Reilly code listing configurations for their books about computer science? Following is an example of such code formatting.
maths soso's user avatar
2 votes
5 answers
544 views

How to write a portion of text on the right only?

I would like to receive some help for writing a block o text completely on the right, in the form as in the photo below. Thank you so much!
Henry's user avatar
  • 378
0 votes
1 answer
219 views

Can anyone produce a minimal working example of listings in Beamer?

I'm trying out the solution in : Lstlisting Python but in Beamer. And no matter what I write, it throws me like a thousand errors: I thoroughly checked. There is no missing } My code is literally (...
Olórin's user avatar
  • 323
1 vote
2 answers
5k views

Insert inline code block in Latex document

Hi i am trying to add an inline code block in a Latex document. I know how to add a separate code block using lstlisting but i want to instead add an inline code block. I am attaching the screenshot ...
user12002570's user avatar
1 vote
0 answers
75 views

Beamer SubSubSection Ifx is not working [closed]

How can I make ifx subsubsection work in my code below. I want the code to only subsection if subsubsection is omitted. \documentclass{beamer} \usetheme[sectionpage=none, progressbar=frametitle, ...
OOzy Pal's user avatar
  • 1,571
0 votes
0 answers
88 views

Force to unindent default code

I want to unindent the default indent by mmacells. Here you can see the input and output are indented, and i want to force them to the left start. How to do that? Using \noindent and hspace*{-.5cm} ...
user516076's user avatar
0 votes
1 answer
269 views

How to add a font code with \lstinline?

Under LaTeX, I'm wanting to add the following R code between text. I'm searching for an appropriate font . I already tried: \documentclass[notitlepage]{article} \usepackage{amsmath, amssymb} \...
Tou Mou's user avatar
  • 205
3 votes
1 answer
3k views

Markdown to pdf with pandoc : how to get color for code framed by a single back-tick

To print .md to .pdf I use pandoc. (due to many contributor in this forum. Thx to them) problem = I would like to have (in the pdf) the same background color for the code no matter if I use triple ...
nguxx's user avatar
  • 33
1 vote
1 answer
219 views

How to display code snippets incrementally?

I want to use BEAMER and PythonTEX to prepare a slideshow that contains a lot of code. When displaying a code snippet in console mode I would like to show one line at a time. I'm struggling to achieve ...
Tonechas's user avatar
  • 976
0 votes
1 answer
102 views

How to use (^) symbol in code formatting of Verilog in Latex

I am formatting a code of Verilog in Overleaf and it is showing error in a line. I am not able to insert (^) symbol. The equation should appear as :- MUL_x = (V << 1) ^ c; The code can be viewed ...
Nitin Mehta's user avatar
0 votes
1 answer
697 views

Multiple ornaments between the corners

I would like to bring in several ornamental elements in the lines between the corners. I'am usigng, \begin{tikzpicture}[every node/.style={inner sep=0pt}] \node[shift={(1.cm,-1cm)},anchor=north west](...
Sebastian Moritz's user avatar
1 vote
1 answer
1k views

Convert plain text formulas into Latex Syntax so that I can use MathJax to show them in a web page

We have a set of Formulas like these- Area of rectangle=breadth*(sqrt((diagonal)^2-(breadth)^2)) Annuity Payment=(rate_per_period*present_value)/(1-(1+rate_per_period)^-number_of_periods) Volume of ...
swapsshah's user avatar
1 vote
1 answer
69 views

Is this achieved with a list?

I am new to LaTex. I want to generate the code as shown below. But I don't know how to achieve it? It does not seem to be a pseudo-code implementation method. The above marked this is a list, but the ...
Gerrie's user avatar
  • 271
1 vote
2 answers
143 views

Change size of a Checker pattern

I have made a 5 x 5 square checker pattern using the code below. How can I change it to 4 x 10 rectangular checker pattern? \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \...
Pankaj Singh's user avatar
0 votes
1 answer
454 views

How to include minus and hyphen sign in colored python code lisiting?

The post: How to highlight Python syntax in LaTeX Listings \lstinputlistings command produced answer from redmode, that gives a colored python code listing. Although the text produces minus/hyphens in ...
Brendan Darrer's user avatar
2 votes
1 answer
146 views

Fira code breaks listings background

I'm trying to use Fira Code on listings with a background. However, the background lines break above (, ), { and }. At first I thought this was a problem with custom fonts in general, but after ...
Luiz Martins's user avatar
1 vote
1 answer
1k views

Formatting minted code box in tcblisting

I am creating a code/strategy reference document for my student organization to be built on by groups of students into the future, and trying to make it simple and readable for those who will be ...
kevin-robb's user avatar
1 vote
0 answers
65 views

Todo notes inside minted

I'm trying to use Todonotes inside minted in order to easily annotate some code. I tried using escapeinside but the following code results in 5 errors unfortunately. \documentclass{article} \...
Desert Scuba's user avatar
0 votes
0 answers
26 views

minted or similar with URI instead of local

Is it possible to pull code in via http from eg a public git repo using minted? This question is motivated by the fact that direct integration between git remotes and overleaf seems to have some ...
mkk's user avatar
  • 217
1 vote
1 answer
360 views

number line with different interval

I'm new to the latex and I'm wondering how I can create a number line with different interval and labeled letter like this:
Kylinny's user avatar
  • 13
2 votes
1 answer
1k 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 ...
Thusle Gadelankz's user avatar
3 votes
1 answer
8k views

How to automatically convert a LaTeX math-mode equation into Python / numpy code?

Mathpix converts scanned formulas into LaTeX math code. Is there a similar tool that automatically converts scanned formulas or LaTeX math-mode equations (code) into python and numpy code?
develarist's user avatar
1 vote
1 answer
1k views

How to use table environment when using multicols

I am using the command multicols as it is the best option for me. However, I have to introduce a table and I want to addd a caption. If I use the enviroment table it does not work, the table disappear....
pdr99's user avatar
  • 11
1 vote
0 answers
374 views

Is there any tool/framework to convert R code into Latex?

I have a lot of code from R, and I'm working on a research project where I need to write down the pseudocode, is there any way to convert these codes into latex?
Felipe Augusto's user avatar
0 votes
1 answer
209 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'...
Migwell's user avatar
  • 143
0 votes
0 answers
36 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 ...
Clone's user avatar
  • 543
2 votes
1 answer
210 views

Moving the quote in the ModernCV banking style

I'm having problems moving some parts of the header in the banking style I managed to move most of it with \patchcmd{\makehead}% <cmd> {\setlength{\makeheaddetailswidth}{0.8\textwidth}}% <...
Methizul's user avatar
1 vote
2 answers
817 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 ...
Ameyah's user avatar
  • 23
0 votes
2 answers
70 views

I need help centering my table and wrap my text

I hope you could help me with my noob question. I have this code \begin{center} \begin{table}[!htb] \caption{\label{tab:vantagens}bus network} \vskip 1cm \begin{tabular}{ |c|m{7cm}| } \hline ...
latexnewbie's user avatar
0 votes
1 answer
136 views

Spacing Around Ampersands in tabular

Does inserting around & in tabular logically change the outcome? \documentclass{article} \begin{document} \begin{tabular}{cc} 0&0\\0&0 %NON-SPACED VERSION %0 & 0 \\ 0 &...
Junyong Kim's user avatar
0 votes
1 answer
78 views

How to highlight the word "base" as code with the listings package, e. g. \lstinline{base}?

When I use the word base inside \lstinline{} to highlight it as inline code, I get an error, followed by warnings that are not there, if the error is not there: Package xcolor Error: Undefined color `...
stackprotector's user avatar
2 votes
1 answer
88 views

How to use bold font on arbitrary string fragments, without affecting adjacent characters?

I'm trying to highlight arbitrary text fragments, in a beamer presentation, in order to explain SQL injection attacks. Using underlining, or a different text color works fine, because only the ...
guillomovitch's user avatar
0 votes
1 answer
67 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-...
user225381's user avatar
1 vote
0 answers
40 views

Beamer: code fragment with listings [duplicate]

I am having difficulty adding code fragment to my slides in beamer with listings package. My code: \documentclass{beamer} %\usepackage[utf8]{inputenc} \usetheme{Warsaw} \usepackage{listings} \title{...
arilwan's user avatar
  • 389
0 votes
1 answer
63 views

Adding font size to already defined command

I am using the answer here to add source code to my beamer (usually inline), as: \usepackage{xcolor} \definecolor{light-gray}{gray}{0.95} \newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}} ...
arilwan's user avatar
  • 389
0 votes
0 answers
114 views

Writing code in a different style [duplicate]

I want to write code in LaTeX with this style I tried with listings but I didn't get the same result. Does anyone could hepl me?
matdlara's user avatar
  • 101

1 2 3
4
5
16