Few \newcommands defined in my standalone .tex file containing tikz figure is not recognized in the main beamer .tex file. Please point out what extra lines should I write to make it work.

Here is the standalone file:

% H-atom energy diagram: 1-photon excited 1-photon ionization

\usetikzlibrary{arrows, decorations.pathmorphing, patterns}

% New commands
\newcommand{\Om}[1]{\small $\omega_{#1}$}

        virtual/.style={thick,densely dashed},
        trans/.style={thick,<->,shorten >=0pt,shorten <=0pt,>=stealth},
        ionize/.style={thick,->,shorten >=0pt,shorten <=0pt,>=stealth},
        decay/.style={thin,->,decorate,decoration=snake,shorten >=0pt,shorten <=0pt,>=stealth}
        % Draw the energy levels
        \draw[level] (1cm,4em) node[left]{\scriptsize{13.6eV}} -- (6cm,4em) node[right]{\ket{c}};
        \draw[level] (1cm,0em) node[left]{\scriptsize{10.2eV}} -- (6cm,0em) node[right]{\ket{2p}};
        \draw[level] (1cm,-10em) node[left]{\scriptsize{0eV}} -- (6cm,-10em) node[right]{\ket{1s}};

        % Draw the transitions
        \draw[trans] (3cm,-10em) -- (3cm,0em) node[midway,left] {\scriptsize{122nm}};
        \draw[ionize] (3cm,0em) -- (3cm,10em) node[left] {\scriptsize{122nm}};
        \draw[ionize] (5cm,0em) -- (5cm,8em) node[right] {\scriptsize{355nm}};
        \draw[decay] (3cm,0em) -- (5cm,-3em) node[below] {\scriptsize{\ta{sp}=1.6ns}};

Here is the excerpt from the main file:


\title{Main title}


\frame{\frametitle{Table of Contents}\tableofcontents}

\section{This section}
\frame{\frametitle{This section}

%       \includegraphics[width=0.3\textwidth]{figs/H_energy_diagram_1_ph}
        \caption{this caption}
    Text text text text,
        \item Text text text text
        \item Text text text text
        \item Text text text text

The error message excerpt:

! Undefined control sequence. l.23 ...ize{13.6eV}} -- (6cm,4em) node[right]{\ket {c}}; ?

  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jun 11 '14 at 12:03
  • Pardon me if the format of my post was illegible. I have edited it into compilable form. – mohan_das Jun 11 '14 at 12:29
  • No problem at all, we do not punish here ;-) – user31729 Jun 11 '14 at 12:33

\includestandalone command crops all preamble and starts processing standalone file after \begin{document}. So, if you include all \newcommand after \begin{document}, all of them will be available into main file.

You also need to include all packages and libraries used in your standalone file on main file preamble.

  • Thank you, Ignasi. I now understand the matter. It solved my problem. – mohan_das Jun 11 '14 at 12:31

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.