To differentiate between “former” and “latter”, understand that “former” is used to refer to one of two things previously mentioned.
On the other hand, “latter” is used to refer to the most recently mentioned part of a pair of something that has also been previously mentioned.
Former: before
Latter: after.