Made latex fail gracefully, now instead of the whole page breaking and requiring a reload, a modal is shown and the user can try to correct any errors.