# Grouping and undefined control sequence error

I was trying to figure out an answer to another question, which required a change of font and size in the middle of a sentence. So I tried to use a \begingroup and \endgroup to isolate the change of font and size. The result is what I was looking for, but it is nonetheless throwing the undefined control sequence error. What am I missing?

\documentclass[8pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{microtype}

\newfontfamily\csa{Dekar}

\newcommand{\abc}[1]{%
\begingroup\csa\footnotesize\textls[130]{#1}%
\endgroup\normalfont\normalfontsize
}

\begin{document}

Hello Kitty \abc{DIN  103} by Sanrio.

\end{document}


And the question I was considering: How to set the name of a standard or the name of a standard component?

The error you get is

! Undefined control sequence.
\abc ...{#1}\endgroup \normalfont \normalfontsize

l.14     Hello Kitty \abc{DIN  103}
by Sanrio.


that means the undefined control sequence is \normalfontsize.

On the other hand, you don't need to restore the font and its size, because the group already limits the scope.

I guess the Dekar font is quite big; you can avoid setting a size by loading it at some scale factor. For instance

\newfontfamily{\csa}{Dekar}[Scale=MatchUppercase]


and the definition can become

\newcommand{\abc}[1]{%
{\csa\textls[130]{#1}}%
}


Instead of MatchUppercase you can specify a factor, such as 0.75; experiment in order to find the desired magnification.

• Wonderful explanation, much obliged. – A Feldman May 14 '16 at 21:24
• I guess making up your own, mythical, slightly different than actual, control sequences is not exactly "best practice". Special thanks for being patient with that. – A Feldman May 14 '16 at 21:34