0

The following simple code gives almost what I need. But I need it inside a slide in beamer. So when I remove the two commented lines of frame to make a slide, the output is somehow disturbed. Can someone fix it (and possibly provide some intuition)? Thanks in advance.

\documentclass{beamer}
\mode<presentation>{\usetheme{Madrid}}

\usepackage{tikz}
\usetikzlibrary{backgrounds,fit,matrix}
\begin{document}
%\begin{frame}
    

\begin{tikzpicture}
\tikzstyle{bigbox} = [minimum size=3cm,draw=blue!50, thick, fill=blue!10, rounded corners, rectangle]
\tikzstyle{box} = [minimum size=1.5cm, rounded corners,rectangle, fill=blue!50]


\matrix[row sep=20mm, column sep=15mm, inner sep=7mm, bigbox, matrix of nodes, every node/.style=box] {
1 & 2 \\
};

\node (h1) [yshift=12mm] {Texta};

\node (h2) [bigbox,xshift=6cm] {Textb};

\end{tikzpicture}
%\end{frame}

\end{document}
1

Use

\begin{frame}[fragile]

enter image description here

tikz picture inside beamer frame

\documentclass{beamer}
\mode<presentation>{\usetheme{Madrid}}

\usepackage{tikz}
\usetikzlibrary{backgrounds,fit,matrix}
\begin{document}
\begin{frame}[fragile]
    

\begin{tikzpicture}
\tikzstyle{bigbox} = [minimum size=3cm,draw=blue!50, thick, fill=blue!10, rounded corners, rectangle]
\tikzstyle{box} = [minimum size=1.5cm, rounded corners,rectangle, fill=blue!50]


\matrix[row sep=20mm, column sep=15mm, inner sep=7mm, bigbox, matrix of nodes, every node/.style=box] {
1 & 2 \\
};

\node (h1) [yshift=12mm] {Texta};

\node (h2) [bigbox,xshift=6cm] {Textb};

\end{tikzpicture}
\end{frame}

\end{document}

And if you want to move contents up

use

\begin{frame}[fragile]
    
\vspace{-3cm}%<--------------------------------add appropriate dimension
\begin{tikzpicture}

enter image description here

2
  • Wouldn't it be better to use a top aligned frame \begin{frame}[fragile,t] instead of a vspace command in the second example?
    – leandriis
    Aug 8 '20 at 5:48
  • of course --never knew the t option existed --still learning
    – js bibra
    Aug 8 '20 at 5:59

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.