Re: lstlisting
Posté : dim. 3 févr. 2013, 12:11
Ce coup ci j'ai élagué un max.
En effet je souhaite une coloration à l'identique du code présenté mais les "otherkeywords" doivent rester en gris dans les commentaires.
Les parenthèses et crochets doivent être en orange dans le code.
En effet je souhaite une coloration à l'identique du code présenté mais les "otherkeywords" doivent rester en gris dans les commentaires.
Les parenthèses et crochets doivent être en orange dans le code.
Code : Tout sélectionner
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage[table,dvipsnames,svgnames]{xcolor}
%%%%%%%%% Code Latex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{textcomp}
\usepackage{listings}
\lstdefinelanguage{Latex}{%
sensitive=true,
morekeywords =[1]{rule,newlength,usepackage,begin,end,hline,color,tt,small,
b,c,l,p,m,r,s}, % en bleu fonce
%
morekeywords =[2]{document,minipage,tabular}, % en vert fonce
%
otherkeywords={|,&,<,>,$,@,\\,!, ; , +, -,=},
literate=
*{\{}{{\textcolor{RedOrange}{\{}}}{1}
{\}}{{\textcolor{RedOrange}{\}}}}{1}
{[}{{\textcolor{RedOrange}{[}}}{1}
{]}{{\textcolor{RedOrange}{]}}}{1},
escapeinside=§§, %Pour mettre du verbatim dans du verbatim
morecomment=[l]\%,
}[strings,keywords,comments]
\lstdefinestyle{LatexCode}{%
language = Latex,
basicstyle = \bf\ttfamily\color{black},
%identifierstyle = \color{couleuridentifier},
%stringstyle = \color{couleurstring},
commentstyle = \color{Grey},
keywordstyle = {[1]\color{MediumBlue}},
keywordstyle = {[2]\color{DarkGreen}},
keywordstyle = {[3]\color{MediumPurple}},
keywordstyle = {[4]\color{Red}\bfseries},
keywordstyle = {[5]\color{Black}}
}
\lstset{style = LatexCode,
columns = flexible
}
%%%%%%%%% Fin Code Latex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Je souhaite que les "otherkeywords" reste en gris dans les commentaires !
\bigskip
Début du listing:
\hrule
\begin{lstlisting}[deletekeywords={rule},morekeywords={[4]rule}]
\begin{document}
\newlength{\mylen} % On crée la longueur mylen
%otherkeywords={|,&,<,>,$,@,\\,!, ; , +, -,=}
\usepackage{minipage}
% Un tableau crée avec \begin{tabular}
\begin{tabular}{|>{\tt \color{blue}}l|>{\small}m{5cm}<{.}|}
\hline
\rule[-0.9cm]{0cm}{2cm} Eric & Manon et Romain \\
\hline
Manon & ma fille \\
\hline
\end{tabular}
%Célèbre formule : E=mc^2
$E=mc^2$
\end{document}
\end{lstlisting}
\hrule
Fin du listing.
\bigskip
Le package \lstinline"minipage"
\end{document}