0

Using the algorithm2e package I am trying to write an algorithm on a document. I wish to change the default font used on the \SetKwData variables and I am trying to do that by using the \SetDataSty function as shown below:

\SetAlFnt{\footnotesize}
\SetDataSty{\small\fontfamily{qcr}} % this line causes Extra \endcsname. errors

\SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} \begin{algorithm}[h] \LinesNumbered

\SetKwData{AVG}{average_val}

\Input{A tuple $(a,b)$} \Output{A hashmap $m$}

\BlankLine

\AVG

\end{algorithm}

But I am getting Extra \endcsname. errors on the compilation log. What am I doing wrong here?

ex1led
  • 339

1 Answers1

1

You need to define a command with an argument giving the font specification and then use the name of this command in the argument for \SetDataSty:

%! TEX program = lualatex
\documentclass[12pt]{article}
\usepackage{algorithm2e}
\begin{document}

\SetAlFnt{\footnotesize} \newcommand\mydatastyle{\small\fontfamily{qcr}} \SetDataSty{mydatastyle} % this line does not cause Extra \endcsname. errors

\SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} \begin{algorithm}[h] \LinesNumbered

\SetKwData{AVG}{averageval}

\Input{A tuple $(a,b)$} \Output{A hashmap $m$}

\AVG

\end{algorithm}

\end{document}

first sentence quote nearly-verbatim from https://tex.stackexchange.com/a/162208/250119

user202729
  • 7,143