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.
797 questions
0
votes
2
answers
115
views
LaTeX code for smiley?
so on Math Stack Exchange when you compile $\rlap \smile {\dot{}\dot{}}$ it shows up as a smiley (it doesn't work here too) something like this one:
but if I try to use this code in overleaf it ...
3
votes
1
answer
88
views
I am using APA style, but the references do not appear
My latex file reads
\documentclass[stu]{apa7}
\usepackage[american]{babel}
\author{student name}
\title{How to cite references in \LaTeX}
\begin{document}
\maketitle
The article body includes \cite{...
4
votes
3
answers
323
views
Combining multicolumn and multicolumn to form this table
I want to obtain the table in the first image but i don't know how to. All I could do is in image
I use overleaf to write the code. I am writing a on a two columns page and want to center the table on ...
6
votes
1
answer
250
views
How to use minted for highlighting two languages in one code block (LuaLaTeX)
Minted loads code from a file.
The file contains code in two languages TeX and Lua.
I found this but it doesn't work:
minted - how to highlight html also, when language "twig" is selected
...
0
votes
0
answers
50
views
Is it somehow feasible to create clickable “own text modules” in WinEdt?
WinEdt is (as far as I detected) the only LaTeX-Editor for Windows which may really be called the (in many regards more advanced) successor of the outdated King of Editors (= TeXnicCenter). For ...
2
votes
1
answer
66
views
How to remove the unexpected space behind the framed box if I type in an Enter behind the \fbox{}? [duplicate]
There exists an extra space behind the framed box if I type in an Enter behind the \fbox{}. Here are two MWEs.
Code 1:
\documentclass{article}
\begin{document}
\fbox{Demo}This is a sample.
\end{...
0
votes
1
answer
57
views
Coding preamble issues with apacite style bib
I'm quite new to latex, and lately I started to have some problems with apa citing. here is the code of my preamble and the portrait of the article.
%DISEÑO Y FORMATO DE DOCUMENTO
\documentclass[...
0
votes
1
answer
336
views
How to write this symbol ( plus minus in the same vertical line)
I am new to LATEX and I am writing a presentation in it. I am using overleaf subscription and I have searched the symbol there and also on detexify kirelabs but I couldn't find the code of this symbol....
1
vote
2
answers
67
views
How to write one-element row in 2 by 2 smallmatrix?
The following code
\left[\begin{smallmatrix}a&a\\p&q\end{smallmatrix}\right]
gives 2 by 2 matrix where the first row is a a and the second row is p q.
How to have only a in the first row and ...
1
vote
0
answers
23
views
lstdefinestyle code will not center in middle of document [duplicate]
I have some python code that I cannot center in the middle of the page as if you would do \centering. But none of the center commands work.
this is my code.
Apologies for the long preamble, whenever I ...
4
votes
1
answer
141
views
Changing color of code using lstlisting
I use lstlisting to show my code in the appendix of my rapport. I have problems with changing the color of the functions and types of data types. I hope to get the following result.
But I get the ...
0
votes
1
answer
139
views
Setting text color with minted inline stopped working
Ever since March, I've been redefining \FancyVerbFormatLine and passing that as formatcom= in order to change the default text color for minted.
Here is a minimal example that does so:
\documentclass{...
0
votes
1
answer
77
views
Are pow(\x, n) and \x*\x*...*\x for n times exactly the same as (\x)^n (\x to the power of n) with n is a set of natural number when writing code?
I know that (\x)^n means '\x raises to the power of n', but I have just found at least two alternative ways of coding this thing, they are the following,
[pow(\x, n)] and [\x*\x*...*\x for n times].
I ...
2
votes
2
answers
193
views
No line numbering in Cryptocode
I am using cryptocode package to write some games in Cryptography.
My question is if we can actually write a line of the code without numbering, but being alligned just above the numbers of the ...
1
vote
1
answer
64
views
newenvironment with lstlisting and tcolorbox
PROBLEM / QUESTION
I want to type code with lstlisting and tcolorbox, which I can do by having 2 enviornments, but I would rather have only 1 environment.
I know that I could probably imitate a ...
0
votes
1
answer
598
views
Is it possible to save a notepad text (.txt) file to a Latex (.tex) file?
I am trying to compile and test a file in Latex/Domino using a text file in Notepad that has a script/code in it. Is it possible to convert the notepad txt file to tex somehow? Could a txt file be ...
0
votes
0
answers
39
views
How can I color dot notation methods in the listings package?
I can't figure out a way to incorporate colored dot notation methods into my custom Python theme with the listings package of LaTeX.
For example, consider the following code:
1 import matplotlib....
1
vote
1
answer
87
views
How Can I change the colors of variables in lstlistings?
So I have some code blocks like the followings
\begin{lstlisting}[language=Python, caption={Ejecución de prueba}]
altura_lista = altura.tolist()
peso_lista = peso.tolist()
w, b = train(altura_lista, ...
0
votes
0
answers
25
views
"extra alignment tab has been changed to \cr" error message [duplicate]
The latex code shown below is not running for me.
Error : Extra alignment tab has been changed to \cr
\begin{equation}\nonumber
{\small
G=\begin{pmatrix}
\sqrt{\phi X_{1}X_{3}} & -\...
12
votes
3
answers
3k
views
How to Draw Gabriel's Horn
Consider Gabriel's Horn:
which, mathematically speaking, is the curve y=1/x over the interval [1,∞] revolved about the x-axis. It is interesting because though it contains a finite volume, its ...
3
votes
1
answer
285
views
How to format code in the style used in academic papers?
I came across a scientific article that features beautifully formatted code, as shown in the image below. I'm interested in using a similar style for my own article, but I'm not sure how to achieve ...
-3
votes
1
answer
106
views
Simple Question [closed]
How to write the image below in latex?:
1
vote
0
answers
58
views
Lstlisting doesn't highlight keyword
I have the MWE below. However, the keyword \getit is not highlighted. How to turn it blue?
\documentclass[12pt]{memoir}
\usepackage{xcolor}
\usepackage{listings}
\lstset{
basicstyle=\...
3
votes
1
answer
61
views
Code shows in Greek letters
I have been trying to insert an Octave function in my paper but when I build the pdf the letters are all turned into greek.(The rest of the paper is written in greek). What is even weirder is that ...
0
votes
1
answer
134
views
Highlighting on lists of strings and lists of numbers in a listing
I am following the format used by this answer to color a json listing on my document, but I noticed that in a list of strings and a list of numbers, only the first element gets colored properly. Is ...