Latex Code

β‘ ALL INFORMATION CLICK HERE ππ»ππ»ππ»
Latex Code
\begin { verbatim }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim }
\begin { verbatim* }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim* }
In the directory \verb |C: \Windows\system 32| you can find a lot of Windows
system applications.
The \verb + \ldots + command produces \ldots
\begin { lstlisting }
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
\begin { lstlisting } [language=Python]
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
The next code will be directly imported from a file
\lstinputlisting [language=Octave] { BitXorMatrix.m }
\lstinputlisting [language=Octave, firstline=2, lastline=12] { BitXorMatrix.m }
\documentclass { article }
\usepackage { listings }
\usepackage { xcolor }
\definecolor { codegreen }{ rgb }{ 0,0.6,0 }
\definecolor { codegray }{ rgb }{ 0.5,0.5,0.5 }
\definecolor { codepurple }{ rgb }{ 0.58,0,0.82 }
\definecolor { backcolour }{ rgb }{ 0.95,0.95,0.92 }
\lstdefinestyle { mystyle }{
backgroundcolor= \color { backcolour } ,
commentstyle= \color { codegreen } ,
keywordstyle= \color { magenta } ,
numberstyle= \tiny\color { codegray } ,
stringstyle= \color { codepurple } ,
basicstyle= \ttfamily\footnotesize ,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset { style=mystyle }
\begin { document }
The next code will be directly imported from a file
\lstinputlisting [language=Octave] { BitXorMatrix.m }
\end { document }
\begin { lstlisting } [language=Python, caption=Python example]
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
We only use cookies for essential purposes and to improve your experience on our site. You can find out more in our cookie policy .
Essential cookies only Accept all cookies
L a T e X is widely used in science and programming has become an important aspect in several areas of science, hence the need for a tool that properly displays code. This article explains how to use the standard verbatim environment as well as the package listings , which provide more advanced code-formatting features. This separate article discusses the minted package, which performs syntax-highlighting using Python's pygmentize library.
The default tool to display code in L a T e X is verbatim , which generates an output in monospaced font.
The code above produces the following output:
Just as in the example at the introduction, all text is printed keeping line breaks and white spaces. There's a starred version of this command whose output is slightly different.
The code above produces the following output:
In this case spaces are emphasized with a special "visible-space" character: β£ .
Verbatim-like text can also be used in a paragraph by means of the \verb command.
The code above produces the following output:
The command \verb|C:\Windows\system32| prints the text inside the delimiters | in verbatim format. Any character, except letters and * , can be used as delimiter. For instance \verb+\ldots+ uses + as delimiter.
To use the lstlisting environment you have to add the following line to the preamble of your document:
Here's an example of using the lstlisting environment from the listings package:
The code above produces the following output:
In this example, the output ignores all L a T e X commands and the text is printed keeping all the line breaks and white spaces typed. Let's see a second example:
The code above produces the following output:
The additional parameter inside brackets [language=Python] enables code highlighting for this particular programming language (Python), special words are in boldface font and comments are italicized. See the reference guide for a complete list of supported programming languages.
Code is usually stored in a source file, therefore a command that automatically pulls code from a file becomes very handy.
The command \lstinputlisting[language=Octave]{BitXorMatrix.m} imports the code from the file BitXorMatrix.m , the additional parameter in between brackets enables language highlighting for the Octave programming language. If you need to import only part of the file you can specify two comma-separated parameters inside the brackets. For instance, to import the code from the line 2 to the line 12, the previous command becomes
If firstline or lastline is omitted, it's assumed that the values are the beginning of the file, or the bottom of the file, respectively.
Code formatting with the listing package is highly customisable. Let's see an example
The code above produces the following output:
As you see, the code colouring and styling greatly improves readability.
In this example the package xcolor is imported and then the command \definecolor{}{}{} is used to define new colours in rgb format that will later be used. For more information see: using colours in L a T e X
There are essentially two commands that generate the style for this example:
Just like in floats ( tables and figures ), captions can be added to a listing for a more clear presentation.
The code above produces the following output:
Adding the comma-separated parameter caption=Python example inside the brackets, enables the caption. This caption can be later used in the list of Listings.
supported languages (and its dialects if possible, dialects are specified in brackets and default dialects are italized):
Have you checked our knowledge base ?
Message sent! Our team will review it and reply by email.
ABAP (R/2 4.3, R/2 5.0, R/3 3.1, R/3 4.6C, R/3 6.10 )
C ( ANSI , Handel, Objective, Sharp)
TeX (AlLaTeX, common, LaTeX, plain , primitive)
\begin { verbatim }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim }
\begin { verbatim* }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim* }
In the directory \verb |C: \Windows\system 32| you can find a lot of Windows
system applications.
The \verb + \ldots + command produces \ldots
\begin { lstlisting }
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
\begin { lstlisting } [language=Python]
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
The next code will be directly imported from a file
\lstinputlisting [language=Octave] { BitXorMatrix.m }
\lstinputlisting [language=Octave, firstline=2, lastline=12] { BitXorMatrix.m }
\documentclass { article }
\usepackage { listings }
\usepackage { xcolor }
\definecolor { codegreen }{ rgb }{ 0,0.6,0 }
\definecolor { codegray }{ rgb }{ 0.5,0.5,0.5 }
\definecolor { codepurple }{ rgb }{ 0.58,0,0.82 }
\definecolor { backcolour }{ rgb }{ 0.95,0.95,0.92 }
\lstdefinestyle { mystyle }{
backgroundcolor= \color { backcolour } ,
commentstyle= \color { codegreen } ,
keywordstyle= \color { magenta } ,
numberstyle= \tiny\color { codegray } ,
stringstyle= \color { codepurple } ,
basicstyle= \ttfamily\footnotesize ,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset { style=mystyle }
\begin { document }
The next code will be directly imported from a file
\lstinputlisting [language=Octave] { BitXorMatrix.m }
\end { document }
\begin { lstlisting } [language=Python, caption=Python example]
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
We only use cookies for essential purposes and to improve your experience on our site. You can find out more in our cookie policy .
Essential cookies only Accept all cookies
L a T e X is widely used in science and programming has become an important aspect in several areas of science, hence the need for a tool that properly displays code. This article explains how to use the standard verbatim environment as well as the package listings , which provide more advanced code-formatting features. This separate article discusses the minted package, which performs syntax-highlighting using Python's pygmentize library.
The default tool to display code in L a T e X is verbatim , which generates an output in monospaced font.
The code above produces the following output:
Just as in the example at the introduction, all text is printed keeping line breaks and white spaces. There's a starred version of this command whose output is slightly different.
The code above produces the following output:
In this case spaces are emphasized with a special "visible-space" character: β£ .
Verbatim-like text can also be used in a paragraph by means of the \verb command.
The code above produces the following output:
The command \verb|C:\Windows\system32| prints the text inside the delimiters | in verbatim format. Any character, except letters and * , can be used as delimiter. For instance \verb+\ldots+ uses + as delimiter.
To use the lstlisting environment you have to add the following line to the preamble of your document:
Here's an example of using the lstlisting environment from the listings package:
The code above produces the following output:
In this example, the output ignores all L a T e X commands and the text is printed keeping all the line breaks and white spaces typed. Let's see a second example:
The code above produces the following output:
The additional parameter inside brackets [language=Python] enables code highlighting for this particular programming language (Python), special words are in boldface font and comments are italicized. See the reference guide for a complete list of supported programming languages.
Code is usually stored in a source file, therefore a command that automatically pulls code from a file becomes very handy.
The command \lstinputlisting[language=Octave]{BitXorMatrix.m} imports the code from the file BitXorMatrix.m , the additional parameter in between brackets enables language highlighting for the Octave programming language. If you need to import only part of the file you can specify two comma-separated parameters inside the brackets. For instance, to import the code from the line 2 to the line 12, the previous command becomes
If firstline or lastline is omitted, it's assumed that the values are the beginning of the file, or the bottom of the file, respectively.
Code formatting with the listing package is highly customisable. Let's see an example
The code above produces the following output:
As you see, the code colouring and styling greatly improves readability.
In this example the package xcolor is imported and then the command \definecolor{}{}{} is used to define new colours in rgb format that will later be used. For more information see: using colours in L a T e X
There are essentially two commands that generate the style for this example:
Just like in floats ( tables and figures ), captions can be added to a listing for a more clear presentation.
The code above produces the following output:
Adding the comma-separated parameter caption=Python example inside the brackets, enables the caption. This caption can be later used in the list of Listings.
supported languages (and its dialects if possible, dialects are specified in brackets and default dialects are italized):
Have you checked our knowledge base ?
Message sent! Our team will review it and reply by email.
ABAP (R/2 4.3, R/2 5.0, R/3 3.1, R/3 4.6C, R/3 6.10 )
C ( ANSI , Handel, Objective, Sharp)
TeX (AlLaTeX, common, LaTeX, plain , primitive)
\begin { verbatim }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim }
\begin { verbatim* }
Text enclosed inside \texttt { verbatim } environment
is printed directly
and all \LaTeX {} commands are ignored.
\end { verbatim* }
In the directory \verb |C: \Windows\system 32| you can find a lot of Windows
system applications.
The \verb + \ldots + command produces \ldots
\begin { lstlisting }
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
\begin { lstlisting } [language=Python]
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end { lstlisting }
The next code will be directly imported from a file
\lstinputlisting [language=Octave] { BitXorMatrix.m }
\lstinputlisting [language=Octave, firstline=2, lastline=12] { BitXorMatrix.m }
\documentc
Home Lingerie
Urban Decay Naked
Outdoor 2