listings - francois-rozet/sleek-template GitHub Wiki

Listings

Listings features of the sleek-listings package.

Commands

  • \NormalStyle creates a version of an existing listing style with line numbering.

    \NumberStyle{java}
    ...
    \begin{lstlisting}[style=javaNumber]
  • \FrameStyle creates a version of an existing listing style with an all around frame.

    \FrameStyle{python}
    ...
    \begin{lstlisting}[style=pythonFrame]
  • \FrameTBStyle creates a version of an existing listing style with a top and bottom frame.

    \FrameTBStyle{matlab}
    ...
    \begin{lstlisting}[style=matlabFrameTB]
  • \FrameNumberStyle creates 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, xxxFrame is also generated.

  • \FrameTBNumberStyle creates 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, xxxFrameTB is also generated.

Styles

Some styles are already built-in within the library.

  • default is a neutral style : no line numbering, no frame, only good old black code. However, Number, Frame, FrameTB, FrameNumber and FrameTBNumber versions of default are also provided.

  • monokai is an all-framed style reproducing the iconic Monokai colormap. The Number version of monokai is 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]

Languages

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.

Examples

\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}
⚠️ **GitHub.com Fallback** ⚠️