I am currently combining solutions proposed here for the loop definition of commands and here for the upper case letter forcing to define mathematical notations in a loop.
The goal is to have a shortcut for all letters of the latin and greek alphabets in bold font and upper/lower case.
For the latin alphabet the current solution works fine, but for the greek one it won't work.
So I actually have two questions here:
- 1: Is it possible to automatically loop over greek letters with pgffor, just like with latin letters
- 2: Is there a reason for my current solution not to work with greek letters
As usual, the answer may be very short or very long, so thanks in advance.
\documentclass{article}
% Command forcing 1st letter of argument to be capital one
\usepackage{xparse}
\ExplSyntaxOn
\NewExpandableDocumentCommand \firstcap { m } { \tl_mixed_case:n {#1} }
\ExplSyntaxOff
% Loop over latin alphabet (working)
\usepackage{pgffor}
\foreach \x in {a,...,z}{%
\expandafter\xdef\csname \firstcap{\x}mat\endcsname{\noexpand\ensuremath{\noexpand\mathbf{\firstcap{\x}}}}
}
\foreach \x in {a,...,z}{%
\expandafter\xdef\csname \firstcap{\x}vec\endcsname{\noexpand\ensuremath{\noexpand\mathbf{\x}}}
}
% Loop over greek alphabet (non working)
%\foreach \x in {alpha,zeta}{%
%\expandafter\xdef\csname \firstcap{\x}mat\endcsname{\noexpand\ensuremath{\noexpand\mathbf{\firstcap{\x}}}}
%}
%\foreach \x in {\alpha,...,\zeta}{%
%\expandafter\xdef\csname \firstcap{\x}vec\endcsname{\noexpand\ensuremath{\noexpand\mathbf{\x}}}
%}
\begin{document}
$\Amat \Bmat \Cmat \Avec \Bvec \Cvec$
%$\Alphamat \Betamat \Alphavec \Betavec$
\end{document}

\expandafter\def\csname abc\alpha xxx\endcsname{blub}. If you want to build command only with Alpha you will have to write out the list explicitly. Btw: it is dangerous to define commands without checking if they are already defined. – Ulrike Fischer Feb 28 '19 at 17:21\foreachlike other easy loops. – egreg Feb 28 '19 at 21:10\newcommand\foosyntax. I will try with the explicit list – BambOo Feb 28 '19 at 21:45