Wrong font family in algorithm2e
The correct command is \mathrm
in every case.
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage[ruled]{algorithm2e}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\KwIn{Blalalala.}
\KwOut{Blalalala}
\For{$t = 1$ to $T$}{
Fit $\Psi_{t+1}$ to $\mathcal{H}_{t}$\\
$\mathbf{x} \leftarrow \argmax_{\mathbf{x} \in \mathcal{X}}
a(\mu (\Psi_{t+1} (\mathbf{x})) , \sigma(\Psi_{t+1} (\mathbf{x})) , J^{\textup{min}})$\\
Check $c=J(\mathbf{x})$\\
$\mathcal{H}_{t+1} \leftarrow \mathcal{H}_{t} \cup \lbrace (\mathbf{x},c) \rbrace $\\
\If{ $c (\mathbf{x}) < c^{\textup{min}} $}{
$\mathbf{x}^{\textup{min}},c^{\textup{min}} \leftarrow \mathbf{x},c$
}
}
\Return $\mathbf{x}^{\textup{min}}$
\caption{Testing}
\end{algorithm}
\end{document}
You'd get the same result with \textup
. The problem is that \text
picks up the font that's current when the formula starts, which is italic in the argument to \If
.
Side note. Your MWE cannot produce “mín” from \min
. That happens if you load babel-spanish, for instance.
At least, I got a workaround.
\documentclass{article}
\usepackage{amsmath,amssymb}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\KwIn{Blalalala.}
\KwOut{Blalalala}
\For{$t = 1$ to $T$}{
Fit $\Psi_{t+1}$ to $\mathcal{H}_{t}$\\
$\mathbf{x}\leftarrow \argmax_{\mathbf{x}\in\mathcal{X}} a(\mu (\Psi_{t+1} (\mathbf{x})),\sigma(\Psi_{t+1} (\mathbf{x})) , J^\text{min})$\\
Check $c=J(\mathbf{x})$\\
$\mathcal{H}_{t+1} \leftarrow \mathcal{H}_{t} \cup \left\lbrace(\mathbf{x},c)\right\rbrace$\\
\If{ $c (\mathbf{x}) < c^\mathrm{min} $}{
$\mathbf{x}^\text{min},c^\text{min} \leftarrow \mathbf{x},c $
}
}
\Return $\mathbf{x}^\text{min}$
\caption{Testing}
\end{algorithm}
\end{document}
Surely, there are fonts which make a difference between \text{}
and \mathrm{}
visible to the naked eye, but for this example, I cannot distinguish my output "min"s whether it was created with the further or the latter.