CeMg2H7 crystallizes in the tetragonal P4_12_12 space group. Mg(1) is bonded to one H(1), two equivalent H(2), two equivalent H(3), and two equivalent H(4) atoms to form distorted MgH7 pentagonal bipyramids that share corners with two equivalent Ce(1)H12 cuboctahedra, corners with two equivalent Mg(1)H7 pentagonal bipyramids, edges with four equivalent Ce(1)H12 cuboctahedra, and edges with four equivalent Mg(1)H7 pentagonal bipyramids. Ce(1) is bonded to four equivalent H(1), four equivalent H(2), and four equivalent H(3) atoms to form distorted CeH12 cuboctahedra that share corners with four equivalent Mg(1)H7 pentagonal bipyramids, edges with eight equivalent Mg(1)H7 pentagonal bipyramids, and faces with four equivalent Ce(1)H12 cuboctahedra. There are four inequivalent H sites. In the first H site, H(4) is bonded to four equivalent Mg(1) atoms to form HMg4 tetrahedra that share corners with four equivalent H(2)Ce2Mg2 tetrahedra, corners with four equivalent H(3)Ce2Mg2 tetrahedra, corners with four equivalent H(4)Mg4 tetrahedra, edges with two equivalent H(2)Ce2Mg2 tetrahedra, and edges with two equivalent H(3)Ce2Mg2 tetrahedra. In the second H site, H(1) is bonded in a 3-coordinate geometry to one Mg(1) and two equivalent Ce(1) atoms. In the third H site, H(2) is bonded to two equivalent Mg(1) and two equivalent Ce(1) atoms to form HCe2Mg2 tetrahedra that share corners with two equivalent H(4)Mg4 tetrahedra, corners with four equivalent H(2)Ce2Mg2 tetrahedra, corners with six equivalent H(3)Ce2Mg2 tetrahedra,  an edgeedge with one H(4)Mg4 tetrahedra, edges with two equivalent H(2)Ce2Mg2 tetrahedra, and edges with three equivalent H(3)Ce2Mg2 tetrahedra. In the fourth H site, H(3) is bonded to two equivalent Mg(1) and two equivalent Ce(1) atoms to form distorted HCe2Mg2 tetrahedra that share corners with two equivalent H(4)Mg4 tetrahedra, corners with six equivalent H(2)Ce2Mg2 tetrahedra, corners with eight equivalent H(3)Ce2Mg2 tetrahedra,  an edgeedge with one H(4)Mg4 tetrahedra, and edges with three equivalent H(2)Ce2Mg2 tetrahedra.
CeMg2H7 crystallizes in the tetragonal P4_12_12 space group. Mg(1) is bonded to one H(1), two equivalent H(2), two equivalent H(3), and two equivalent H(4) atoms to form distorted MgH7 pentagonal bipyramids that share corners with two equivalent Ce(1)H12 cuboctahedra, corners with two equivalent Mg(1)H7 pentagonal bipyramids, edges with four equivalent Ce(1)H12 cuboctahedra, and edges with four equivalent Mg(1)H7 pentagonal bipyramids. The Mg(1)-H(1) bond length is 1.92 Å. There is one shorter (1.98 Å) and one longer (2.08 Å) Mg(1)-H(2) bond length. There is one shorter (2.02 Å) and one longer (2.06 Å) Mg(1)-H(3) bond length. There is one shorter (1.96 Å) and one longer (2.02 Å) Mg(1)-H(4) bond length. Ce(1) is bonded to four equivalent H(1), four equivalent H(2), and four equivalent H(3) atoms to form distorted CeH12 cuboctahedra that share corners with four equivalent Mg(1)H7 pentagonal bipyramids, edges with eight equivalent Mg(1)H7 pentagonal bipyramids, and faces with four equivalent Ce(1)H12 cuboctahedra. There are two shorter (2.33 Å) and two longer (2.44 Å) Ce(1)-H(1) bond lengths. There are two shorter (2.33 Å) and two longer (2.42 Å) Ce(1)-H(2) bond lengths. There are two shorter (2.49 Å) and two longer (2.51 Å) Ce(1)-H(3) bond lengths. There are four inequivalent H sites. In the first H site, H(4) is bonded to four equivalent Mg(1) atoms to form HMg4 tetrahedra that share corners with four equivalent H(2)Ce2Mg2 tetrahedra, corners with four equivalent H(3)Ce2Mg2 tetrahedra, corners with four equivalent H(4)Mg4 tetrahedra, edges with two equivalent H(2)Ce2Mg2 tetrahedra, and edges with two equivalent H(3)Ce2Mg2 tetrahedra. In the second H site, H(1) is bonded in a 3-coordinate geometry to one Mg(1) and two equivalent Ce(1) atoms. In the third H site, H(2) is bonded to two equivalent Mg(1) and two equivalent Ce(1) atoms to form HCe2Mg2 tetrahedra that share corners with two equivalent H(4)Mg4 tetrahedra, corners with four equivalent H(2)Ce2Mg2 tetrahedra, corners with six equivalent H(3)Ce2Mg2 tetrahedra,  an edgeedge with one H(4)Mg4 tetrahedra, edges with two equivalent H(2)Ce2Mg2 tetrahedra, and edges with three equivalent H(3)Ce2Mg2 tetrahedra. In the fourth H site, H(3) is bonded to two equivalent Mg(1) and two equivalent Ce(1) atoms to form distorted HCe2Mg2 tetrahedra that share corners with two equivalent H(4)Mg4 tetrahedra, corners with six equivalent H(2)Ce2Mg2 tetrahedra, corners with eight equivalent H(3)Ce2Mg2 tetrahedra,  an edgeedge with one H(4)Mg4 tetrahedra, and edges with three equivalent H(2)Ce2Mg2 tetrahedra.