[Tex/LaTex] Inverted exclamation mark in Mathmode

math-modesymbols

What is the command/package used to give the Inverted exclamation mark in Mathmode. I have tried the following:

\mbox{!`}_A - The output is not at the same margin level as !.

\mbox{\textexclamdown}_A -  The output is again not at the same margin level as !.

\rotatebox[origin=c]{180}{!}_A -  The output is at the same margin, and this is what is required. However, I find this too complex for a simple inverted exclamation mark.

Best Answer

Taking code from https://tex.stackexchange.com/a/312530/4427, here is a version that raises the inverted exclamation mark to sit on the baseline.

\documentclass{article}
\usepackage{amsmath}

\DeclareMathSymbol{\mathinvertedexclamationmark}{\mathclose}{operators}{'074}
\DeclareMathSymbol{\mathexclamationmark}{\mathclose}{operators}{'041}

\makeatletter
\newcommand{\raisedmathinvertedexclamationmark}{%
  \mathclose{\mathpalette\raised@mathinvertedexclamationmark\relax}%
}
\newcommand{\raised@mathinvertedexclamationmark}[2]{%
  \raisebox{\depth}{$\m@th#1\mathinvertedexclamationmark$}%
}
\begingroup\lccode`~=`! \lowercase{\endgroup
  \def~}{\@ifnextchar`{\raisedmathinvertedexclamationmark\@gobble}{\mathexclamationmark}}
\mathcode`!="8000
\makeatother

\begin{document}

$n! + n!`$

$\scriptstyle n! + n!`$

\end{document}

enter image description here

You might want to use \mathord instead of \mathclose throughout, if your symbols are to denote objects of a category. Or, better, define semantic commands.

\documentclass{article}
\usepackage{amsmath}

\DeclareMathSymbol{\mathinvertedexclamationmark}{\mathord}{operators}{'074}
\DeclareMathSymbol{\mathexclamationmark}{\mathord}{operators}{'041}
\makeatletter
\newcommand{\raisedmathinvertedexclamationmark}{%
  \mathord{\mathpalette\raised@mathinvertedexclamationmark\relax}%
}
\newcommand{\raised@mathinvertedexclamationmark}[2]{%
  \raisebox{\depth}{$\m@th#1\mathinvertedexclamationmark$}%
}
\makeatother

\newcommand{\terminal}{\mathexclamationmark}
\newcommand{\initial}{\raisedmathinvertedexclamationmark}

\begin{document}

$\terminal\to\initial$

\end{document}

enter image description here