Temperature-dependent structure and electrochemical performance of highly nanoporous carbon from potassium biphthalate and magnesium powder via a template carbonization process