# Defining a symbol that scales when used as a subscript

I defined a command by

\newcommand{\antishriek}{\mbox{\footnotesize{\rotatebox[origin=c]{180}{$!$}}}},

which gives a small, upside-down exclamation mark. I always use it as an exponent for other symbols, such as

which is given by $\mathscr{P}^{\antishriek}$. My problem is when I try to put the whole thing as a subscript, in which case my symbol doesn't scale. For example, writing $\Delta_{\mathscr{P}^{\antishriek}}$ gives

with the symbol exactly of the same size. Is there a way to make my symbol scale when I put it as the superscript of a subscript without having to define a second symbol giving the same output, but smaller?

• i'm not in a situation where i can test anything, but the symbol is prevented from sizing because you've given it a fixed size when you pack it in the \mbox{\footnotesize{...}}. try removing just the sizing instruction, and see what that does. Jan 27, 2017 at 1:07
• @barbarabeeton I just tried, and nothing changes. The symbol as a superscript or as a superscript of a subscript has the same dimension. Jan 27, 2017 at 1:22

Instead of creating your own symbol, LaTeX has a predefined \textexclamdown that one can use. So, technically, you can do:

\usepackage{amsmath}
\newcommand{\antishriek}{\text{\raisebox{\depth}{\textexclamdown}}}

amsmath's \text will ensure that the correct size is used, while \raisebox puts the inverted exclamation at the baseline (if you want it that way; similar to what \rotatebox[origin=c]{180} would do for !).

In general, if you wish to have a command vary in its presentation depending on the location where it's used in math mode, then you can consider using \mathchoice (or the wrapper \mathpalette). \mathchoice has the following format:

\mathchoice{<material for display style>}
{<material for text style>}
{<material for script style>}
{<material for scriptscript style>}

So, in your case, you could supply the formatting (sizing and rotation or whatever) to suit your needs. Here's an example of what that means: Consider the hypothetical \somesymbol:

\newcommand{\somesymbol}{\mathchoice
{a}% \displaystyle
{b}% \textstyle
{c}% \scriptstyle
{d}% \scriptscriptstyle
}

The above "symbol" definition displays (left is in default \displaystyle, while the right is in forced \textstyle, for comparison):

$\somesymbol^{\somesymbol^{\somesymbol^{\somesymbol}}} \quad \somesymbol_{\somesymbol_{\somesymbol_{\somesymbol}}} \qquad\textstyle \somesymbol^{\somesymbol^{\somesymbol^{\somesymbol}}} \quad \somesymbol_{\somesymbol_{\somesymbol_{\somesymbol}}}$

Specific to your symbol, you may then use (as an example):

\newcommand{\antishriek}{\mathchoice
{\rotatebox[origin=c]{180}{!}}% \displaystyle
{\rotatebox[origin=c]{180}{!}}% \textstyle
{\rotatebox[origin=c]{180}{\scalebox{.7}{!}}}% \scriptstyle
{\rotatebox[origin=c]{180}{\scalebox{.5}{!}}}% \scriptscriptstyle
}

which displays as

$\somesymbol^{\somesymbol^{\somesymbol^{\somesymbol}}} \antishriek^{\antishriek^{\antishriek^{\antishriek}}} \quad \somesymbol_{\somesymbol_{\somesymbol_{\somesymbol}}} \antishriek_{\antishriek_{\antishriek_{\antishriek}}} \qquad\textstyle \somesymbol^{\somesymbol^{\somesymbol^{\somesymbol}}} \antishriek^{\antishriek^{\antishriek^{\antishriek}}} \quad \somesymbol_{\somesymbol_{\somesymbol_{\somesymbol}}} \antishriek_{\antishriek_{\antishriek_{\antishriek}}}$

Here they are together, to show the relative sizing:

${\somesymbol\antishriek}^{{\somesymbol\antishriek}^{{\somesymbol\antishriek}^{{\somesymbol\antishriek}}}} \quad {\somesymbol\antishriek}_{{\somesymbol\antishriek}_{{\somesymbol\antishriek}_{{\somesymbol\antishriek}}}} \qquad\textstyle {\somesymbol\antishriek}^{{\somesymbol\antishriek}^{{\somesymbol\antishriek}^{{\somesymbol\antishriek}}}} \quad {\somesymbol\antishriek}_{{\somesymbol\antishriek}_{{\somesymbol\antishriek}_{{\somesymbol\antishriek}}}}$

Relevant:

• Thank you for your answer! I learned a lot by reading it. Jan 27, 2017 at 1:31
• When this is put into an environment that does `\emph' the symbol also italicizes. Is there a way to prevent this? Sep 15, 2020 at 9:34
• @PedroTamaroff: Perhaps try adding \upshape before the symbol. If this doesn't work, please provide a complete minimal example that replicates your problematic behaviour.
– Werner
Sep 19, 2020 at 2:49

Here is a scalerel solution in which ¡ is scaled to the vertical footprint of the ! in the appropriate math style.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath, mathrsfs,scalerel}%
\newcommand{\antishriek}{\scalerel*{$¡$}{!}}

\begin{document}

$\mathscr{P}^{\antishriek}\mathscr{P}^{!}\quad \Delta_{\mathscr{P}^{\antishriek}}\Delta_{\mathscr{P}^{!}}\quad \antishriek !$%
\end{document}

Why make things more comples than they are?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath, mathrsfs}%
\newcommand{\antishriek}{\text{¡}}

\begin{document}

$\mathscr{P}^{\antishriek}\quad \Delta_{\mathscr{P}^{\antishriek}}\quad \antishriek$%

\end{document}

• This is a nice solution, however, I also use an exclamation mark in the same way, and if I do that for both (by defining the exclamation mark by \text{!}) they are not placed in the same way. Also, simply using $!$ and \rotatebox[origin=c]{180}{$!$} (without putting it in an \mbox and resizing), the symbols are too big. Jan 27, 2017 at 1:19