[Tex/LaTex] stop bold in algorithmx

algorithmicxbold

I am using the algorithmx package:

http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/algorithmicx/algorithmicx.pdf

The keywords such as "if", "while", "then", "else" "end if" etc. etc. all appear in bold font. I am looking for an easy "switch" to turn off the bold font "feature" of this package. Any help would be appreciated.

Best Answer

There is no such feature in algorithmicx (I suggest contacting the package author to customize this as a new package feature).

Take algpseudocode, for example. All the keywords are defined verbatim as \textbf{<keyword>}:

%
%      ***      KEYWORDS      ***
%
\algnewcommand\algorithmicend{\textbf{end}}
\algnewcommand\algorithmicdo{\textbf{do}}
\algnewcommand\algorithmicwhile{\textbf{while}}
\algnewcommand\algorithmicfor{\textbf{for}}
\algnewcommand\algorithmicforall{\textbf{for all}}
\algnewcommand\algorithmicloop{\textbf{loop}}
\algnewcommand\algorithmicrepeat{\textbf{repeat}}
\algnewcommand\algorithmicuntil{\textbf{until}}
\algnewcommand\algorithmicprocedure{\textbf{procedure}}
\algnewcommand\algorithmicfunction{\textbf{function}}
\algnewcommand\algorithmicif{\textbf{if}}
\algnewcommand\algorithmicthen{\textbf{then}}
\algnewcommand\algorithmicelse{\textbf{else}}
\algnewcommand\algorithmicrequire{\textbf{Require:}}
\algnewcommand\algorithmicensure{\textbf{Ensure:}}
\algnewcommand\algorithmicreturn{\textbf{return}}
\algnewcommand\textproc{\textsc}

You would have to redefine these to suit your needs in a very generic way. Alternatively, if you're willing to sacrifice all \textbf usages within the algorithmic environment, you can make \textbf a no-op by adding to your document preamble:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\AtBeginEnvironment{algorithmic}{\let\textbf\relax}

Here is a minimal example showing the output with the above change:

enter image description here

\documentclass{article}
\usepackage{algorithm,algpseudocode,etoolbox}
\AtBeginEnvironment{algorithmic}{\let\textbf\relax}
\begin{document}

\begin{algorithm}
  \caption{Euclid’s algorithm}\label{euclid}
  \begin{algorithmic}[1]
    \Procedure{Euclid}{$a,b$}\Comment{The g.c.d.\ of $a$ and $b$}
      \State $r\gets a\bmod b$
      \While{$r\not=0$}\Comment{We have the answer if $r$ is $0$}
        \State $a\gets b$
        \State $b\gets r$
        \State $r\gets a\bmod b$
      \EndWhile\label{euclidendwhile}
      \State \textbf{return} $b$\Comment{The gcd is $b$}
    \EndProcedure
  \end{algorithmic}
\end{algorithm}

\end{document}

This is what the output would have looked like without the no-op addition/patch using etoolbox:

enter image description here

Related Question