Code : Tout sélectionner
%%%%%%%COULEURS%%%%%%
\definecolor{my-gray}{gray}{0.95}
\colorlet{fond-code}{my-gray}
\colorlet{bord-code}{SkyBlue}
\colorlet{comment}{link}
\colorlet{c-emph}{blue}
\colorlet{c-key}{red}
\colorlet{c-math}{OliveGreen}
%%%%%%%%%%%
\lstset{%
basicstyle=\ttfamily,
% the size of the fonts that are used for the code
numbers=left,
% where to put the line-numbers
numberstyle=\footnotesize,
% the size of the fonts that are used for the line-numbers
stepnumber=1,
% the step between two line-numbers. If it's 1 each line
% will be numbered
numbersep=5pt,
% how far the line-numbers are from the code
backgroundcolor=\color{fond-code},
% choose the background color. You must add \usepackage{color}
showspaces=false,
% show spaces adding particular underscores
showstringspaces=false,
% underline spaces within strings
showtabs=false,
% show tabs within strings adding particular underscores
frame=single,
% adds a frame around the code
tabsize=4,
% sets default tabsize to 4 spaces
captionpos=b,
% sets the caption-position to bottom
breaklines=true,
% sets automatic line breaking
breakatwhitespace=false,
% sets if automatic breaks should only happen at whitespace
title=\lstname,
% show the filename of files included with \lstinputlisting;
% also try caption instead of title
escapeinside={*!}{!*},
% if you want to add a comment within your code
%morekeywords={???} % if you want to add more keywords to the set
framexleftmargin=5mm, frame=shadowbox, rulesepcolor=\color{bord-code},
commentstyle=\color{comment}\small,
emphstyle=\color{c-emph},
keywordstyle=\ttfamily\bfseries\color{c-key},
}% à compléter au besoin
%
% et puis aussi ailleurs
%
\lstset{%
language=python,
keywords=[1]{and,as,assert,break,class,continue,def,%
del,elif,else,except,False,finally,for,%
from,global,if,import,in,is,lambda,%
None,nonlocal,not,or,pass,raise,return,%
True,try,while,with,yield},
%
keywords=[2]{print,input,str,float,int,len,range,abs,%
any,all,set,sum,pow,sorted,list,divmod,enumerate,ord,open,min,max,dir}, % c'est encore incomplet !!!!
keywordstyle=[1]\bfseries\color{red},
keywordstyle=[2]\color{brown},
numbers=none,
escapechar=§,
string=[b]",
%morestring=[b]\textquotesingle,
stringstyle=\color{purple},
moredelim=[is][\ttfamily\color{blue}]{£}{£},% deux trucs perso
moredelim=[is][\ttfamily\color{red}]{≤}{≥}%erreur de python, en rouge
}
\renewcommand*{\lstlistlistingname}{Codes sources des programmes \sujet}
\renewcommand*{\lstlistingname}{Code source}