The present paper describes a method for autofocusing specifically studied for the acquisition of digital slides, i.e. full histologic and cytologic slides, utilising low-cost equipment. At first, experimentations with some of the most used focus measures and algorithms have been made, in order to choose the most suitable for histologic and cytologic images. Then, a study of the specific features of digital slides has been preliminarily carried out in order to understand the constraints of the domain. These included the capability of autofocusing in an unattended way on thousands of microscope fields, while fast performance is not a strict requirement. Based on the findings, an algorithm based on a dynamic focus position space, with a variance-based focus measure has been adapted to the specific situation. A qualitative and quantitative evaluation of the proposed algorithm allowed us to show that the proposed algorithm is suitable for the acquisition of digital slides, and furthermore it can be implemented starting from a basic microscope with an inexpensive motorised stage. The algorithm is currently implemented into a complete digital slide acquisition system, which is in turn being used for a Quality Assurance Programme in cervicovaginal cytologic screening.