如何使用 chemfig 和 animate 包创建分子键运动

如何使用 chemfig 和 animate 包创建分子键运动

我想要一种简单的方法来展示分子结构中的移动原子。我受到了这个网站的启发:http://chem.libretexts.org。这是创建该示例的一个示例。其他人稍后可能会添加更多示例。

答案1

%
\documentclass[12pt]{article}
\usepackage[loop,palindrome,autoplay]{animate}
\usepackage{chemfig}

\begin{document}

\begingroup
\setatomsep{3em}
\centering
Symmetric stretching

\newline

\begin{animateinline}[begin={\begin{minipage}[c][3em][c]{8em}}, end={\end{minipage}}]{3}
\noindent\makebox[\textwidth][c]{
\chemfig{C(=[:-180,1.2]O)(=[:0,1.2]O)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(=[:-180,0.95]O)(=[:0,0.95]O)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(=[:-180,0.65]O)(=[:0,0.65]O)}
}
\end{animateinline}

Antisymmetric stretching

\newline

\begin{animateinline}[begin={\begin{minipage}[c][3em][c]{8em}}, end={\end{minipage}}]{3}
\noindent\makebox[7em][c]{
\chemfig{C(=[:-180,1.25]O)(=[:0,0.75]O)}
}
\newframe
\noindent\makebox[8em][c]{
\chemfig{C(=[:-180,1]O)(=[:0,1]O)}
}
\newframe
\noindent\makebox[9em][c]{
\chemfig{C(=[:-180,0.7]O)(=[:0,1.2]O)}
}
\end{animateinline}

Scissoring (bending)

\newline

\begin{animateinline}[begin={\begin{minipage}[c][6em][c]{8em}}, end={\end{minipage}}]{3}
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]H)(-[:30]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-45]H)(-[:45]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-60]H)(-[:60]H)}
}
\end{animateinline}

Rocking

\newline

\begin{animateinline}[begin={\begin{minipage}[c][5em][c]{8em}}, end={\end{minipage}}]{3}
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:30]H)(-[:90]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:0]H)(-[:60]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]H)(-[:30]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-60]H)(-[:0]H)}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-90]H)(-[:-30]H)}
}
\end{animateinline}

Wagging

\newline

\begin{animateinline}[begin={\begin{minipage}[c][7em][c]{8em}}, end={\end{minipage}}]{3}
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<[:-30,1.5]{\mbox{\Huge H}})(<[:30,1.5]{\mbox{\Huge H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<[:-30,1.25]{\mbox{\Large H}})(<[:30,1.25]{\mbox{\Large H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\mbox{\normalsize H}})(-[:30]{\mbox{\normalsize H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<:[:-30]{\mbox{\footnotesize H}})(<:[:30]{\mbox{\footnotesize H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<:[:-30]{\mbox{\tiny H}})(<:[:30]{\mbox{\tiny H}})}
}
\end{animateinline}


Twisting

\newline

\begin{animateinline}[begin={\begin{minipage}[c][6em][c]{8em}}, end={\end{minipage}}]{3}
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<[:-30,1.5]{\mbox{\Huge H}})(<:[:30]{\mbox{\tiny H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<[:-30,1.25]{\mbox{\Large H}})(<:[:30]{\mbox{\footnotesize H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\mbox{\normalsize H}})(-[:30]{\mbox{\normalsize H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<:[:-30]{\mbox{\footnotesize H}})(<[:30,1.25]{\mbox{\Large H}})}
}
\newframe
\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(<:[:-30]{\mbox{\tiny H}})(<[:30,1.5]{\mbox{\Huge H}})}
}
\end{animateinline}

\endgroup
\end{document}

输出示例

输出示例

答案2

好吧,这个答案在某种程度上涉及化学……以及它对生物学的伴随影响。我甚至不需要使用chemfig

任何有十几岁女儿的人都会有同样的感受……

\documentclass[12pt]{article}
\usepackage[loop,palindrome,autoplay]{animate}
\usepackage{stackengine}
\begin{document}
\char80\char77\char83:
\begin{animateinline}[begin={\begin{minipage}[c][6em]{12em}}, end={\end{minipage}}]{3}
\noindent\makebox[\textwidth][c]{
\stackinset{c}{}{c}{-1.0pt}{\scalebox{2.4}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{-1.5pt}{\scalebox{2.0}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{1pt}{\scalebox{.5}{$\circ$}\,\scalebox{.5}{$\circ$}}{%
\stackinset{c}{}{c}{-3pt}{\scalebox{1}[.9]{$\circ$}}{%
  \LARGE\sffamily O}}}}
}
\newframe
\noindent\makebox[\textwidth][c]{
\stackinset{c}{}{c}{-1.0pt}{\scalebox{2.4}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{-1.5pt}{\scalebox{2.0}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{1pt}{\scalebox{.3}{$\circ$}\,\scalebox{.3}{$\circ$}}{%
\stackinset{c}{}{c}{-3pt}{\scalebox{1}[.7]{$\circ$}}{%
  \LARGE\sffamily O}}}}
}
\newframe
\noindent\makebox[\textwidth][c]{
\stackinset{c}{}{c}{-1.0pt}{\scalebox{2.4}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{-1.5pt}{\scalebox{2.0}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{1pt}{..}{%
\stackinset{c}{}{c}{-3pt}{\scalebox{1}[.5]{$\circ$}}{%
  \LARGE\sffamily O}}}}
}
\newframe
\noindent\makebox[\textwidth][c]{
\stackinset{c}{}{c}{-1.0pt}{\scalebox{2.4}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{-1.5pt}{\scalebox{2.0}[2.6]{$\cap$}}{%
\stackinset{c}{}{c}{1pt}{..}{%
\stackinset{c}{}{c}{-3pt}{-}{%
  \LARGE\sffamily O}}}}
}
\end{animateinline}
\end{document}

相关内容