Centering \dot in a symbol macro (\listofsymbol)

I was trying to achieve the results of get a variable listed in listofsymbol's generated list, when called with a -dot suffix. If was trying also to find a way to center dot in variables with subscript (without using subscript listing capabilities of the package).

To do that a macro \checkUnderscore was implemented, that tries to find _ character in a string, split and insert the command before the subscript.

But if the macro has a \mathbf directive, the dot is printed in the extreme left of the variable.

I cannot find a solution for this behavior, but i think it is an error in my macro. Do you have any idea? thank's in advance.

A minimal example:

\documentclass{article}
\usepackage{xstring}
\usepackage[final]{listofsymbols}

\newcommand{\checkUnderscore}[1]{\IfSubStr{#1}{_}{\dot{\StrBefore{#1}{_}}_{\StrBehind{#1}{_}}}{\dot{#1}}}

\makeatletter
\renewcommand{\@createsym}[3]
{\expandafter\newcommand\expandafter{\csname#2\endcsname}{\relax\ensuremath{#3}\spaceaftersym\expandafter\protected@xdef\csname#2isused\endcsname {yes}} %evntl. gdef
\expandafter\newcommand\expandafter{\csname#2doc\endcsname}{#1}
\expandafter\newcommand\expandafter{\csname#2tabdoc\endcsname}{\ensuremath{#3} & #1}
\expandafter\newcommand\expandafter{\csname#2isused\endcsname}{no}
\expandafter\newcommand\expandafter{\csname#2dot\endcsname}{\relax\ensuremath{\expandafter\checkUnderscore#3}\spaceaftersym\expandafter\protected@xdef\csname#2isused\endcsname {yes}}}
\makeatother

\opensymdef
\newsym[Test A]{symA}{x}
\newsym[Test B]{symB}{x_{p}}
\newsym[Test C]{symC}{\mathbf{x}}
\newsym[Test D]{symD}{\mathbf{x}_{p}}
\closesymdef

\begin{document}
\begin{itemize}
\item Here's my symbol $\symAdot$,
\item and the other one with subscript $\symBdot$,
\item and the other one bold $\symCdot$,
\item and the other bold one with subscript $\symDdot$,
\end{itemize}

\listofsymbols
\end{document}


• it looks like your expansion is applying the dot to only the \mathbf, not to what it is applied to. adding a second set of braces to \newsym[Test C]{symC}{{\mathbf{x}}} only results in an unhelpful error message. what you want to get as the expanded forms is \dot{\mathbf{x}} and \dot{\mathbf{x}}_{p} (note that only the bolded "x" should have the dot applied). but how you would parse that i'm not prepared to explore. – barbara beeton Oct 8 '14 at 17:43
• Yes you understood the problem, but is more likely dot is applied to an empty object (\dot{}\mathbf{x}_p), not to only \mathbf. Thank's for your help. – Matteo Ragni Oct 8 '14 at 18:08

Just writing \dot in front of your object works in all your cases, just don't add extra brackets. The underscore testing is unnecessary.

\documentclass{article}

\usepackage[final]{listofsymbols}

\makeatletter
\renewcommand{\@createsym}[3]
{\expandafter\newcommand\expandafter{\csname#2\endcsname}{\relax\ensuremath{#3}\spaceaftersym\expandafter\protected@xdef\csname#2isused\endcsname {yes}} %evntl. gdef
\expandafter\newcommand\expandafter{\csname#2doc\endcsname}{#1}
\expandafter\newcommand\expandafter{\csname#2tabdoc\endcsname}{\ensuremath{#3} & #1}
\expandafter\newcommand\expandafter{\csname#2isused\endcsname}{no}
\expandafter\newcommand\expandafter{\csname#2dot\endcsname}{\relax
\ensuremath{\dot #3}\spaceaftersym\expandafter\protected@xdef\csname#2isused\endcsname {yes}}}
\makeatother

\opensymdef
\newsym[Test A]{symA}{x}
\newsym[Test B]{symB}{x_{p}}
\newsym[Test C]{symC}{\mathbf{x}}
\newsym[Test D]{symD}{\mathbf{x}_{p}}
\closesymdef

\begin{document}
\begin{itemize}
\item Here's my symbol $\symAdot$,
\item and the other one with subscript $\symBdot$,
\item and the other one bold $\symCdot$,
\item and the other bold one with subscript $\symDdot$,
\end{itemize}

\listofsymbols
\end{document}