Magnetoelasticity in rare-earth superlattices and films