Let us suppose we have some quantum system whose Hilbert space admits a bipartition $\mathscr{H}\simeq \mathscr{H}_A\otimes \mathscr{H}_B$. Let $|n\rangle_A$ be a basis of $\mathscr{H}_A$ and $|m\rangle_B$ be a basis of $\mathscr{H}_B$. Then $|n,m\rangle_{A,B}$ is a basis of the composite system.
A general mixed state $\rho$ can be written always as $$\rho=\sum \rho_{nmn'm'}|n,m\rangle_{AB}\langle n',m'|$$
And we can define the partial trace over $\mathscr{H}_A$ to be $$\operatorname{Tr}_A\rho=\sum \rho_{mm'}|m\rangle_B\langle m'|,\quad \rho_{mm'}=\sum_n \rho_{nmnm'}$$
This seems to work well if $|n\rangle_A,|m\rangle_B$ are discrete basis.
Now, in Quantum Mechanics we often work with "continuous bases". These are not really rigorous since the "position eigenstates" $|x\rangle$ are not well defined. Still, this is very useful.
So now suppose that for $\mathscr{H}_A$ we take such a $|x\rangle_A$ basis. Then a basis of $\mathscr{H}$ is $|x,m\rangle_{A,B}$ and the state is $$\rho=\sum \int \rho_{mm'}(x,x') |x,m\rangle_{A,B}\langle x',m'|$$
And we can in analogy take a partial trace $$\operatorname{Tr}_A\rho=\sum \rho_{mm'}|m\rangle_B\langle m'|,\quad \rho_{mm'}=\int \rho_{mm'}(x,x)dx$$
It seems everything is fine, but now take the pure state $\rho = |z,\sigma\rangle\langle z,\sigma|$ (for instance, a particle located at $z$ with spin $S_z$ being $\sigma$). If we evaluate $$\rho_{mm'}(x,x')=\delta_{m\sigma}\delta_{m'\sigma}\delta(x-z)\delta(x'-z)$$
and the partial trace involves $(\delta(x-z))^2$ which is ill-defined.
Still, there should certainly be a way of talking about partial traces when continuous degrees of freedom like position and momentum are involved.
How is that done correctly? How to avoid this issue of getting a delta function squared when taking a partial trace over continuous degrees of freedom?