[Tex/LaTex] Style problem in algorithmic package

algorithmsbold

I'm using algorithmic package and I write algorithms. It seems OK but the operators, like IF, ELSE, FOR, ENDIF, etc., are not bold.

Is there anyone that has an idea?

Here is an example:

\begin{algorithm}
  \caption{Tournament algorithm}
  \label{alg:algoTournament}
\begin{boxedminipage}{155mm}
    \begin{algorithmic}[1]
    \STATE $fitness \leftarrow 0$
    \STATE $groupIndex \leftarrow -1$
    \FOR {$i \leftarrow 1$ to $tournamentSize$}
        \STATE Select a random group G1
        \IF {$G1$ in $selectedGroups$}
            \STATE Select another group for G1
        \ENDIF
        \IF {$fitness < fitnessOfSelectedGroup$}
            \STATE {$fitness=fitnessOfSelectedGroup$}
            \STATE {$groupIndex=indexOfSelectedGroup$}
        \ELSE 
            \STATE continue
        \ENDIF
        \STATE Add $G1$ to $selectedGroups$
    \ENDFOR
    \STATE return $groupIndex$
   \end{algorithmic}
\end{boxedminipage}
 \vskip17.5pt
\end{algorithm}

Best Answer

  • Use a font which provides a bold typeface

  • Check your log file for font warnings

This minimal example shows bold operators in your code:

\documentclass{article}
\usepackage[hmargin=3cm]{geometry}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{boxedminipage}
\begin{document}
\begin{algorithm}
  \caption{Tournament algorithm}
  \label{alg:algoTournament}
\begin{boxedminipage}{155mm}
    \begin{algorithmic}[1]
    \STATE $fitness \leftarrow 0$
    \STATE $groupIndex \leftarrow -1$
    \FOR {$i \leftarrow 1$ to $tournamentSize$}
        \STATE Select a random group G1
        \IF {$G1$ in $selectedGroups$}
            \STATE Select another group for G1
        \ENDIF
        \IF {$fitness < fitnessOfSelectedGroup$}
            \STATE {$fitness=fitnessOfSelectedGroup$}
            \STATE {$groupIndex=indexOfSelectedGroup$}
        \ELSE 
            \STATE continue
        \ENDIF
        \STATE Add $G1$ to $selectedGroups$
    \ENDFOR
    \STATE return $groupIndex$
   \end{algorithmic}
\end{boxedminipage}
 \vskip17.5pt
\end{algorithm}
\end{document}

enter image description here