I want to use the command \DTLstoreinitials
from package \usepackage{datatool}
in the following way :
\newcommand{\extractInitials}[1]{%
\DTLstoreinitials{#1}{\userInitials}%
\DTLsubstituteall{\userInitials}{.}{}%remove points between the initials
\DTLsubstituteall{\userInitials}{ }{}%remove spaces
\userInitials%
}
If I call the command directly, it works :
\extractInitials{My Name}
gives MN
. But if I use an auxiliary command: \newcommand{\nom}{My Name}
and try to call
\extractInitials{\nom}
then the compilation fails with error
! Paragraph ended before \@dtl@initials was complete.
How can I fix this?
Here is a minimal example 1 :
\documentclass[12pt]{article}
\usepackage{trackchanges}
\usepackage{datatool}
\newcommand{\extractInitials}[1]{%
%\expandafter\DTLstoreinitials\expandafter{#1}{\userInitials}%
\DTLstoreinitials{#1}{\userInitials}%
\DTLsubstituteall{\userInitials}{.}{}%remove points
\DTLsubstituteall{\userInitials}{ }{}%remove spaces
}
\begin{document}
\extractInitials{AAA BBB}\addeditor{\userInitials}
\extractInitials{CCC DDD}\addeditor{\userInitials}
----------- \\% to see the result of the addeditor commands
\makeatletter
\TC@editorOne\\
\TC@editorTwo\\
\TC@editorThree\\
\makeatother
-----------
\end{document}
The output is CD n/n n/n To compare : example 2
\addeditor{AB}
\addeditor{CD}
----------- \\% to see the result of the addeditor commands
\makeatletter
\TC@editorOne\\
\TC@editorTwo\\
\TC@editorThree\\
\makeatother
-----------
The output is AB CD n/n