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

0

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...?
    – user202729
    Jun 14 at 11:29
  • Well, i still get the same error
    – ex1led
    Jun 14 at 14:22
  • @ex1led Give MWE. The document I include in my answer does not get any error
    – user202729
    Jun 14 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.