[Tex/LaTex] Algorithm2e – Permanent fix for no italics if-clause

algorithm2eformatting

I am using algorithm2e to create pseudocode for my document. However, it has it so that the conditions in if clauses are italicised.

This solution suggests putting an \upshape in each if condition. Is there a permanent fix to set the if condition to never be italics?

For example

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}

\begin{algorithm}
\Begin{
    Flag $\leftarrow$ True\;
    \If{Flag}{
        DoSomething()\;
    }
}
\end{algorithm}
\end{document}

I don't want Flag to be italicised without having to put an \upshape in the condition, or have to do multiple fixes for each condition in an algorithm.

Best Answer

Please always post complete small document that shows the problem and allows answers to be tested. The package allows you to go

\SetArgSty{textrm}

to replace the default emph but that affects several components not just if clauses so might be more than you want.

Related Question