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?

  • 1
    Welcome to TeX.SE! Could you provide a minimal example that allows us to reproduce the problem? – Nils L Mar 20 '13 at 14:40
  • 1
    if you use amsmath, you have the \text{...} command available for including text. but for the upside down exclamation mark, it would be better to define a math command. – barbara beeton Mar 20 '13 at 14:43

You can define your own symbol:



n!=\sum_k h(n,k) &= \sum_k \binom{n}{k}(n-k)\subfactorial\\

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

  • i realize that the spanish exclamation mark is positioned like it has a descender, but since the ordinary factorial ! is placed on the baseline, i'm not sure of the proper vertical alignment of a subfactorial in math. (i really don't know, which is why i'm asking.) – barbara beeton Mar 20 '13 at 17:55
  • 1
    @barbarabeeton Equation 5.49 in "Discrete Mathematics", by Graham, Knuth and Patashnik: it descends as normal. – egreg Mar 20 '13 at 18:05

Your question can be broken down into a few manageable parts.

  1. Any text command can be used in mathmode if you use it as an argument to the \text macro, as in \text{\textexclamdown}.

  2. To have it play the proper role in the spacing of the mathematics, you should embed this in a \mathord macro, as in \mathord{\text{\textexclamdown}}.

  3. Because \mathord{\text{\textexclamdown}} is a bit cumbersome to write, and isn't very suggestive of what you want it to signify, I'd suggest writing a macro for the subfactorial function, similar to


    and then use \subfac to represent the subfactorial function. (This way if you decide that you would like to modify how the subfactorial is displayed, you can do it once and all instances of it will get changed.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.