also so funktioniert es bei mir. ich habe nur \lstset vor \begin{document} gesetzt und eine \lstset aus einen von meinen alten dateien genommen. ka, was bei dir das problem war.
Code:
\documentclass[11pt,a4paper]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{listings}
\lstset{ %
language=[Visual]C++, % choose the language of the code
basicstyle=\small\ttfamily, % the size of the fonts that are used for the code
basewidth=1.1ex,
keywordstyle=\sffamily\bfseries,
numbers=left, % where to put the line-numbers
numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber=2, % 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{white}, % 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=tb, % adds a frame around the code
tabsize=2, % sets default tabsize to 2 spaces
captionpos=b, % sets the caption-position to bottom
breaklines=true, % sets automatic line breaking
breakautoindent=false,
breakindent=69pt,
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
morekeywords={max, Fitness, min, Crossover, Mutate, random},
escapeinside={/*@}{@*/} % if you want to add a comment within your code
}
\begin{document}
\begin{lstlisting}[caption={Pseudo--Code: GSA--Verfahren}, columns=fixed]
Intitalisiere: T // Höhe der Abkühltemperatur
Intitalisiere: M // Größe der Anfangspopulation
Intitalisiere: (*@$\gamma$@*) // (*@$0 < \gamma < 1$@*)
Intitalisiere: (*@$P$@*) mit (*@$\left|P\right|=M$@*) // Anfangspopulation
x_best = max(Fitness((*@$P$@*)));
x_globel = x_best;
while( )
{
x_worst = min(Fitness((*@$P$@*)));
x_worst = Crossover((*@$s\in P, k\in P$@*)); // Fitness((*@$s$@*)) (*@$\neq$@*)Fitness((*@$k$@*))
while()
{
for(l = 0; l < ???; l++)
{
x_mut = Mutate(P_i);
(*@$\Delta$@*) = Fitness(x_mut) - Fitness(P_i);
if((*@$\Delta$@*) < 0 || random(0,1) < (*@$\exp^{-\frac{\Delta}{T}}$@*))
{
x_i = x_mut;
}
if(Fitness(x_i) < Fitness(x_best))
{
x_best = x_i;
}
T *= (*@$\gamma$@*); // Temperatur reduzieren
}
}
if(Fitness(x_best) < Fitness(x_global))
{
x_global = x_best;
}
x_worst = x_best;
Fitness(x_best) = (*@$+\infty$@*);
}
return x_best
\end{lstlisting}
\end{document}
strolch
Lesezeichen