[Tex/LaTex] Text mode commands/symbols in math mode

equationsmath-modesymbols

I am fairly new to LaTeX, and have run into a problem with commands apparently only available in text mode, where I would like to use them in math mode as well (e.g. integrated in equations).

One of the commands/symbols in question is the upside down exclamation sign used to represent the subfactorial function.
In running text, I can use the command \textexclamdown, but this does not work in math mode (as far as I can tell).

Is there a way to seamlessly integrate text mode commands in the middle of rather hairy equations?

Best Answer

You can define your own symbol:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathSymbol{\subfactorial}{\mathord}{operators}{"3C}

\begin{document}
\begin{equation}
\begin{aligned}
n!=\sum_k h(n,k) &= \sum_k \binom{n}{k}(n-k)\subfactorial\\
  &=\sum_k\binom{n}{k}k\subfactorial
\end{aligned}
\tag{5.49}
\end{equation}
\end{document}

This will work so long as the "operators" font is OT1 encoded. Should it be T1 encoded, change "3C" into "BD (this might depend on your font settings).

The equation (same number) is taken from "Discrete Mathematics", by Graham, Knuth and Patashnik (the original uses Euler fonts, but the result is quite similar).

enter image description here