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}
  • Hydrogen atoms seem to change size fine (using Acrobat reader) – jak123 Jan 12 '17 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. – Jimmy Westberg Jan 12 '17 at 13:10
  • I see. I missed that point. – jak123 Jan 12 '17 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. – Steven B. Segletes Jan 12 '17 at 13:13
  • Absolutely correct, worked just great! – Jimmy Westberg Jan 12 '17 at 13:15
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.

  • Thanks! I did it without the {} around the command, {\mbox ...} Is this bad practice? – Jimmy Westberg Jan 12 '17 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. – Steven B. Segletes Jan 12 '17 at 13:19
  • I hear ya. I will stick to GOOD practice :) – Jimmy Westberg Jan 12 '17 at 13:20
  • 2
    @JimmyWestberg By the way, that is a cool animation you have there. – Steven B. Segletes Jan 12 '17 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}}} – clemens Jan 12 '17 at 16:12

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.