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?

3

1 Answer 1

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

3
  • Actually I'm not quite sure if the lack of grouping cause problem or not...? Commented Jun 14, 2022 at 11:29
  • Well, i still get the same error Commented Jun 14, 2022 at 14:22
  • @ex1led Give MWE. The document I include in my answer does not get any error Commented Jun 14, 2022 at 14:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.