Commit ba8c18c3 authored by Gerald Oster's avatar Gerald Oster
Browse files

Merge pull request #9 from virgileTN/Listings

Listings (à utiliser avec parcimonie dans le corps du rapport)
parents 713bca50 e355fcab
......@@ -115,6 +115,90 @@ righteous in wrath.
\cleardoublepage
\chapter{Exemples Listings}
Il est aisé d'insérer du code dans un rapport. Il suffit de définir le langage, la légende à afficher et enfin un Label pour pouvoir y faire référence. Le résultat est donnée dans le listing \ref{lst:premierExemple}. Il est également possible de changer les couleurs, pour cela il faut éditer le lstset dans la classe tnreport.cls.
\begin{lstlisting}[language=c++, caption={Premier Exemple}, label={lst:premierExemple}]
void CEquation::IniParser()
{
if (!pP){ //if not already initialized...
pP = new mu::Parser;
pP->DefineOprt("%", CEquation::Mod, 6); //deprecated
pP->DefineFun("mod", &CEquation::Mod, false);
pP->DefineOprt("&", AND, 1); //DEPRECATED
pP->DefineOprt("and", AND, 1);
pP->DefineOprt("|", OR, 1); //DEPRECATED
pP->DefineOprt("or", OR, 1);
pP->DefineOprt("xor", XOR, 1);
pP->DefineInfixOprt("!", NOT);
pP->DefineFun("floor", &CEquation::Floor, false);
pP->DefineFun("ceil", &CEquation::Ceil, false);
pP->DefineFun("abs", &CEquation::Abs, false);
pP->DefineFun("rand", &CEquation::Rand, false);
pP->DefineFun("tex", &CEquation::Tex, false);
pP->DefineVar("x", &XVar);
pP->DefineVar("y", &YVar);
pP->DefineVar("z", &ZVar);
}
}
\end{lstlisting}
\clearpage
Il est également possible d'afficher du code directement depuis un fichier source, le résultat de cette opération est visible dans le listing \ref{lst:fromSrc}
\lstinputlisting[language=c++,caption={Affichage depuis le fichier source},label={lst:fromSrc}]{figures/sourceCode.cpp}
De nombreux languages sont supportés : \\
ABAP2,4, ACSL, Ada4, Algol4, Ant, Assembler2,4, Awk4, bash, Basic2,4, C\#5, C++4, C4, Caml4, Clean, Cobol4, Comal, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran4, GCL, Gnuplot, Haskell, HTML, IDL4, inform, Java4, JVMIS, ksh, Lisp4, Logo, Lua2, make4, Mathematica1,4, Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modelica3, Modula-2, MuPAD, NASTRAN, Oberon-2, Objective C5 , OCL4, Octave, Oz, Pascal4, Perl, PHP, PL/I, Plasm, POV, Prolog, Promela, Python, R, Reduce, Rexx, RSL, Ruby, S4, SAS, Scilab, sh, SHELXL, Simula4, SQL, tcl4, TeX4, VBScript, Verilog, VHDL4, VRML4, XML, XSLT.
\clearpage
Il est néanmoins possible de définir le sien, il faudra alors ajouter dans la classe tnreport.cls du code resemblant au listing \ref{lst:defLang}. On y définit les différents mots-clés, ainsi que les délimiteurs des chaines de caractère et des commentaires.
\begin{lstlisting}[language=Tex, caption={Syntaxe définition d'un langage}, label={lst:defLang}]
\lstdefinelanguage{amf}
{keywords=
{
xml,
amf,
volume,
material,
coordinates,
vertices,
vertex,
triangle,
x,
y,
z,
v1,
v2,
v3,
mesh,
object,
constellation,
metadata,
color,
texmap,
texture,
utex1,
utex2,
utex3,
instance,
deltax,
deltay,
deltaz,
r,
g,
b,
rx,
ry,
rz,
composite
},
sensitive=false,
morestring=[b]",
comment=[s]{<!--}{-->}
}
\end{lstlisting}
\cleardoublepage
\chapter{Autre chapitre}
......@@ -162,6 +246,9 @@ Ceci est une référence bibliographique~\cite{GOT4}.
\listoftables
\cleardoublepage
\lstlistoflistings
\cleardoublepage
\chapter*{Glossaire}
\addcontentsline{toc}{chapter}{Glossaire}
......
......@@ -118,6 +118,90 @@ righteous in wrath.
\cleardoublepage
\chapter{Exemples Listings}
Il est aisé d'insérer du code dans un rapport. Il suffit de définir le langage, la légende à afficher et enfin un Label pour pouvoir y faire référence. Le résultat est donnée dans le listing \ref{lst:premierExemple}. Il est également possible de changer les couleurs, pour cela il faut éditer le lstset dans la classe tnreport.cls.
\begin{lstlisting}[language=c++, caption={Premier Exemple}, label={lst:premierExemple}]
void CEquation::IniParser()
{
if (!pP){ //if not already initialized...
pP = new mu::Parser;
pP->DefineOprt("%", CEquation::Mod, 6); //deprecated
pP->DefineFun("mod", &CEquation::Mod, false);
pP->DefineOprt("&", AND, 1); //DEPRECATED
pP->DefineOprt("and", AND, 1);
pP->DefineOprt("|", OR, 1); //DEPRECATED
pP->DefineOprt("or", OR, 1);
pP->DefineOprt("xor", XOR, 1);
pP->DefineInfixOprt("!", NOT);
pP->DefineFun("floor", &CEquation::Floor, false);
pP->DefineFun("ceil", &CEquation::Ceil, false);
pP->DefineFun("abs", &CEquation::Abs, false);
pP->DefineFun("rand", &CEquation::Rand, false);
pP->DefineFun("tex", &CEquation::Tex, false);
pP->DefineVar("x", &XVar);
pP->DefineVar("y", &YVar);
pP->DefineVar("z", &ZVar);
}
}
\end{lstlisting}
\clearpage
Il est également possible d'afficher du code directement depuis un fichier source, le résultat de cette opération est visible dans le listing \ref{lst:fromSrc}
\lstinputlisting[language=c++,caption={Affichage depuis le fichier source},label={lst:fromSrc}]{figures/sourceCode.cpp}
De nombreux languages sont supportés : \\
ABAP2,4, ACSL, Ada4, Algol4, Ant, Assembler2,4, Awk4, bash, Basic2,4, C\#5, C++4, C4, Caml4, Clean, Cobol4, Comal, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran4, GCL, Gnuplot, Haskell, HTML, IDL4, inform, Java4, JVMIS, ksh, Lisp4, Logo, Lua2, make4, Mathematica1,4, Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modelica3, Modula-2, MuPAD, NASTRAN, Oberon-2, Objective C5 , OCL4, Octave, Oz, Pascal4, Perl, PHP, PL/I, Plasm, POV, Prolog, Promela, Python, R, Reduce, Rexx, RSL, Ruby, S4, SAS, Scilab, sh, SHELXL, Simula4, SQL, tcl4, TeX4, VBScript, Verilog, VHDL4, VRML4, XML, XSLT.
\clearpage
Il est néanmoins possible de définir le sien, il faudra alors ajouter dans la classe tnreport.cls du code resemblant au listing \ref{lst:defLang}. On y définit les différents mots-clés, ainsi que les délimiteurs des chaines de caractère et des commentaires.
\begin{lstlisting}[language=Tex, caption={Syntaxe définition d'un langage}, label={lst:defLang}]
\lstdefinelanguage{amf}
{keywords=
{
xml,
amf,
volume,
material,
coordinates,
vertices,
vertex,
triangle,
x,
y,
z,
v1,
v2,
v3,
mesh,
object,
constellation,
metadata,
color,
texmap,
texture,
utex1,
utex2,
utex3,
instance,
deltax,
deltay,
deltaz,
r,
g,
b,
rx,
ry,
rz,
composite
},
sensitive=false,
morestring=[b]",
comment=[s]{<!--}{-->}
}
\end{lstlisting}
\cleardoublepage
\chapter{Autre chapitre}
......@@ -165,6 +249,9 @@ Ceci est une référence bibliographique~\cite{GOT4}.
\listoftables
\cleardoublepage
\lstlistoflistings
\cleardoublepage
\chapter*{Glossaire}
\addcontentsline{toc}{chapter}{Glossaire}
......
void CEquation::IniParser()
{
if (!pP){ //if not already initialized...
pP = new mu::Parser;
pP->DefineOprt("%", CEquation::Mod, 6); //deprecated
pP->DefineFun("mod", &CEquation::Mod, false);
pP->DefineOprt("&", AND, 1); //DEPRECATED
pP->DefineOprt("and", AND, 1);
pP->DefineOprt("|", OR, 1); //DEPRECATED
pP->DefineOprt("or", OR, 1);
pP->DefineOprt("xor", XOR, 1);
pP->DefineInfixOprt("!", NOT);
pP->DefineFun("floor", &CEquation::Floor, false);
pP->DefineFun("ceil", &CEquation::Ceil, false);
pP->DefineFun("abs", &CEquation::Abs, false);
pP->DefineFun("rand", &CEquation::Rand, false);
pP->DefineFun("tex", &CEquation::Tex, false);
pP->DefineVar("x", &XVar);
pP->DefineVar("y", &YVar);
pP->DefineVar("z", &ZVar);
}
}
\ No newline at end of file
......@@ -14,6 +14,33 @@
%\RequirePackage{newtxtext}
\RequirePackage[libertine]{newtxmath}
\RequirePackage[svgnames]{xcolor}
\RequirePackage{listings}
\lstset{ %
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\footnotesize, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{Orange}, % comment style
extendedchars=false, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
frame=single, % adds a frame around the code
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\color{DarkOrchid}, % keyword style
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
numbersep=5pt, % how far the line-numbers are from the code
numberstyle=\tiny\color{DarkGray}, % the style that is used for the line-numbers
rulecolor=\color{DarkGray}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{DarkGreen}, % string literal style
tabsize=2, % sets default tabsize to 2 spaces
%title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
}
\RequirePackage[a4paper]{geometry}
\geometry{top=2cm, bottom=2cm,right=2cm,left=2.5cm}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment