This expression is divergent but can be made finite in a sensible way by subtraction of a corresponding slice in infinite volume, i.e., without boundary conditions in the x direction. An alternative way of getting rid of the unphysical infinite part is so-called dimensional regularisation. The above integral (the sum will be attacked analogously later) falls into a class of integrals that is parametrised by (a.o.) the dimension. The method then consists of computing the convergent integrals within this class, and redefining the divergent ones by analytic continuation (in the set of parameters) of the convergent outcomes.