I'm reading this derivation of the equipartition theorem for ideal gases. On the second page, it is mentioned that the partition function as a simple sum,
$${\displaystyle Z=\sum _{i}e^{-\varepsilon _{i}/kT}}$$
is not adequate to describe a classical gas as the distribution of energies is not discrete, but continuous. Instead, an integral is needed where
$$e^{-\varepsilon/kT}$$
is integrated over positions and momenta of which energy is a function of. But why is this conversion from a sum to an integral correct?
I can understand why an integral is needed, as the distribution of energies is continuous. But why is it correct to just integrate the exponential function to get the sum? Doesn't the integral give us the area under the curve of the exponential function, that is (speaking perhaps non-rigorously), the sum of the values of the function at different points, multiplied by the differentials $dx$, rather than the simple sum of the values? I've seen this kind of thing done in other places as well, and it bugs me.