Thin films of TiNx are synthesized by reactive dc sputtering of a titanium cathode in an Ar/N2 gas mixture. The substrates (glass, stainless steel, and silicon) are negatively biased at −200 or −300 V. The composition is monitored in situ by the measurement of the Ti Lα,β, Ti Ll,n, N Kα, and O Kα x-ray line or band intensities. The x-ray emission is induced in the film during the deposition by the high energy secondary electrons (about 4 keV) emitted by the cathode. After deposition, x-ray measurements are also carried out while using a cold cathode electron gun. The oxygen content of the films measured during deposition is low (<1 wt. %). The titanium nitride films appear to become rapidly overstoichiometric (up to TiN1.4) when the nitrogen partial flow rate increases. These overstoichiometric films show an x-ray diffraction pattern corresponding mostly to fcc TiN with the plane (111) oriented parallel to the substrate surface. These results are correlated to the changes of the Ti Lα,β emission band profile which depends drastically on the titanium chemical environment.