Difference between revisions of "Listings in Latex"
From Klaus' wiki
Line 39: | Line 39: | ||
Erlang | Erlang | ||
} | } | ||
+ | </source> | ||
+ | |||
+ | Use the listings like this: | ||
+ | |||
+ | <source lang="latex"> | ||
+ | \lstset{language=Erlang} | ||
+ | \begin{lstlisting}[float, caption=The priority test program, label=PriorityTest] | ||
+ | %% | ||
+ | %% Launch a very long running process while launching a number of other | ||
+ | %% processes with Prio priority | ||
+ | %% | ||
+ | s (Prio) -> | ||
+ | %% Launch one long calculation with low priority | ||
+ | spawn (ef_erlangB, erlangBproc, [1000000000, 100000000, low]), | ||
+ | %% Ensure that his process will enough priority to launch several other | ||
+ | %% processes while calculating | ||
+ | process_flag (priority, high), | ||
+ | %% Run 8 rounds of the test | ||
+ | s (8, Prio). | ||
+ | |||
+ | %% | ||
+ | %% Run the longTest N times with Prio priority | ||
+ | %% | ||
+ | s (N, Prio) when (N > 0) -> | ||
+ | %% Call longTest with Priority = Prio | ||
+ | longTest(Prio), | ||
+ | %% Tail recursively call s again | ||
+ | s (N - 1, Prio); | ||
+ | |||
+ | %% | ||
+ | %% Stop the loop | ||
+ | %% | ||
+ | s(N, _Prio) when (N =:= 0) -> | ||
+ | ok. | ||
+ | |||
+ | longTest(Prio) -> | ||
+ | OffTrf = 100000, | ||
+ | Res = 10000, | ||
+ | Priority = Prio, | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), | ||
+ | spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]). | ||
+ | \end{lstlisting} | ||
</source> | </source> |
Revision as of 18:12, 13 May 2012
Setup code listing like this:
\definecolor{listinggray}{gray}{0.9} \definecolor{lbcolor}{rgb}{0.9,0.9,0.9} \lstset{ backgroundcolor=\color{lbcolor}, tabsize=2, rulecolor=, basicstyle=\scriptsize, upquote=true, aboveskip={1.5\baselineskip}, columns=fixed, showstringspaces=false, extendedchars=true, breaklines=true, prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}}, frame=single, showtabs=false, showspaces=false, showstringspaces=false, identifierstyle=\ttfamily, keywordstyle=\color{Purple}, identifierstyle=\color{Black}, commentstyle=\color{BrickRed}, stringstyle=\color{RubineRed}, captionpos=b, } \lstloadlanguages{ % Check Dokumentation for further languages ... %[Visual]Basic %Pascal C, C++, %XML HTML, %Java, Erlang }
Use the listings like this:
\lstset{language=Erlang} \begin{lstlisting}[float, caption=The priority test program, label=PriorityTest] %% %% Launch a very long running process while launching a number of other %% processes with Prio priority %% s (Prio) -> %% Launch one long calculation with low priority spawn (ef_erlangB, erlangBproc, [1000000000, 100000000, low]), %% Ensure that his process will enough priority to launch several other %% processes while calculating process_flag (priority, high), %% Run 8 rounds of the test s (8, Prio). %% %% Run the longTest N times with Prio priority %% s (N, Prio) when (N > 0) -> %% Call longTest with Priority = Prio longTest(Prio), %% Tail recursively call s again s (N - 1, Prio); %% %% Stop the loop %% s(N, _Prio) when (N =:= 0) -> ok. longTest(Prio) -> OffTrf = 100000, Res = 10000, Priority = Prio, spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]), spawn (ef_erlangB, erlangBproc, [OffTrf, Res, Priority]). \end{lstlisting}