4

I would like to some symbols lower than others in a math formula, without size change, for example

\def\abcd#1#2{\left[\raisebox{-.4em}{{\ensuremath{#1}}}\kern-.3em\setminus\kern-.2em#2\right]}
$\abcd{X_1}{X_2}$

which gives enter image description here

But when I use this notation in a subscript position $$\bigoplus_{\abcd{X_1}{X_2}}$$, the left glyph remains at normalsize (because of the \raisebox acting like a \hbox and ignoring the fact that it is located in a subscript):

enter image description here

How can I define a math-font-size-knowledgeable \raisebox command?

yannis
  • 2,013
  • 19
  • 18

2 Answers2

3

You can use \mathpalette plain TeX macro:

\def\abcd#1#2{\left[\mathpalette\abcdA{#1}\mkern-6mu{\setminus}#2\right]}
\def\abcdA#1#2{\lower.4em\hbox{$#1#2$}}

Moreover, the \setminus is re-typed as Ord using {\setminus}, so you needn't compensate the space after it by negative kern. And the first negative kern is expressed in mu units in order to work in script sizes too.

wipet
  • 74,238
2

You don't have to guess the amount of lowering. It's necessary to use \mathpalette in order to use the right font size. See The mysteries of \mathpalette

\documentclass{article}
\usepackage{amsmath}

\makeatletter

\newcommand{\abcd}[2]{\left[\mathpalette\abcd@{#1}\backslash#2\right]} \newcommand{\abcd@}[2]{% % #1 = math style % #2 = text to be lowered \raisebox{% % we make it so that the top of the % lowered part is at the formula axis \dimexpr-\height+\abcd@fontdimen{#1}% }{% % we don't want that \scriptspace kicks in \scriptspace=\z@ % the part to be lowered $\m@th#1#2$% }% } \newcommand{\abcd@fontdimen}[1]{% % the height of the formula axis is \fontdimen22 <math font of family 2> \fontdimen22 \ifx#1\displaystyle\textfont\else \ifx#1\textstyle\textfont\else \ifx#1\scriptstyle\scriptfont\else \scriptscriptfont\fi\fi\fi 2 } \makeatother

\begin{document}

[ \abcd{X_1}{X_2}\qquad\bigoplus_{\abcd{X_1}{X_2}} ] [ \abcd{X}{Y}\qquad\bigoplus_{\abcd{X}{Y}} ]

\end{document}

enter image description here

egreg
  • 1,121,712