[texhax] combing adjacent macros

Donald Arseneau asnd at triumf.ca
Sat May 30 07:25:05 CEST 2009


Dorothy Jammins <dorothy.jammins at yahoo.com> writes:

> \hyph\var -> (hyph., var)   Using the same definition for \hyph and \var, I was wondering if it was possible to achieve this:
> 
> \hyph\var -> $_{hyph., var}$ i.e. to combine the two and make them subscript at the same time whether they are already in a math environment or not.

Sure.  LaTeX has \ensuremath.  I suspect it will not be simple to
use \ensuremath directly in the solution because it reads its
parameter text up front, but you can look at its definition.
For example, you could use 
 ...
 \ifmmode _\bgroup \else $_\bgroup \aftergroup$\fi

-- 
Donald Arseneau                          asnd at triumf.ca


More information about the texhax mailing list