The spatial distribution of colloidal particles in an energy field is evaluated theoretically. The field may be established by a relatively large object such as a rigid wall, a closed boundary, and a particle. The set of nonlinear hypernetted chain equations describing the variations of the correlation functions for particle–particle and particle–object interactions is solved. A numerical scheme based on the discrete Fourier transform is proposed for the former, and a Newton–Raphson iterative method for the latter. Three cases are examined to illustrate the method proposed, namely, particles in a planar slit, cylindrical pore, and square duct. The qualitative behavior of the spatial variation of the concentration of colloidal particles predicted by the present study is consistent with that observed experimentally by D.H. Van Winkle and C.A. Murray [J. Chem. Phys. 89 (1988) 3885].