I'm trying to use pgffor to define a new command for \boldsymbol\mathsf like the following.
\documentclass{article}
\usepackage{pgffor,amsmath}
\newcommand\makemathsfbf[1]{
\foreach\a\b\c in{#1}{
\expandafter\gdef\csname\a\b\c\expandafter\endcsname\expandafter{%
\expandafter\boldsymbol{\mathsf\expandafter{\a}}
}
}
}
\makemathsfbf{AAA,BBB,...,ZZZ} % {AAA,BBB, CCC, DDD, ..., ZZZ}
\begin{document}
$\AAA$ % = $\boldsymbol{\mathsf A}$
\end{document}
I want to use the above command, i.e., \AAA, to replace \boldsymbol{\mathsf A} and so on. However, I could not make it to work. How should I modify it?

\abc(or some other macro) instead of\a\b\c. – John Kormylo Sep 13 '21 at 13:43\abc. Unfortunately, it didn't work out. – stackname Sep 13 '21 at 13:53AAA,BBB,...,ZZZis not a valid loop specification for pgf (or any other language I know) – David Carlisle Sep 13 '21 at 13:58\boldsymbol\mathsf{A}would be the same as\boldsymbol{\mathsf}{A}You are missing the{}for\boldsymbolbut you want to loop from A to Z not an undefined sequence from AAA to ZZZ, then construct the csname from three copies of the loop variable – David Carlisle Sep 13 '21 at 14:01expandafter\boldsymbol{expands{which is not expandable, – David Carlisle Sep 13 '21 at 14:04https://tex.stackexchange.com/a/594722/181831. I think I need to go through a document to learn how to use this command. – stackname Sep 13 '21 at 14:10AAA,BBB,...,ZZZas a single entry rather than a list. – John Kormylo Sep 13 '21 at 14:17