PDE:
$$ u_t (x,t) - u_{xx} (x,t) = 0, \quad u(0,t)=0, \quad u_x(2,t)=0, \quad u(x,0)=\delta(x-x_0) $$
where $0<x_0<2$ is a given constant.
I worked out my solution by using separation of variables $$u(x,t)=X(x)T(t) \implies \frac{X''(x)}{X(x)}=\frac{T'(t)}{T(t)}=\lambda$$
For $\lambda>0$ and $\lambda=0$ we get trivial solutions, but for $\lambda=-k^2<0$ we get the solutions
$$ X(x)=c_1 sink_nx, \quad k_n=\frac{\pi}{2}(\frac{1}{2}+n), \quad n=0,1,... $$ $$ T(t)=c_2e^{-k_n^2t} $$
Superposition gives the general solution to the PDE as
$$ \sum_{n=0}^\infty c_n sin(k_nx)e^{-k_n^2t}, \quad k_n=\frac{\pi}{2}(\frac{1}{2}+n)$$
Now for my question, I don't understand how to handle the initial condition to calculate the fourier coefficients $c_n$. I have the solution for it though, and what they have done is this (I understand this step);
$$ u(x,0)=\sum_{n=0}^\infty c_n sin(k_n x) = \delta(x-x_0) \quad (1)$$
This is the step I don't understand;
$$ (1) \implies c_n = \frac{\int_0^2 \delta(x-x_0)sin(k_nx)dx}{\int_0^2 sin^2(k_nx)dx}=sin(k_n x_0) $$
Any explanation as to why and how they got that expression for $c_n$, and also why it equals $sin(k_n x_0)$ (it's like they're discounting the denominator and only looking at the numerator?) would be greatly appreciated.
Starting from your last equation
$$ \sum_n c_n \sin (k_n x) = \delta(x - x_0) $$
Multiply by $\sin (k_m x)$ on both sides and integrate
$$ \sum_n c_n \color{blue}{\int \sin (k_m x) \sin (k_n x)~{\rm d}x} = \int \delta(x - x_0)\sin (k_m x)~{\rm d}x \tag{1} $$
The blue term is zero unless $n = m$, which means
$$ \sum_n c_n \color{blue}{\delta_{nm}\int \sin (k_n x) \sin (k_n x)~{\rm d}x} = c_m\color{blue}{\int \sin^2 (k_m x) ~{\rm d}x} = \int \delta(x - x_0)\sin (k_m x)~{\rm d}x $$
and from here
$$ c_m = \frac{\int \delta(x - x_0)\sin (k_m x)~{\rm d}x}{\int \sin^2 (k_m x) ~{\rm d}x} $$