How to derive the macroscopic dielectric function?

I'm following Matteo Gatti's slides to repeat the derivation of macroscopic dielectric function $$\epsilon_M$$:

$$\epsilon_M=\dfrac{1}{\epsilon^{-1}_{\vec{G}=0,\vec{G}'=0}(\vec{q},\omega)}.$$

On page 41 one needs to perform the following derivations:

Here are my derivations:

Note:

• $$V_{tot}$$ and $$V_{ext}$$ is a periodic potential in real space.

One can see to obtain the final result I have introduced a delta function, is it reasonable? Or do I miss something to arrive at the final result?

Perhaps it's missing a prefactor? If you split the sum as $$\sum_{\textbf{q}'} \sum_{\textbf{G}'} V_{ext}(\textbf{q}' + \textbf{G}', \omega) \int d\textbf{r}_1 d\textbf{r}_2 e^{-i(\textbf{q}+\textbf{G})\cdot \textbf{r}_1} \epsilon^{-1}(\textbf{r}_1, \textbf{r}_2, \omega) e^{i(\textbf{q}'+\textbf{G}')\cdot \textbf{r}_2},$$ then you can shift $$\textbf{G'} \rightarrow \textbf{G}' - \textbf{q}' + \textbf{q}$$, which yields $$\sum_{\textbf{q}'} \sum_{\textbf{G}'} V_{ext}(\textbf{q} + \textbf{G}', \omega) \int d\textbf{r}_1 d\textbf{r}_2 e^{-i(\textbf{q}+\textbf{G})\cdot \textbf{r}_1} \epsilon^{-1}(\textbf{r}_1, \textbf{r}_2, \omega) e^{i(\textbf{q}+\textbf{G}')\cdot \textbf{r}_2} \\ = \sum_{\textbf{q}'} \sum_{\textbf{G}'} V_{ext}(\textbf{q} + \textbf{G}', \omega) \epsilon^{-1}_{\textbf{G}\textbf{G}'}(\textbf{q}, \omega).$$
The sum over $$\textbf{q}'$$ is simply the number of $$\textbf{q}$$-points, that's why I think it's missing a prefactor.