# subscript or superscript causes chemical bond vertical shift

\documentclass{article}
\usepackage{chemfig}
\begin{document}
$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {CH=C}(CH_3)OCH_3$\par
$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {CH_2=C}(CH_3)OCH_3$\par
$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {H_2C=C}(CH_3)OCH_3$\par
$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {C_4H_2=C}(CH_3)OCH_3$\par
\end{document}


As you can see, chemical bond in formula with subscript vertical shift are lower, I know it's 'chemfig' macro's algorithm consequence. But I wonder how to disable this shift? Thanks to answer.

UPDATE: I have got a tex.cls which has lots of \NewDocumentCommand which satisfy customized feature. So I can't change macro. And because of common NewDocumentCommand, I have to ensure atom sep & bond offset & italics

It's a eg:

\NewDocumentCommand{\myChem}{m}{
\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig #1\par }  So far, I've try \vphantom and chemskipalign macro, but not success to vertical shift problem. May be my usage of this macro is wrong. Hope for answer and thanks to 'andselisk' . \documentclass{article} \usepackage{chemfig} \begin{document} \begin{enumerate} \item\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {CH=C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {CH_2=C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {H_2C=C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {C_4H_2=C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig { CH= \chemskipalign C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig { CH_2= \chemskipalign C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {H_2C=\chemskipalign C}(CH_3)OCH_3$\par \item$\rm \setatomsep{2em}\setbondoffset{0pt}\chemfig {C_4H_2=\chemskipalign. C}(CH_3)OCH_3\$\par

\end{enumerate}
\end{document}


• And I can't to change macro to mhchem~ – user10920710 Sep 17 '19 at 12:57
• This is a well-documented behavior, see chemfig's manual, section 4. Vertical Alignment. tl:dr is you want to use \chemskipalign macro. Also, your code looks weird to me in a sense that there is no need to use either math mode, or \rm, or declare the same settings again on each line. – andselisk Sep 17 '19 at 14:26
• Thanks to andselisk, I've update my question description. – user10920710 Sep 18 '19 at 3:20

I believe that chemfig is not the best for this kind of formulas. It's easier with chemformula:

\documentclass{article}
\usepackage{chemformula}

\setchemformula{bond-length=1em}

\begin{document}

\ch{CH=C(CH3)OCH3}\par
\ch{CH2=C(CH3)OCH3}\par
\ch{H2C=C(CH3)OCH3}\par
\ch{C4H2=C(CH3)OCH3}\par

\end{document}