I am looking for a latex preamble in order to have a good python script. Here I found this
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12} % for normal
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\usepackage{listings}
% Python style for highlighting
\newcommand\pythonstyle{\lstset{
language=Python,
basicstyle=\ttm,
morekeywords={self}, % Add keywords here
keywordstyle=\ttb\color{deepblue},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\color{deepred}, % Custom highlighting style
stringstyle=\color{deepgreen},
frame=tb, % Any extra options here
showstringspaces=false
}}
% Python environment
which looks great but I find noway to apply it into my latex code, phereaps I'm lost into the complexity of it and what I am looking for is just a sample code such as
\begin{document}
here some python codes
\begin{listings}
\pythonstyle
import numpy as np
class __init__(self, a, b):
self.a = a
self.b = b
\end{listings}
\end{document}
or the like, in order to have a proper python ambient. Could you help me, please?
minted
packagearara
like this:arara: pdflatex: {options: -shell-escape}
when I need to shell escape.Minted
and other packages/programmes (likemakeindex
I believe) require-shell-escape
to run. Look atarara
orlatexmk
depending upon what you like, the documentation explains it better then I.