1

I'm using minted to include Python code in my document, but I want to change the font of the letters only in the annotations and make it look more like what is portrayed in Jupyter Notebook.

This is what i have:

\begin{document}
\usepackage{minted} 
\begin{minted}
    [
    frame=lines,
    framesep=2mm,
    baselinestretch=1.2,
    fontsize=\small,
    linenos
    ]
    %%% python3 instead of python
    {python3}
    # Se define una funcion "Trozar" que sirve simplemente para 
    # facilitar el uso de elementos muy grandes y manejarlos con Pandas.
    def Trozar(vec, num):  # corta vectores (vec) en "num" pedazos
\end{minted}

And this is what I get:

enter image description here

I don't like the style of the annotations, and would like something like: enter image description here

1 Answer 1

1

I don't know how to do that with minted, but I can say that, with piton (a LuaLaTeX package designed to format Python listings), it's very easy to change the styles of the different syntaxic elements.

\documentclass{article}
\usepackage{piton,xcolor}

\begin{document}

\PitonOptions{line-numbers}

\begin{Piton}
    # Se define una funcion "Trozar" que sirve simplemente para 
    # facilitar el uso de elementos muy grandes y manejarlos con Pandas.
    def Trozar(vec, num):  # corta vectores (vec) en "num" pedazos
\end{Piton}


\vspace{1cm}

After \verb|\SetPitonStyle{Comment = \slshape \color{cyan}}| :


\bigskip

\SetPitonStyle{Comment = \slshape \color{cyan}} 

\begin{Piton}
    # Se define una funcion "Trozar" que sirve simplemente para 
    # facilitar el uso de elementos muy grandes y manejarlos con Pandas.
    def Trozar(vec, num):  # corta vectores (vec) en "num" pedazos
\end{Piton}

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .