Quantum-size effects have been shown to influence significantly the determi
nation of work functions from thin-slab calculations. We show here that a t
echnique based on macroscopic averages can be used to reduce such effects a
nd determine more precisely the work functions of metals from ab initio thi
n-film calculations. The technique combines the mean electrostatic potentia
l step across the slab surface with the Fermi energy of a bulk crystal. The
method is applied to Al(100) slabs containing 1-14 atomic layers.