  Starting with Maxwell's equations and defining normal variables in the
Fourier space, we write the equations of temporal evolution of the
electromagnetic field with sources in the Hamiltonian and Lagrangian forms,
making explicit all intermediate steps often omitted in standard textbooks.
Then, we follow the same steps to write the equations of evolution of this
field along a spatial dimension in the Hamiltonian and Lagrangian forms. In
this way, we arrive at the explicit form of the generator of spatial evolution
of the electromagnetic field with sources and show that it has a physical
meaning of the modulus of momentum transferred through a given plane orthogonal
to the direction of propagation. In a particular case of free field this
generator coincides with the projection of the full momentum of the field on
the propagation direction, taken with a negative sign. The Hamiltonian and
Lagrangian formulations of the spatial evolution are indispensable for a
correct quantization of the field when considering its spatial rather than
temporal evolution, in particular, for a correct definition of the equal-space
commutation relations.
