[Tex/LaTex] Positioning TikZ pictures in Beamer frames

beamerpositioningtikz-pgf


I am trying to position my images as follows. the problem is that the moment I delete the black point positioned at the origin, the positioning of my images are messed up.
My second question is that I went the images to blend with the text. Right Now it starts after the text but not inline with text. This is what I want to achieve.
this is my code:

\documentclass{beamer}

\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{comment}
\usepackage{listings}
\usepackage{hyperref,xcolor}
\usepackage{empheq}

\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\usepackage{ragged2e}
\usepackage{textcomp}

\usepackage{amsmath, amssymb}
\usepackage{lmodern}
\usepackage{etoolbox}
\usepackage{framed}
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark,arrows,shapes,backgrounds}
\usepackage{xparse}%  For \NewDocumentCommand
\usepackage{calc}%    For the \widthof macro
\newcommand{\Text}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Sed accumsan nulla ac ipsum elementum interdum. }
\newcommand{\mytikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}


\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
    \tikz[overlay,remember picture]{
    \IfBooleanTF{#1}{%
        \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
    }{%
        \coordinate (RightPoint) at (right.east);
    }%
    \draw[red,#2]
      ($(left)+(-0.2em,0.9em)$) rectangle
      ($(RightPoint)+(0.2em,-0.3em)$);}
}

\NewDocumentCommand{\DrawBoxWide}{s O{}}{%
    \tikz[overlay,remember picture]{
    \IfBooleanTF{#1}{%
        \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
    }{%
        \coordinate (RightPoint) at (right.east);
    }%
    \draw[red,#2]
      ($(left)+(-\labelwidth,0.9em)$) rectangle
      ($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\usepackage{pifont}
\newcommand{\titem}{\ding{226}\quad}



\usepackage{tabu}
%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\title[Lecture 2: Visualization and Programming]{Introduction to programming in MATLAB} % The short 
\date{} % Date, can be changed to a custom date
\subtitle{Lecture 2: Visualization and Programming}
\begin{document}

% For every picture that defines or uses external nodes, you'll have to
% apply the 'remember picture' style. To avoid some typing, we'll apply
% the style to all pictures.
\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]

\begin{frame}{Surface Plots}

\begin{itemize}
\item It is more common to visualize surfaces in 3D
\item Example:
\begin{subequations}
\begin{empheq}[box=\widefbox]{align*}
&f(x,y)=sin(x)cos(y), \\
&x\in [-\pi , \pi];  y \in[-\pi ,\pi ]
\end{empheq}
\end{subequations}

\item \textcolor{orange}{\textbf{surf}} puts vertices at specified points in space x,y,z, and connects all the vertices to make a surface

\item The vertices can be denoted by matrices X\tikz[na] \coordinate (s-mat); ,Y\tikz[na] \coordinate (s-gray);,Z
\item How can we make these matrices
\begin{itemize}
\item loop (DUMB)
\item built-in function: \textcolor{orange}{\textbf{meshgrid}}
\end{itemize}

\end{itemize}

\tikzstyle{background grid}=[draw, black!50,step=.5cm]
\begin{tikzpicture}[show background grid]

\node [inner sep=0pt] (X)  at (7,.50) {X};%\includegraphics[width=2cm]{X}
\node [inner sep=0pt](Y)  at (9,1){Y};%\includegraphics[width=2cm]{Y}

            % show origin
            \fill (0,0) circle (2pt);
            % define destination coordinates
            \path (X) coordinate (mat)
                  (Y) coordinate (gray);
        \end{tikzpicture}

\begin{tikzpicture}[overlay]
        \path[->,black,thick] (s-mat) edge (mat);
        \path[->,black,thick] (s-gray) edge  (gray);
\end{tikzpicture}

\end{frame}

\end{document}

example image
above is my desired result.
below is my actual output (after Sigur suggestion).
enter image description here

Best Answer

I used 2 \parboxes to insert side-by-side.

\documentclass{beamer}

\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{comment}
\usepackage{listings}
\usepackage{hyperref,xcolor}
\usepackage{empheq}

\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\usepackage{ragged2e}
\usepackage{textcomp}

\usepackage{amsmath, amssymb}
\usepackage{lmodern}
\usepackage{etoolbox}
\usepackage{framed}
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark,arrows,shapes,backgrounds}
\usepackage{xparse}%  For \NewDocumentCommand
\usepackage{calc}%    For the \widthof macro
\newcommand{\Text}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Sed accumsan nulla ac ipsum elementum interdum. }
\newcommand{\mytikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}


\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
    \tikz[overlay,remember picture]{
    \IfBooleanTF{#1}{%
        \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
    }{%
        \coordinate (RightPoint) at (right.east);
    }%
    \draw[red,#2]
      ($(left)+(-0.2em,0.9em)$) rectangle
      ($(RightPoint)+(0.2em,-0.3em)$);}
}

\NewDocumentCommand{\DrawBoxWide}{s O{}}{%
    \tikz[overlay,remember picture]{
    \IfBooleanTF{#1}{%
        \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
    }{%
        \coordinate (RightPoint) at (right.east);
    }%
    \draw[red,#2]
      ($(left)+(-\labelwidth,0.9em)$) rectangle
      ($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\usepackage{pifont}
\newcommand{\titem}{\ding{226}\quad}



\usepackage{tabu}
%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\title[Lecture 2: Visualization and Programming]{Introduction to programming in MATLAB} % The short 
\date{} % Date, can be changed to a custom date
\subtitle{Lecture 2: Visualization and Programming}
\begin{document}

% For every picture that defines or uses external nodes, you'll have to
% apply the 'remember picture' style. To avoid some typing, we'll apply
% the style to all pictures.
\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]

\begin{frame}{Surface Plots}

\begin{itemize}
\item It is more common to visualize surfaces in 3D
\item Example:
\begin{subequations}
\begin{empheq}[box=\widefbox]{align*}
&f(x,y)=sin(x)cos(y), \\
&x\in [-\pi , \pi];  y \in[-\pi ,\pi ]
\end{empheq}
\end{subequations}

\item \textcolor{orange}{\textbf{surf}} puts vertices at specified points in space x,y,z, and connects all the vertices to make a surface

\item The vertices can be denoted by matrices X\tikz \coordinate (s-mat); , Y\tikz[na] \coordinate (s-gray);, Z
\item How can we make these matrices\\
\parbox{.48\linewidth}{ %% <-----------------HERE
\begin{itemize}
\item loop (DUMB)
\item built-in function: \textcolor{orange}{\textbf{meshgrid}} 
\end{itemize}
} 
\hfill%
\parbox{.50\linewidth}{\hfill \tikzstyle{background grid}=[draw, black!50,step=.5cm]
\begin{tikzpicture}[show background grid]
\node[inner sep=0pt] (X)  at (0,0) {\includegraphics[width=2cm]{example-image-a}};
\node [inner sep=0pt](Y)  at (3,0){\includegraphics[width=2cm]{example-image-b}};

            % show origin
            %\fill (0,0) circle (2pt);
            % define destination coordinates
            \path (X) coordinate (mat)
                  (Y) coordinate (gray);
        \end{tikzpicture}
}
\end{itemize}



\begin{tikzpicture}[overlay]
        \path[->,black,thick] (s-mat.south) edge (mat.north);
        \path[->,black,thick] (s-gray) edge  (gray);
\end{tikzpicture}

\end{frame}

\end{document}

enter image description here