I wrote a code:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\tvm}[1]{{\mathbf{#1}}}
\newcommand{\tdot}[1]{\expandafter\dot#1}
\newcommand{\vecta}{{\tvm{v}}{abc}^{def}}
\newcommand{\vectb}{\tvm{v}{abc}^{def}}
\begin{document}
$ \tdot{\vecta} $ % line a
\
$ \tdot{\vectb} $ % line b
\end{document}
where \tdot is used to apply \dot only to the base character of the argument that has subscripts, and 'line a' gives a correct result as
But 'line b' that uses \vectb gives an error. The difference comes from the braces around \tvm{v}. I would like to let the macro \tvm have its output braced somewhat internally so that I don't need to write braces for each use of \tvm.
Note that actual definition of \tvm that I use is
\makeatletter
\newcommand{\vm}[1]{
\@tfor\next:=#1\do{
\ifcat\next\relax
{\boldsymbol{\next}}
\else
{\mathbf{\next}}
\fi
}
}
\makeatother
which discriminate between English and Greek.


{\tvm{v}}to brace the base, but also use\mathrm{def}notdefnever use math italic for words, it is spaced to look like a product of variables. Also are you sure that\ifcattest does what you want (it seems very weird) and why use\mathbf(so getting upright bold) on some inputs but\boldsymbol(so getting bold italic) on others? why not simply use\boldsymbol{#1}or better,\bm{#1}? – David Carlisle Oct 04 '21 at 06:55