# [Tex/LaTex] Changing algorithm2e keywords fonts

algorithm2efonts

A journal has asked me to change the font of my algorithm to Courier New. I'm able to change all except the keywords (if, then, else, etc.). My best solution looks like this:

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}[H]
{{\fontfamily{pcr}
\If {{\fontfamily{pcr}\selectfont condition}}
}}
\end{algorithm}
\end{document}


You can set each of the algorithm components individually (through settings like \SetKwStyle, \SetArgSty, \SetDataSty, ...), or change the font at the start of every algorithm automatically by adjusting \textnormal:

\documentclass{article}

\usepackage{algorithm2e,etoolbox}
\AtBeginEnvironment{algorithm}{\let\textnormal\ttfamily}

\begin{document}

\begin{algorithm}[H]
\If {condition}{true clause}
\end{algorithm}

\end{document}


etoolbox was used to tap into \begin{algorithm}.