# Conditions in algorithms are underlined

I'm using algorithm2e for typesetting pseudocode. Generally I find it easy to use, however, I cannot seem to find the setting that underlines the conditions in my while and for loops and if-statements.

\begin{algorithm}[H]
\LinesNumbered
\SetAlgoNoLine
\DontPrintSemicolon
\KwData{New relation $m_i(r_{new})m_j$}
\KwResult{An updated network where consequences of the new relation is inferred.}
\BlankLine
Add $(i,j)$ to Q\;
\While{Q is not empty} {

(i, j) $\leftarrow$ Q.dequeue\;

\For{k $\leftarrow$ 0 $\KwTo$ n} {
$m_k(r_{new})m_j$ $\leftarrow$ $m_k(r)m_j \cup (m_k(r)m_i \circ m_i(r_{new})m_j)$\;
\If {$m_k(r_{new})m_j \subset m_k(r)m_j$} {
Q.enqueue($(k,j)$)\;
}
}

\For{k $\leftarrow$ 0 $\KwTo$ n} {
$m_i(r_{new})m_k$ $\leftarrow$ $m_i(r)m_k \cup (m_i(r_{new})m_j \circ m_j(r)m_k)$\;
\If {$m_i(r_{new})m_k \subset m_i(r)m_k$} {
Q.enqueue($(i,k)$)\;
}
}
}
\caption{Allen's Path Consistency}
\end{algorithm}


Which produces this result:

Basically, I want to disable the underlining of the conditions. Any suggestions?

• Welcome to TeX.SX! You have to give us a compilable but minimal document which results just in the screenshot above. When I compile your document inside a \documentclass{article}\usepackage{algorithm2e}\begin{document}...\end{document}, it does not show that lines. Therefore, I can't reproduce your error. Oct 1 '14 at 14:33
• Please post a complete MWE, starting with \documentclass and ending with \end{document}, as I cannot reproduce your error. In the meantime, maybe Algorithm2e - Permanent fix for no italics if-clause is worth looking at. Oct 1 '14 at 14:35
• Thanks for the nice welcome! That is exactly what I feared - that one of my other dependencies and/or definitions was 'intruding' here. Will update question with MWE soon. Oct 1 '14 at 14:48
• Tried removing packages from my original in a MWE one by one. Found the suspect - the ulem package. Answered my question for later reference. Oct 1 '14 at 14:51

## 2 Answers

Actually, you don't have to remove the ulem package, since it could be useful somewhere else. Use the \normalem and \ULforem commands provided by the ulem package.

The conditions of algorithm2e package are emphasized, and ulem package by default replaces italics with underlining for all emphasized text, that's why underlines appear automatically when using algorithm2e and ulem package together.

But fortunately ulem package provides a \normalem command/option to disable this default feature, and provides a \ULforem command/option to enable it. So here is my solution:

\normalem %%%% disable auto underline

\begin{algorithm}[H]
algorithms goes here ...
\end{algorithm}[H]

\ULforem %%%% enable auto underline


Reference:

ulem manual http://texdoc.net/texmf-dist/doc/generic/ulem/ulem.pdf

and this similar example: Getting \emph back to normal after loading ulem

It appeared that removing the ulem package, which I once used for strikeouts, did the trick. It now typesets with the expected format.

• Glad, you found the error and thanks for answering here. But as this is very localized and may not help others in future, you might delete this post. Or, even better, you clarify your question (complete MWE, tag ulem) and write a complete answer. If you think, this could help other TeXnicans, this would be the propper way to go. Thank you. Oct 1 '14 at 15:13
• Thanks for this "localized" yet very useful answer! I have to say, sometimes just one keyword (ulem) with a bit of search can solve the problem! I encountered the same problem, and I did find the ulem package used in my .cls file. Apr 18 '15 at 12:48
• One should load ulem (if really necessary) with the option normalem, that is, \usepackage[normalem]{ulem}, so the package will not redefine \em and \emph. Apr 18 '15 at 13:31