# Insert TeX code from another Beamer presentation (which uses PGF) into Lyx while composing new Beamer presentation

I'm struggling to insert the TeX code for an older Beamer presentation into one that I'm currently putting together using Lyx. The problem seems to be that Lyx doesn't recognize the package import:

\usepackage{pgf,pgfarrows,pgfnodes}


What I'm trying to do is insert several slides using a TeX code inset (Ctrl+L), where some drawing has been done using PGF.

Here's an example of one of the slides:

\frame
{
\frametitle{Building things up}
\begin{pgfpicture}{0cm}{0cm}{5cm}{5cm}
\pgfnodebox{Node1}[stroke]{\pgfxy(1.2,5)}{Item 1}{2pt}{2pt}
\pgfnodebox{Node2}[stroke]{\pgfxy(8.2,5)}{Item 2}{2pt}{2pt}
\pgfnodebox{Node3}[stroke]{\pgfxy(3,2)}{a}{2pt}{2pt}
\pgfnodebox{Node4}[stroke]{\pgfxy(4.7,2)}{blue}{2pt}{2pt}
\pgfnodebox{Node5}[stroke]{\pgfxy(6.4,2)}{sky}{2pt}{2pt}
\pgfnodeconncurve{Node3}{Node4}{-20}{260}{1cm}{1cm}
\pgfnodeconncurve{Node3}{Node4}{-25}{270}{1cm}{1.5cm}
\pgfnodeconncurve{Node3}{Node4}{-30}{280}{1cm}{2cm}
\pgfnodeconncurve{Node3}{Node4}{-35}{290}{1cm}{2.5cm}
\pgfnodeconncurve{Node4}{Node5}{-5}{260}{.7cm}{.6cm}
\pgfnodeconncurve{Node4}{Node5}{-8}{270}{.8cm}{.8cm}
\pgfnodeconncurve{Node4}{Node5}{-11}{280}{.9cm}{1cm}
\pgfnodeconncurve{Node4}{Node5}{-13}{290}{1cm}{1.2cm}
\end{pgfpicture}
}

-
How does it fail? Do you get an error message, or does the figure just not show up? – Jake Apr 15 '12 at 7:14
I got it working! Thanks @Jake. I was apparently an idiot for not putting the \usepackage{pgf,pgfarrows,pgfnodes} command in the preamble (Document > Settings > LaTeX Preamble) in the Lyx file. – Julie Apr 15 '12 at 7:31

## 1 Answer

The problem is that you have a #1 in your node that should be a \#1. The following compiles for me. (I'm not using LyX, though).

\documentclass{beamer}

\usepackage{pgf,pgfarrows,pgfnodes}
\begin{document}
\begin{frame}
\frametitle{Building things up}
\begin{pgfpicture}{0cm}{0cm}{5cm}{5cm}
\pgfnodebox{Node1}[stroke]{\pgfxy(1.2,5)}{Item \#1}{2pt}{2pt}
\pgfnodebox{Node2}[stroke]{\pgfxy(8.2,5)}{Item \#2}{2pt}{2pt}
\pgfnodebox{Node3}[stroke]{\pgfxy(3,2)}{a}{2pt}{2pt}
\pgfnodebox{Node4}[stroke]{\pgfxy(4.7,2)}{blue}{2pt}{2pt}
\pgfnodebox{Node5}[stroke]{\pgfxy(6.4,2)}{sky}{2pt}{2pt}
\pgfnodeconncurve{Node3}{Node4}{-20}{260}{1cm}{1cm}
\pgfnodeconncurve{Node3}{Node4}{-25}{270}{1cm}{1.5cm}
\pgfnodeconncurve{Node3}{Node4}{-30}{280}{1cm}{2cm}
\pgfnodeconncurve{Node3}{Node4}{-35}{290}{1cm}{2.5cm}
\pgfnodeconncurve{Node4}{Node5}{-5}{260}{.7cm}{.6cm}
\pgfnodeconncurve{Node4}{Node5}{-8}{270}{.8cm}{.8cm}
\pgfnodeconncurve{Node4}{Node5}{-11}{280}{.9cm}{1cm}
\pgfnodeconncurve{Node4}{Node5}{-13}{290}{1cm}{1.2cm}
\end{pgfpicture}
\end{frame}
\end{document}


-
Thanks for taking the time to answer. Unfortunately, without the # in the code, Lyx is still unable to compile it. – Julie Apr 15 '12 at 7:11