Code Block¶
Python highlighting using minted¶
pip install PygmentsIn Latex
Invoke the
shell-escapeflag to compile the document
add a frame¶
Add a frame for the code block (framesep is the distance between frame and content):
\begin{minted}[frame=single,framesep=10pt]{python}
import pandas as pd
print('Hello World!')
\end{minted}
use newminted¶
\newminted{py}{
breaklines,
framesep=2mm,
fontsize=\scriptsize,
numbersep=5pt,
linenos
}
% create a code block
\begin{pycode}
if true:
print('Hello World!')
\end{pycode}
custom the space before and after the code block¶
after loading minted