A nematic liquid crystal in contact with a solid substrate is studied by means of the Landau--de Gennes formalism. The free-energy functional is expanded around the bulk nematic order parameter up to the second-order terms. This approximation is used to obtain an explicit condition for the anchoring direction in terms of the surface and bulk coupling constants, in a semi-infinite system. Then a finite system is studied and the equilibrium free energy is found as a function of the angular deviation from the anchoring direction and the sample thickness. A geometrical measure of the anchoring strength, resembling the de Gennes extrapolation length, is obtained from the asymptotic behavior of the free energy for large sample thicknesses. \textcopyright{} 1996 The American Physical Society.