Structural response to electronic transitions in hexagonal and ortho-manganites