5

I'm trying to display the bondings movement/vibration due to heat. I am able to recreate all the movement (together with animate package) except the "wagging" and "twisting" (please refer here for explanation). The thing is that ChemFig seems to not accept the default text manipulation commands: \tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge, \Huge. This is the code:

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

\begin{document}


Twisting:
\begin{animateinline}[begin={\begin{minipage}[c][6em]{12em}}, end={\end{minipage}}]{3}
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\Huge H})(-[:30]{\tiny H})}
{\Huge H}{\tiny H}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\Large H})(-[:30]{\footnotesize H})}
{\Large H}{\footnotesize H}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\normalsize H})(-[:30]{\normalsize H})}
{\normalsize H}{\normalsize H}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\footnotesize H})(-[:30]{\Large H})}
{\footnotesize H}{\Large H}
}
\newframe
\noindent\makebox[\textwidth][c]{
\chemfig{C(<[:165])(<:[:195])(-[:-30]{\tiny H})(-[:30]{\Huge H})}
{\tiny H}{\Huge H}
}
\end{animateinline}
\end{document}
5
  • Hydrogen atoms seem to change size fine (using Acrobat reader)
    – jak123
    Jan 12, 2017 at 13:08
  • Are you meaning the extra HH on the right of the molecule? That is just to show that the ChemFig isn't applying the sizing inside the \chemfig command. Jan 12, 2017 at 13:10
  • I see. I missed that point.
    – jak123
    Jan 12, 2017 at 13:12
  • 1
    I think (?) the chemfig arguments are processed in math mode. Thus, you might need \mbox{\tiny H} instead of \tiny H. Jan 12, 2017 at 13:13
  • Absolutely correct, worked just great! Jan 12, 2017 at 13:15

1 Answer 1

7

I think the chemfig arguments are processed in math mode. Thus, if one wishes to use size changes like \tiny, they need to be in an \mbox.

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

\begin{document}


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

enter image description here

enter image description here

POSTSCRIPT

See clemens' comments below, who indeed confirms that the arguments are processed in math mode. Further, he notes that "atoms are placed in \printatom which is defined as \newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}". Thus a redefinition of this would allow the \mbox requirement of my answer to be alleviated.

8
  • Thanks! I did it without the {} around the command, {\mbox ...} Is this bad practice? Jan 12, 2017 at 13:17
  • 2
    \mbox takes a braced argument, if that is what you are asking. While it may work without it, it would be through luck and not design. I would stick with the braces. Jan 12, 2017 at 13:19
  • I hear ya. I will stick to GOOD practice :) Jan 12, 2017 at 13:20
  • 2
    @JimmyWestberg By the way, that is a cool animation you have there. Jan 12, 2017 at 13:27
  • 3
    It indeed does use mathmode for atoms. The manual tells it. Atoms are placed in \printatom which is defined as \newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}
    – cgnieder
    Jan 12, 2017 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .