Units of observables in quantum mechanics Observables in quantum mechanics are described by Hermitian operators $\hat A: V \to V$, where $V$ is the Hilbert space of states.
Examples include the $x$-coordinate operator $\hat x$, the $x$-coordinate momentum operator $\hat p_x$, and the Hamiltonian operator $\hat H$.
The possible measured values are the eigenvalues of the operator $\hat A$.
However, eigenvalues are naturally real numbers (because $\hat A$ is Hermitian, more generally complex numbers), without any units.
My question is then

Where do the units come from?

I understand that in specific examples you can "see" that the observable has the correct units (for instance $\hat p_x = -i \hbar \frac{\partial}{\partial x}$ could be interpreted as having units $\mathrm{J} \cdot \mathrm{s} \cdot \frac{1}{\mathrm{m}} = \frac{\mathrm{kg} \cdot \mathrm{m}}{\mathrm{s}}$), but I can't see where this enters in the mathematics (even if we assume that we have such a "formula" for $\hat A$).
Edit:
As the comments seem to misinterpret my question, let me clarify it.
I don't even understand what is the meaning of multiplying a vector (state) by a number with units such has $\hbar$.
By definition, in a vector space you can multiply by a vector by a scalar from the field of definition ($\mathbb C$ in our case), but I can't make sense of multiplying by a number with units.
 A: 
Edit:
As the comments seem to misinterpret my question, let me clarify it.
I don't even understand what is the meaning of multiplying a vector (state) by a number with units such has $\hbar$.
By definition, in a vector space you can multiply by a vector by a scalar from the field of definition ($\mathbb C$ in our case), but I can't make sense of multiplying by a number with units.

I will build on the material in jberger's answer and my answer to 'Is 0m dimensionless?
.
In physics, calculations are normally done with physical quantities, and not with real numbers. This is important, because physical quantities are not a field, since not all additions are well-defined. Instead, the set of physical quantities is a set
$$
\mathcal P = \{(q,d):q\in \mathbb C,d\in \mathbb Q^N\}
$$
whose elements consist of the quantity value $q$, which may be real but we allow in general to be complex, and the dimension, which is an $N$-tuple of rational numbers, with $N$ the number of algebraically-independent dimensions that you want to include in your theory.
Now, as I said, $\mathcal P$ is not a field, and instead it what you might call a field-with-dimensions, which is equipped with the following operations:

*

*addition, $(q_1,d)+(q_2,d) = (q_1+q_2,d)$, when both quantities have equal dimension; and

*multiplication, $(q_1,d_1)\times(q_2,d_2) = (q_1\times q_2, d_1+d_2)$.

Since these are not field operations, the field axioms do not even make sense. However, they have transparent generalizations; if you really care about this then it's a good exercise to write them down.
Now, this works thus far for scalar physics, but we have yet to touch vector spaces. Those are normally defined relative to a field, but we want to move away from those dimensionless mathematics, so we need to define a new structure, which you might call a vector-space-with-(physical)-dimensions. To do this we need a pre-existing vector space $V$ over $F=\mathbb C$ (or $\mathbb R$ as required), and we basically generate $\mathbb Q$-fold copies of $V$, each with its own physical dimension:
$$
V_\mathcal P = \{(v,d):v\in V,d\in \mathbb Q^N\}.
$$
As above, we need to define the operations anew, and this is again transparent:

*

*addition, $(v_1,d)+(v_2,d) = (v_1+v_2,d)$, when both vectors have equal physical dimension; and

*scalar multiplication, $(s,d_1)\times(v,d_2) = (s\, v, d_1+d_2)$, for $s\in \mathbb F$ and $v\in V$.

Since these are not the algebraic operations of a vector space, the vector-space axioms no longer make sense, so instead they need to be generalized to this setting; again, the generalization is transparent and obvious.
Finally, what happens with linear operators? We want to assign them physical dimensionality as well, so how is that done? Basically, again, by direct imposition: we define linear operators on vector-spaces-with-physical-dimensions as functions
$$
A:V_\mathcal P \to V_\mathcal P
$$
with an assigned dimension $d_A$ such that $A(v,d_v)$ has dimension $(d_V+d_A)$ for every $(v,d_v)\in V_\mathcal P$, and such that

*

*$A\big((v_1,d_v)+(v_2,d_v)\big) = A(v_1,d_v)+A(v_2,d_v)$; and

*$A((s,d_s)\times(v,d_v)) = (s,d_s)\times A(v,d_v)$.

At least on the surface, this looks different enough to the normal definition of linear operator that the entire work needs to be repeated, but this is easy to avoid. For any linear operator $A$ with physical dimension $d$, if you define an arbitrary scale $s = (q,d)\in\mathcal P$, then $A/s$ has physical dimension $0$, which means that it respects all of the layers in $V_\mathcal P$ and can thus be treated as a normal vector-space linear operator within each of those layers, and the usual results hold for it; you can then extend those results to $A = s \times (A/s)$ by applying the multiplication-by-$s$ identity operator.
Also of note here: keep in mind that there are now two independent notions of 'dimension', that of vector-space dimension (to do with linear independence of vectors in $V$) and that of physical dimension (to do with algebraic independence of physical quantities). That means that you need to be careful when speaking about 'dimension' in this setting unless the context makes it dead clear what you mean.
If you really cared about this, then you would need to re-do all of linear algebra and functional analysis from scratch (doing things like ensuring the [physical dimensions match before doing any addition) to account for this.

*

*Why haven't physicists done this effort? Because the extension is trivial and it's not worth the time to notate like this; we have better uses for our time and the material is understood well enough that we know that nothing is going to break if we ignore it.

*Why haven't mathematicians gone to these lengths? You'll have to ask them. They seem a bit allergic to dimensional analysis, so maybe that has something to do with it, but ultimately this is a trivial extension and there's little to be gained from doing it in depth, and again they have better uses for their time.

If you feel that this is important and you have the time and inclination to go and fill in the gaps, though, then you should go ahead and do so!
A: The heart of this question stems from a desire for a mathematical "algebraic" definition of a dimensionful quantity.
The OP is concerned that a mathematical vector space $V$ should admit multiplication by elements of the mathematical field, $F$, over which the vector space is defined.
The problem is that dimensionful quantities do NOT form a field. Suppose $x$ and $y$ represent two lengths, that is they both have dimension of $L$. We might write
$$
[x] = [y] = [L]
$$
To notate this.
We are able to add $x$ and $y$ together. If we allow negative lengths then we see that there is an additive inverse for every length and there is also an additive identity length (zero length). The addition is commutative and associative and the operation is closed. This means that the space of physical lengths forms an abelian group.
However, we cannot multiply two lengths together and get another length. This is because
$$
[xy] = [L^2]
$$
If we multiply two lengths together we have something which has dimensions of length squared. This is like an area. Of course in physics we know that this is a perfectly valid and simple operation. We use it all the time. Mathematically, however, this means that the space of physical lengths is NOT a field, because for something to be a field you must be able to multiply two of its elements and get another one of its elements.
The OPs question then, if I may rephrase it, is how do we multiply a vector by a dimensionful quantity if dimensionful quantities don't form a field?
The physics answer is, it's easy, just multiply and add as you would if the dimensionful quantity were an element of a bonafide field and just keep track of the dimensions as you normally would. The OP, however desires an answer based on algebraic mathematical definitions.
My answer will include the introduction of a new sort of mathematical object which I would like to refer to as a general physical quantity. Suppose that we have 3 base dimensions, mass ($M$), length ($L$) and time ($T$) and suppose all dimensionful quantities could be formed from these 3. In real physics, using the SI system, for example, you may need to include more base dimensions but this set of 3 will suffice for now.
Any physical quantity can be described by a real number $q$ and a 3-tuple $d \in \mathbb{R}^3$ which describes the dimension of that quantity. The 3-tuple carries the exponents of the respective dimension for the quantity. Any physical quantity can be expressed as a tuple $(q, d)$. For example a length $[L]$ may be written as:
$$
x = (1, (0, 1, 0))\\
$$
A time $[T]$ may be written as
$$
t = (3, (0, 0, 1))
$$
While a force $[ML^2 T^{-2}]$ would be written as
$$
f = (0, (1, 2, -2))
$$
We call the set of all tuples $(q, d)$ the set of physical quantities and denote this space by $P$.
We can define a partial addition on the space $P$. Suppose $p_1 = (q_1, d_2)$ and $p_2 = (q_2, d_2)$. We have
$$
p_1 + p_2 = (q_1 + q_2, d_1)
$$
if $d_1 = d_2$. If $d_1 \neq d_2$ then the operation is undefined. This means the space $P$ is NOT a group under addition. However, if we restrict to elements of a fixed $d$ then we do have an abelian group.
We can define multiplication of any two elements of $P$.
$$
p_1 * p_2 = (q_1q_2, d_1 + d_2)
$$
We now have a "rigorous" definition of a physical quantity, $p \in P$.
We can now define multiplication of a vector times a physical quantity. Let $P$ be the space of physical quantities and let $V$ be a vector space of the field $\mathbb{C}$. We define the space of dimensionful vectors $V_D$ as the set of tuples $(v, d)$ where $v \in V$ is a vector and $d\in\mathbb{R}^3$ is a dimension representation as before. This space has similar rules for multiplication and addition of its elements as $P$. We first define multiplication by a physical quantity. Suppose $v_1 = (v_a, d_a) \in V_D$ and $p_b = (q_b, d_b) \in P$. We define
$$
p_b * v_1 = (q_b, d_b) * (v_a, d_a) = (q_b v_a, d_a + d_b) \in V_D
$$
Note we can also define multiplication by a regular scalar $z \in \mathbb{C}$ by
\begin{align}
z * v_1 = z * (v_a, d_a) = (z v_a, d_a)
\end{align}
Alternatively, if we had allowed physical quantities $p\in P$ to be have complex values (instead of just reals) we could identify the "dimensionless scalars" with physical quantities whose dimension $d = \boldsymbol{0} = (0, 0, 0)$.
We can define addition of two elements $v_1 = (v_a, d_a)$ and $v_2 = (v_b, d_b)$ by
\begin{align}
v_1 + v_2 =& (v_a, d_a) + (v_b, d_b) = (v_a + v_b, d_a)
\end{align}
Where the operation is again only defined if $d_a = d_b$.
Consider the set
$$
V_{d_0} = \{\bar{v} = (v, d)|v\in V \text{ and } d = d_0 \in \mathbb{R}^3\} \subset V_D
$$
This is the subset of $V_D$ which has fixed dimension $d_0$. It can be seen that this space is a vector space because it is closed under addition and multiplication by dimensionless scalars and has all the appropriate properties.
Ok, now we have dimensionful vector spaces. I think we now need to define dimensionful operators on these spaces to finally answer the OPs question. A dimensionful operator $X_1$ is a tuple $(X_a, d)$ where $d$ is a dimension tuple as before and $X_a:V\rightarrow V$ is an operator on $V$. This operator takes in dimensionful vectors and outputs dimensionful vectors:
$$
X_1: V_D \rightarrow V_D
$$
defined by (supposing $v_1 = (v_b, d_b)$)
$$
X_1 v_1 = (X_a, d_a)*(v_b, d_b) = ( X_a v_B, d_a + d_b)
$$
This should answer the OPs question of how quantum operators can be dimensionful. This answer also may be useful for designing software protocols which handle dimensionful quantities.
The OP has another question which is, if it is so complicated to handle dimensionful quantities why have I not seen this presentation anywhere else? The answer is that it is not complicated at all to handle dimensionful quantities as I described above. Just algebraically manipulate the quantities as if they were elements of a single field (just making sure not to add the quantities unless they have the same dimension) and then perform dimensional analysis as you normally would. All of this discussion adds basically no value to a physicist trying to calculate something and as long as you pay attention to dimensional analysis throughout your calculation, you will not have any problems.
Said yet one more way, physical quantities behave exactly like elements of a field except for the single fact that you cannot add quantities that have different dimensions. This whole post is basically a very very long winded way to encode that statement in mathematical definitions. The main thrust of the OP is to point out that physical quantities are not a field.
edit:
Adding more to respond to the OPs specific concerns about Hermitian operators. In quantum mechanics lets consider the kets $|\psi\rangle$ to be dimensionless vectors. This is not always the case but it will suffice for now. How does a dimensionful operator act on these kets?
Well, recall that a dimensionful operator $\bar{X} = (X, d)$ is an operator (or function if you prefer) on the space $V_D$ of dimensionful vectors. However, consider the action of this operator on a dimensionless vector $\bar{v} = (v, \boldsymbol{0})$
\begin{align}
\bar{X} * \bar{v} =& (X, d) * (v, \boldsymbol{0}) = (Xv, d+\boldsymbol{0}) = (Xv, d) \in V_d
\end{align}
So we see that if we restrict $\bar{X}$ maps the vector space $V_0$ to the vector space $V_d$. And in particular the mapping is
$$
\bar{X} * (v, \boldsymbol{0}) = (1, d) * (Xv, \boldsymbol{0})
$$
So it is exactly as if you had a simple dimensionless vectors and operators, you just have to remember multiply by the unit dimensionful quantity $(1, d)$ at the end.
Dimensionful hermitian operators. Consider hermitian operator $H$ on $V$. Consider then $\bar{H} = (H, d)$. Suppose $v$ is an eigenvector of $H$ with real eigenvalue $\lambda$: $Hv = \lambda v$.
\begin{align}
\bar{H} * \bar{v} =& (H, d) * (v, \boldsymbol{0}) = (Hv, d) = (1, d) * (\lambda v, \boldsymbol{0})\\
=& (1, d) * \lambda \bar{v} = (\lambda, d) * \bar{v}
\end{align}
This notation makes it look very suggestive that $\bar{v}$ is an eigenvector of $\bar{H}$ with dimensionful eigenvalue $(\lambda d)$. Of course this statement is not technically correct because $\bar{H}$ is not a mapping from a vector space to itself but it is damn close to one. The only difference is a trivial multiplication by the unit dimensionful quantity $(1, d)$.
To address the OPs question: At the extremely high levels of pedantry we are entertaining here operators in quantum mechanics are NOT technically hermitian operators. They do not act from a space onto itself. Rather, they might map dimenionsless vectors in $V_{\boldsymbol{0}}$ to dimensionful vector in $V_d$. However, they look similar enough to regular hermitian operators that the difference doesn't affect anything and we can generally think of them as being hermitian operators.
Note it might be useful to define the adjoint of a dimensionful operator as
$$
\bar{X}^{\dagger} = (X, d)^{\dagger} = (X^{\dagger}, d)
$$
This will allow one to work with inner products of dimensionful vectors etc.
A: Your question already exists at the classical level.
You are right, "units" don't really exist in the equations of physics in the fundamental sense which you're thinking about. Units arise when you try to compare one physical observable to another, i.e. how many centimeters will give me the size of my arm? What about the distance from the center of a hydrogen nucleus to the average radius of its orbiting electron? Thus, suppose in some fundamental sense my arm has length $l_a=16$. There is absolutely no sense in speaking about this standalone length - we must compare it with something: suppose a matchstick has $l_m=2$, then $l_a=\frac{l_a}{l_m}\times l_m = 8\times l_m$, and now $l_m$ is what we call our "unit". There would be nothing wrong with defining your units such that $l_m=1$ for simplicity, but sometimes doing so will make other calculations numerically unpleasant.
In this sense, $\hbar$ is just a unit-conversion factor from "fundamental" to "human", i.e. "how many joules of energy is contained in this atom?". If you're working only with fundamental quantities, your life will be much simpler by just choosing units where $\hbar=1$, but if you're trying to do calculations for, say, a nuclear reactor, it may be more helpful to choose $\hbar=1.05\times10^{-34}$, which is identical to choosing your "unit of energy" as Joules.
One catch to all this, however, is that this concept of units may only apply to quantities which are additive, else your choice of units will change under trivial arithmetic operations. For example, suppose my arm has length $l_a=10^{n_a}$ and a stick has length $l_s=10^{n_s}$. The combined length end-to-end of the stick and my arm is:
$$l_a+l_s=10^{n_a}+10^{n_s}=10^{n_T}$$
where
$$n_T=\log_{10}\left(10^{n_a}+10^{n_s}\right)$$
which is not equal to $n_a+n_s$ (or some other linear combination of $n_a$ and $n_s$), so the units of $n_a$ and $n_s$ will not simply carry over to be the units of $n_T$. I would have to artificially reintroduce such units by multiplying and dividing $n_T$.
This is in contrast with choosing your units for additive quantities. For example, if you choose your units for length to be the length of a matchstick $l_m$, then you would have:
$$l_a=\left(\frac{l_a}{l_m}\right) l_m$$
$$l_s=\left(\frac{l_s}{l_m}\right) l_m$$
$$\implies l_a+l_s=\left(\frac{l_a}{l_m}+\frac{l_s}{l_m}\right) l_m$$
So the units carry over nicely this trivial arithmetic operation. In principle you could be a nonconformist and ignore this principle of defining units only for quantities that respect "simple" arithmetic operations, and start dealing with oddities like "exponential units", "logarithmic units", etc. But the issue is that you will then need to have separate units for all the different mathematical functions which do behave nontrivially under common arithmetic operations - $\sin$ units, exponential units, logarithmic units, etc. etc.
