I have done my best to understand \expandafter
, \edef
and friends, but I can't find a way of using them to force expansion of the parameter passed in to the macro \FormatDate
in the following example.
\documentclass{article}
\makeatletter
\def\@FormatDateAuxA#1/#2/#3 #4.{%
% Day
\number#3\relax\space
% Month
\ifcase#2{}?#2?\or
January\or February\or March\or April\or
May\or June\or July\or August\or
September\or October\or November\or December\else
?#2?\fi\space
% Year
\ifnum#1>99{}#1\else\ifnum#1>9{}19#1\else190#1\fi\fi}
\def\@FormatDateAuxB#1$#2.{{
\typeout{\noexpand#1}
\@FormatDateAuxA#1 X.}}
\def\FormatDate#1{\@FormatDateAuxB#1$X.}
\makeatother
\begin{document}
\FormatDate{2015/4/15}
\def\Date{2015/4/15}
\FormatDate{\Date}
\end{document}
The above gives the following output.
2015/4/15
\Date
! Argument of \@FormatDateAuxA has an extra }.
\Date hasn't been expanded and that has (presumably) stopped the pattern-matching for the parameter of \@FormatDateAuxA
working. Any help with this will be greatly appreciated.