  The state of a thermodynamic system being characterized by its set of
extensive variables $q^{i}(i=1,...,n) ,$ we write the associated intensive
variables $\gamma_{i},$ the partial derivatives of the entropy $
S(q^{1},...,q^{n}) \equiv q_{0},$ in the form $\gamma_{i}=-p_{i}/p_{0}$ where
$p_{0}$ behaves as a gauge factor. When regarded as independent, the variables
$q^{i},p_{i}(i=0,...,n) $ define a space $\mathbb{T}$ having a canonical
symplectic structure where they appear as conjugate. A thermodynamic system is
represented by a $n+1$-dimensional gauge-invariant Lagrangian submanifold
$\mathbb{M}$ of $\mathbb{T}.$ Any thermodynamic process, even dissipative,
taking place on $\mathbb{M}$ is represented by a Hamiltonian trajectory in
$\mathbb{T},$ governed by a Hamiltonian function which is zero on $\mathbb{M}.$
A mapping between the equations of state of different systems is likewise
represented by a canonical transformation in $\mathbb{T}.$ Moreover a natural
Riemannian metric exists for any physical system, with the $q^{i}$'s as
contravariant variables, the $p_{i}$'s as covariant ones. Illustrative examples
are given.
