1
\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.

enter image description here


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

    \chemfig{A-B-C-D}\qquad \chemfig{E-F-G-H}\par
    \chemfig{A^1-B-C-D}\qquad \chemfig{E_1-F-G-H}\par
    \chemfig{\vphantom{C}A^1-B-C-D}\qquad \chemfig{\vphantom{G}E_1-F-G-H}\par
    \chemfig{A^1-B-{\vphantom{A^1}C}-D}\qquad \chemfig{E_1-F-{\vphantom{E_1}G}-H}\par
    \chemfig{A^1-\chemskipalign B-C-D}\qquad \chemfig{E_1-\chemskipalign F-G-H}\par
\end{enumerate}
\end{document}

enter image description here enter image description here

  • 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
2

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.