The Hamilton-Cartan formalism in the calculus of variations