In math, # usually denotes the number of elements in a set (cardinality).

For example, in this equation

enter image description here

the #D{x} operator denotes the number of elements in the set D that satisfies property x.

I am trying to render this character in TeX, and this code


gives this symbol:

enter image description here

What am I missing?


It seems the font used in the image is Adobe Times/URW Nimbus as provided by the txfonts package (or some very similar variant of it):


\[ \hat\thetaup_{ijk} = \hat P(X_i=x_{ij}\mid Y=y_k)
    = \frac{\#D\{X_i=x_{ij} \wedge Y=y_k\}}{\#D\{Y=y_k\}} \]

enter image description here

Original answer

The font used in your image is not the default Computer Modern font. You could use \text{\ttfamily\#}, which is closer to the symbol in the image, but still not the same:



$\#D$ vs. $\tthash D$

enter image description here

Wikipedia also just lists the standard \# as a symbol for cardinality.

For the exact same output, you need to find the font that provides this special hash character glyph.

  • 1
    txfonts has many weaknesses, avoid it and prefer newtxtext,newtxmath. – egreg Nov 12 '19 at 8:38

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.