# I cannot put an equation and figure inside same frame on beamer

I have a very basic question. I am trying to use beamer to prepare a presentation and I need to put a figure and 2 line equation one under the other. I am able to put figure by itself but when I add the equation, I cannot see it on the output. I am using overleaf. I share the code I used in that frame below. The figure was an svg and I converted it to proper version as suggested here.

Code:

\begin{frame}[fragile]{ Recurrent Neural Networks(RNNs)}
\begin{figure}
\centering
\def\svgwidth{\columnwidth}
\input{rnn.pdf_tex}
\caption{Recurrent Neural Network unfolded in time}
\end{figure}
\begin{eqnarray}\label{rnn-eq}
h_{t} &=& f(W_{hx}x_{t} + W_{hh}h_{t-1} + b) \\
y_{t} &=& g(W_{yh}h_{t} + c)
\end{eqnarray}
\end{frame}


Current output:

I am trying to achive something like that:

• please make your code fragment compilable for us. we haven't your image .... btw, instead of eqnarray rather use align from the package amsmath. – Zarko May 27 '18 at 9:02
• @Zarko I put the link for the image I use as comment to your answer – zwlayer May 27 '18 at 9:47
• @zwlayer: Regarding your edit: Please note, that there is no space in \includegraphics. – leandriis May 27 '18 at 10:24
• @leandriis it was a very bad mistake :) Thank you for letting me know. I will undo last edit. – zwlayer May 27 '18 at 10:42

like this?

apparently your image is to high that in frame would have space image and equation. since your image is relatively simple i redraw it by use of the packagetikz:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{chains,
positioning,}

\begin{document}
\begin{frame}[fragile]{ Recurrent Neural Networks (RNNs)}
\begin{figure}
\centering
\begin{tikzpicture}[
node distance = 6mm and 8mm,
start chain = A going right,
box/.style = {draw, rounded corners,
minimum size=8mm, outer sep=0pt},
circ/.style = {circle, draw, dashed,
minimum size=10mm, inner sep=1pt, outer sep=0pt},
]
\foreach \i/\j/\k [count=\n] in {h_{t-1}/y_{t-1}/x_{t-1}, h_{t}/y_{t}/x_{t}, h_{t+1}/y_{t+1}/x_{t+1}}
{
\node[circ,on chain=A,join=by -stealth]    {$\i$};
\node[box, above=of A-\n] (y\n)           {$\j$};
\node[box, below=of A-\n] (x\n)           {$\k$};
\draw[-stealth] (A-\n) -- (y\n);
\draw[-stealth] (A-\n) -- (x\n);
}
\node[circ, left =of A-1]  (A-0) {$h_{({\dots})}$};
\node[circ, right=of A-3]  (A-4) {$h_{({\dots})}$};
%
\draw[-stealth,dashed] (A-0) -- (A-1);
\draw[-stealth,dashed] (A-3) -- (A-4);
\end{tikzpicture}
\caption{Recurrent Neural Network unfolded in time}
\end{figure}
\begin{align}\label{rnn-eq}
h_{t} & = f(W_{hx}x_{t} + W_{hh}h_{t-1} + b) \\
y_{t} & = g(W_{yh}h_{t} + c)
\end{align}
\end{frame}
\end{document}


in case, that you have image as pdf files, than the simplest way to include them as follows:

\begin{figure}
\centering
\include graphics[height=4cm]{rnn} % adjust height so, that image and equation will fit in one frame
\caption{Recurrent Neural Network unfolded in time}
\end{figure}

• thank your for your answer! I have an image saved as pdf. Is it possible to show both image and equation without drawing the image like you did ? It is not a problem for this case but I also have some complex images that I cannot draw so easly. – zwlayer May 27 '18 at 9:42
• you can find the resources here: drive.google.com/open?id=1swYyITHxwKALTm70f-STalWgDRSsPkyc – zwlayer May 27 '18 at 9:47
• if you have image as pdf file, why you not include it with \includegraphics[height=<desired height>]{<image name}? see edited answer – Zarko May 27 '18 at 9:56
• I did not know I have such an option. I did exactly what you said. (Please see my edit) but It showed me a text rather than an image. What might be the problem ? – zwlayer May 27 '18 at 10:14
• i haven't any idea :-(. i don't know your image, nor your document set up nor other necessary informations ... sorry, but my crystal ball is permanently-out-of-order :-) – Zarko May 27 '18 at 11:09