Denoting by q(i) (i = 1, ..., n) the set of extensive variables which chara
cterize the state of a thermodynamic system, we write the associated intens
ive variables gamma (i),, the partial derivatives of the entropy S = S (q(1
), ..., q(n)) equivalent to q(0), in the form gamma (i) = -p(i) / p(0) wher
e p(0) behaves as a gauge factor. When regarded as independent, the variabl
es q(i), p(i) (i = 0, ..., n) define a space T having a canonical symplecti
c structure where they appear as conjugate. A thermodynamic system is repre
sented by a n + 1-dimensional gauge-invariant Lagrangian submanifold M of T
. Any thermodynamic process, even dissipative, taking place on M is represe
nted by a Hamiltonian trajectory in T, governed by a Hamiltonian function w
hich is zero on M A mapping between the equations of state of different sys
tems is likewise represented by a canonical transformation in T. Moreover a
Riemannian metric arises naturally from statistical mechanics for any ther
modynamic system, with the differentials dq(i) as contravariant components
of an infinitesimal shift and the dp(i)'s as covariant ones. Illustrative e
xamples are given.