The thermodynamic theory of capillarity under the hypothesis of a continuous variation of density