Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Why does algorithm2e typeset the variables anychange and done in italics, and how can I turn this off? How can I remove the semicolon after done in the until-clause?

enter image description here

$\textsf{anychange} \gets \textsf{false}$ \\
\Repeat{$\textsf{done}$}{

    $\textsf{done} \gets \textsf{true}$ \\
    \ParallelFor{$u \in V$} {
        $\delta \gets \max_{v \in N(u)} \left \{ \Delta mod(v, \zeta(u) \rightarrow \zeta(v)) \right \} $\\
        $C \gets \zeta(\arg\max_{v \in N(u)} \left \{ \Delta mod(v, \zeta(u) \rightarrow \zeta(v)) \right \} ) $\\
        \If{$\delta > 0$}{
            $\zeta(u) \leftarrow C$ \\
            $\textsf{done} \gets \textsf{false}$ \\
            $\textsf{anychange} \gets \textsf{true}$ \\
        }
    }
}
\If{$\textsf{anychange}$}{
    $G' \leftarrow$ \textsf{contract}$(G, \zeta)$ \\
    $\zeta \gets$ \textsf{prolong(PLM$(G')$)} \\
}
share|improve this question

1 Answer 1

up vote 1 down vote accepted

algorithm2e provides \DontPrintSemicolon to avoid printing the ; at the end of statements. Conditional arguments to structures are set in italics. You can override this using the occasional as-needed \upshape:

enter image description here

\documentclass{article}
\usepackage{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
$\textsf{anychange} \gets \textsf{false}$ \\
\Repeat{$\textsf{\upshape done}$}{

    $\textsf{done} \gets \textsf{true}$ \\
    \For{$u \in V$} {
        $\delta \gets \max_{v \in N(u)} \left \{ \Delta mod(v, \zeta(u) \rightarrow \zeta(v)) \right \} $\\
        $C \gets \zeta(\arg\max_{v \in N(u)} \left \{ \Delta mod(v, \zeta(u) \rightarrow \zeta(v)) \right \} ) $\\
        \If{$\delta > 0$}{
            $\zeta(u) \leftarrow C$ \\
            $\textsf{done} \gets \textsf{false}$ \\
            $\textsf{anychange} \gets \textsf{true}$ \\
        }
    }
}
\If{$\textsf{\upshape anychange}$}{
    $G' \leftarrow$ \textsf{contract}$(G, \zeta)$ \\
    $\zeta \gets$ \textsf{prolong(PLM$(G')$)} \\
}
\end{algorithm}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.