Algorithm2e: Einstellerei klappt einfach nicht

Formelsatz für Mathematik, Naturwissenschaften und Technik


BlackDevil
Forum-Century
Forum-Century
Beiträge: 107
Registriert: Di 23. Jul 2013, 11:38
Wohnort: Deutschland

Algorithm2e: Einstellerei klappt einfach nicht

Beitrag von BlackDevil »

Ahoi!

Ich versuche nun seit einer Stunde algorithm2e dazu zu bewegen das zu tun was ich möchte. Ich bin heute schon 11std am arbeiten und habe noch ein paar Stunden vor mir, ich hoffe mir kann hier jemand helfen :roll:

Was ich möchte:
-----------------------------------------------------------
k-means Algorithm
----------------------------------------------------------
1 Function k-means(o1,...,on)
2    |   initialize
3    |    repeat
4    |   Classify
5    |   Recompute
6    |   until no change
7    |  return (µ1,...,µn)
8 end
------------------------------------------------------------
Algorithm 1.1 k-means Algorithm
Sprich
  • Zeilen Nummeriert
    Horizontale Linien
    Titel im Kasten, Caption unten drunter
    Captionnummerierung KAPITEL.#Algo
Was ich habe:
-----------------------------------------------------------
Algorithm 1 k-means Algorithm
----------------------------------------------------------
1 Function k-means(o1,...,on)
2    |   initialize
3    |    repeat
4    |   Classify
5    |   Recompute
6    |   until no change
7    |  return (µ1,...,µn)
8   end
------------------------------------------------------------
Code:
EDIT: Punkt 1 "Function ... End" geht nun. Beschämend einfach^^
\documentclass[listof=totocnumbered,
				bibliography=totoc,
				twoside,12pt,
				headsepline,
				footsepline,
				cleardoublepage=current,
				chapterprefix,headings=normal]{scrbook}

	\usepackage{listings}
	\usepackage[lined,commentsnumbered,inoutnumbered,linesnumbered,ruled]{algorithm2e}

\begin{document}
\begin{algorithm}
	\DontPrintSemicolon
	\SetKwProg{Fn}{Function}{}{End}
	\Fn(){k-means{$(x_1,\dots,x_n,k)$}}
	{
		initialize $\mu_i,\dots,\mu_k$ \tcc{Automatically (e.g. random) or manual}
		\Repeat{no change in $\mu_i,\dots,\mu_k$}{
			 Classify $o_1,\dots,o_n$ for the next $\mu_i$\;
			 Recompute $\mu_i,\dots,\mu_k$\;
		}
	
		\KwRet{$(\mu_i,\dots,\mu_k)$}
	}	
	\caption{k-means algorithm}
\end{algorithm}
\end{document}
Vielleicht hat jemand eine Idee ...


Grüße


Edit: Ich habe mich nun entschieden es so zu lassen. Titel und Caption wären ja ohnehin redundant.