Unified formalism for electromagnetic and gravitational probes: Densities