I could not find in the manual how to increment a for loop in the algorithm2e package.
I want to something like this:
for(i=0; i<10, i=i+2){
do something;
}
Somehow algorithm2e has \KwTo but not \KwBy. It is easy to define it, however:
\documentclass{article}
\usepackage{algorithm2e}
\pagestyle{empty}
\SetKw{KwBy}{by}
\begin{document}
\begin{algorithm}
\For{$i\gets0$ \KwTo $8$ \KwBy $2$}{
Do something
}
\end{algorithm}
\end{document}
You can redefine the way \For works:
\documentclass{article}
\usepackage[noline]{algorithm2e}
\SetKwFor{For}{for (}{) $\lbrace$}{$\rbrace$}
\begin{document}
\begin{algorithm}
\For{$i = 0;\ i < 10;\ i = i + 2$}{
Do something\;
}
\end{algorithm}
\end{document}
\; after each statement doesn't work, they just get concatenated into a long line
\;