We prepared alternating CNx/TiN composite films using a dc magnetron sputtering system in which a closed unbalanced magnetic field was adopted and a negatively biased grating was placed in front of each substrate. The composition of the thin film was analyzed by X-ray photoelectron spectroscopy (XPS). X-ray diffraction (XRD) and transmission electron diffraction (TED) revealed that the CNx films deposited at grating voltages lower than 400V are amorphous. β-C3N4 and subic-C3N4(c-C3N4) were formed at higher voltages. A high grating voltage is indispensable for synthesis of c-C3N4. The lattice constants of C3N4 evaluated from the experimental data agree well with reported theoretical values.