算法包中的样式问题

算法包中的样式问题

我正在使用算法包并编写算法。看起来不错,但是 IF、ELSE、FOR、ENDIF 等运算符不是粗体。

有谁有想法吗?

以下是一个例子:

\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}

答案1

  • 使用提供粗体字体的字体

  • 检查日志文件中是否存在字体警告

这个最小的例子显示了代码中的粗体运算符:

\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}

在此处输入图片描述

相关内容