以下简单代码几乎满足了我的需求。但我需要在 Beamer 的幻灯片中使用它。因此,当我删除两行注释行以frame
制作幻灯片时,输出会受到某种干扰。有人可以修复它(并可能提供一些直觉)吗?提前致谢。
\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
使用
\begin{frame}[fragile]
\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}
如果你想将内容向上移动
使用
\begin{frame}[fragile]
\vspace{-3cm}%<--------------------------------add appropriate dimension
\begin{tikzpicture}