A Spectroscopic Framework for Deriving Elemental Abundances of M Dwarfs