listings - francois-rozet/sleek-template GitHub Wiki
Listings features of the sleek-listings package.
-
\NormalStylecreates a version of an existing listing style with line numbering.\NumberStyle{java} ... \begin{lstlisting}[style=javaNumber]
-
\FrameStylecreates a version of an existing listing style with an all around frame.\FrameStyle{python} ... \begin{lstlisting}[style=pythonFrame]
-
\FrameTBStylecreates a version of an existing listing style with a top and bottom frame.\FrameTBStyle{matlab} ... \begin{lstlisting}[style=matlabFrameTB]
-
\FrameNumberStylecreates a version of an existing listing style with line numbering and an all around frame.\FrameNumberStyle{c} ... \begin{lstlisting}[style=cFrameNumber]
In the process of generating
xxxFrameNumber,xxxFrameis also generated. -
\FrameTBNumberStylecreates a version of an existing listing style with line numbering and a top and bottom frame.\FrameTBNumberStyle{cpp} ... \begin{lstlisting}[style=cppFrameTBNumber]
In the process of generating
xxxFrameTBNumber,xxxFrameTBis also generated.
Some styles are already built-in within the library.
-
defaultis a neutral style : no line numbering, no frame, only good old black code. However,Number,Frame,FrameTB,FrameNumberandFrameTBNumberversions ofdefaultare also provided. -
monokaiis an all-framed style reproducing the iconic Monokai colormap. TheNumberversion ofmonokaiis provided as well.
If you wish to use a language with one of the above style, take care of doing so before setting the style.
\begin{lstlisting}[language=fortran, style=monokai]A few programming languages have their own style built-in.
| Languages | Style |
|---|---|
| C | c |
| C++ | cpp |
| MATLAB | matlab |
| Python | python |
| Java | java |
However, feel free to add further languages to the library.
\NumberStyle{python}
\begin{listing}[style=pythonNumber]
import numpy as np # Unnecessary import
a, b = 1, 2
if a < b:
print(str(a) + " is smaller than " + str(b))
\end{listing}
Writing this code in a file stupid-script.py and using the command \lstinputlisting has the exact same output.
\NumberStyle{python}
\lstinputlisting[style=pythonNumber]{stupid-script.py}