in math mode?
I googled it, but I got nothing;(
This mostly depends on what kind of symbol you need. If it's an ordinary symbol, just
\#
will do, using the hash symbol from the main text font. But if you need a relation symbol or an operation symbol, you need, respectively
\mathrel\#
\mathbin\#
Note the difference:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$a # b$
$a \mathrel# b$
$a \mathbin# b$
\end{document}
The difference between the last two is subtle, but noticeable.
Of course, the best is, after you have decided the type, to define your command, for instance
\newcommand{\mathhash}{\mathrel\#}
Choose a more semantic name.
You might want to import \hash from mathabx. Here I define a \mathrel, change to \mathord or \mathbin if you want an ordinary or operation symbol respectively.
\documentclass{article}
\usepackage{amsmath}
\DeclareFontFamily{U}{matha}{}
\DeclareFontShape{U}{matha}{m}{n}{
<-5.5> matha5
<5.5-6.5> matha6
<6.5-7.5> matha7
<7.5-8.5> matha8
<8.5-9.5> matha9
<9.5-11> matha10
<11-> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\hash}{\mathrel}{matha}{"23}
\begin{document}
$a \hash b$
\end{document}
\#. – campa Sep 07 '22 at 15:04