We study the chemical properties of the stellar populations in eight simulations of the formation of Milky-Way mass galaxies in a LCDM Universe. Our simulations include metal-dependent cooling and an explicitly multiphase treatment of the effects on the gas of cooling, enrichment and supernova feedback. We search for correlations between formation history and chemical abundance patterns. Differing contributions to spheroids and discs from in situ star formation and from accreted populations are reflected in differing chemical properties. Discs have younger stellar populations, with most stars forming in situ and with low alpha-enhancement from gas which never participated in a galactic outflow. Up to 15 per cent of disc stars can come from accreted satellites. These tend to be alpha-enhanced, older and to have larger velocity dispersions than the in situ population. Inner spheroids have old, metal-rich and alpha-enhanced stars which formed primarily in situ, more than 40 per cent from material recycled through earlier galactic winds. Few accreted stars are found in the inner spheroid unless a major merger occurred recently. Such stars are older, more metal-poor and more alpha-enhanced than the in situ population. Stellar haloes tend to have low metallicity and high alpha-enhancement. The outer haloes are made primarily of accreted stars. Their mean metallicity and alpha-enhancement reflect the masses of the disrupted satellites where they formed: more massive satellites typically have higher [Fe/H] and lower [alpha/Fe]. Surviving satellites have distinctive chemical patterns which reflect their extended, bursty star formation histories. These produce lower alpha-enhancement at given metallicity than in the main galaxy, in agreement with observed trends in the Milky Way.