factored out improved overreaching layout calculation; unified math editor caption style