13

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')$)} \\
}
Moriambar
  • 11,466
clstaudt
  • 1,192
  • 2
  • 11
  • 27

1 Answers1

11

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}
Moriambar
  • 11,466
Werner
  • 603,163
  • 2
    How can one switch this italic font in conditional arguments generally off? – Arne Dec 07 '22 at 14:24
  • 3
    @Arne: This is governed by \ArgSty - an Argument Style function, which can be adjusted via \SetArgSty. Try, for example, \SetArgSty{upshape} to force a specific (upright) shape. Similar alternatives include \SetArgSty{relax} (\relax is just a no-op) and \SetArgSty{textnormal}, which is the current "exterior" default switch to remove any kind of formatting/shape. – Werner Dec 07 '22 at 17:57
  • Thanks, Werner! – Arne Dec 08 '22 at 12:18