Optimize margins for margin type.