Grouping with \dosingleempty
Hi, I am confused why the following definition does not work as expected. \def\PM{\dosingleempty\doPM} \def\doPM[#1]{\iffirstargument P_{M_{#1}} \else P_{M_t}\fi} \starttext Why is $\widetilde \PM[T]$ not the same as $\widetilde P_{M_T}$ \stoptext Can I change the definition so that $\widetilede \PM$ is same as $\widetilde P_{M_t}$ and $\widetilede \PM[T]$ is same as $\widetilde P_{M_T}$ Thanks, Aditya
Aditya Mahajan wrote:
Hi, I am confused why the following definition does not work as expected.
\def\PM{\dosingleempty\doPM} \def\doPM[#1]{\iffirstargument P_{M_{#1}} \else P_{M_t}\fi}
\starttext Why is $\widetilde \PM[T]$ not the same as $\widetilde P_{M_T}$ \stoptext
The argument to \widetilde cannot be a macro that requires arguments, that just won't work. If you want the accent on top of a single character, you have to give it a single argument. It is possbile to do so, like this: \def\PM{P\dosingleempty\doPM} \def\doPM[#1]{\iffirstargument _{M_{#1}}\else _{M_t}\fi} \let\normalwidetilde\widetilde \def\widetilde{\expandafter\normalwidetilde} But it is better to create a new set of macros \widetildePM. Cheers, Taco
On Tue, 6 Jun 2006, Taco Hoekwater wrote:
Aditya Mahajan wrote:
Hi, I am confused why the following definition does not work as expected.
\def\PM{\dosingleempty\doPM} \def\doPM[#1]{\iffirstargument P_{M_{#1}} \else P_{M_t}\fi}
\starttext Why is $\widetilde \PM[T]$ not the same as $\widetilde P_{M_T}$ \stoptext
The argument to \widetilde cannot be a macro that requires arguments, that just won't work. If you want the accent on top of a single character, you have to give it a single argument. It is possbile to do so, like this:
\def\PM{P\dosingleempty\doPM} \def\doPM[#1]{\iffirstargument _{M_{#1}}\else _{M_t}\fi} \let\normalwidetilde\widetilde \def\widetilde{\expandafter\normalwidetilde}
Thanks. I will test around to see it this has undesired side-effects. If something else breaks, I will define \def\ewidetilde{\expandafter\widetilde} and use \ewidetilde before \PM.
But it is better to create a new set of macros \widetildePM.
That is what I was doing till now. But I have a lot of costructs like this, \PM[t] <=> P_{M_t}, \PYM <=> P_{Y_t,M_{t-1}}, \PYMS <=> P_{Y_t,M_{t-1},S_t} and so on and all of them can have widetilde and wildehat. Gets kind of boring to define \tPM for widetilde \hPM for widehat for all of them. Thanks, Aditya
participants (2)
-
Aditya Mahajan
-
Taco Hoekwater