Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Please consider the following code

\documentclass[t]{beamer} 
\usepackage{chemfig}
\begin{document}

\begin{frame}
  \frametitle{1st frame}
\definesubmol{x}{-[:+30,.6]-[:-30,.6]}
\definesubmol{y}{-O-(=[2,.6]O)-!x!x!x!x!x!x!x!x}
\chemfig{[2,0.5]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}

\end{frame}

\begin{frame}
  \frametitle{2nd frame}
\chemfig{[2,0.5]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}
\end{frame}

\end{document}

What I would like to achieve is to build submolecules first and then assemble them in successive frames. If I write the submolecules that I need within each frame, soon the whole code become complicate and cluttered.

The only solution I was able to find was to save the submolecules in an external .tex file, to be invoked each time from within frames when needed.

Something like the following

\documentclass[t]{beamer} 
    \usepackage{chemfig}
    \begin{document}

    \begin{frame}
      \frametitle{1st frame}
    \input{submoleculesChemfig.tex}
    \chemfig{[2,0.5]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}
    \end{frame}

    \begin{frame}
      \frametitle{2nd frame}
     \input{submoleculesChemfig.tex}    
     \chemfig{[2,0.5]([0]!y)-[,1.5]([0]!y)-[,1.5]([0]!y)}
    \end{frame}

    \end{document}

Is there a better solution, without using the external file ? Thanks

share|improve this question
1  
Why don't you put the \definesubmol declarations in the preamble? –  cgnieder Mar 27 at 15:28
1  
Do you know about beamer's \only \pause and \onslide commands? –  Seamus Mar 27 at 15:28
    
Thanks cgnieder. I'm after building molecules and I forgot the basics !! For Seamus; yes I know thos commands. It is exactly because I have to use them intensively, that I want my code a little bit cleaner and readable. –  Ottorino Mar 27 at 21:27
    
@Seamus. There are issues with using \onslide and chemfig. This may not be the issue here but see tex.stackexchange.com/questions/98349/… . –  Leeser Mar 28 at 19:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.