我想画一个与水分子形成氢键的乙醇分子。
我希望它们之间的连接是一条虚线,红色,线,但所有其他的连接都是正常的,但我不知道该怎么做。
我的代码(到目前为止)是:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\begin{center}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-O^{\delta^{-}}H^{\delta^{+}}--O^{\delta^{-}}(-H^{\delta^{+}})(-[6]H^{\delta^{+}})}
\end{center}
\end{document}
答案1
稍微复杂一点的方法
\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{center}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-\charge{20:4pt=$^{\delta^{-}}$}{O}-[,0.5,,,draw=none]\charge{20:4pt=$^{\delta^{+}}$}{H}-[,1.5,,,draw=none,
postaction={decorate},
decoration={
markings,
mark = at position 0.22 with {\fill[red] circle[radius=1pt];},
mark = at position 0.5 with {\fill[red] circle[radius=1pt];},
mark = at position 1-0.22 with {\fill[red] circle[radius=1pt];}
}
]\charge{20:4pt=$^{\delta^{-}}$}{O}(-[6]\charge{20:4pt=$^{\delta^{-}}$}{H})-\charge{20:4pt=$^{\delta^{+}}$}{H}}
\end{center}
\end{document}
答案2
\documentclass{article}
\usepackage{chemfig}
\makeatletter
\tikzset{
dot diameter/.store in=\dot@diameter,
dot diameter=1pt,
dot spacing/.store in=\dot@spacing,
dot spacing=5.5pt,
dots/.style={
line width=\dot@diameter,
line cap=round,
dash pattern=on 0pt off \dot@spacing
}
}
\makeatother
\begin{document}
\begin{center}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-O^{\delta^{-}}H^{\delta^{+}}-[,2,,,thick, dotted, red]\charge{20:4pt=$^{\delta^{-}}$}{O}(-[6]\charge{20:4pt=$^{\delta^{-}}$}{H})-\charge{20:4pt=$^{\delta^{+}}$}{H}}
\end{center}
\begin{center}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-O^{\delta^{-}}H^{\delta^{+}}-[,2,,,dots, red]\charge{20:4pt=$^{\delta^{-}}$}{O}(-[6]\charge{20:4pt=$^{\delta^{-}}$}{H})-\charge{20:4pt=$^{\delta^{+}}$}{H}}
\end{center}
\end{document}