只是块 2 被块 3 隐藏了。我希望块 2 高 1 厘米,块 3 低 1 厘米。
这是我的代码,我该怎么做:
\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\usepackage{booktabs}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
% Define custom colors based on metropolis theme
\definecolor{blockoutline}{RGB}{79,106,133} % Color for block outline
\definecolor{blockbg}{RGB}{245,245,245} % Color for block background
\begin{frame}[fragile]
\frametitle{Introduction}
\begin{figure}
\centering
\begin{tikzpicture}[
block/.style={
draw=blockoutline, % Use custom block outline color
fill=blockbg, % Use custom block background color
line width=1.1pt,
minimum width=2cm,
minimum height=1.5cm,
rounded corners=8pt
},
arrow/.style={
->,
>=latex,
thick,
shorten >=2pt,
blockoutline % Use custom block outline color for arrows
}
]
% Define the blocks
\node [block] (block1) {Block 1};
\node [block, right=1cm of block1] (block2) {Block 2};
\node [block, right=1cm of block1] (block3) {Block 3};
\node [block, right=1cm of block3] (block4) {Block 4};
% Connect the blocks
\draw [arrow] (block1) -- (block2);
\draw [arrow] (block1) -- (block3);
\draw [arrow] (block2) -- (block4);
\draw [arrow] (block3) -- (block4);
% Figure title
\node[below, font=\Large\bfseries] at (block1.south) {Block Diagram};
\end{tikzpicture}
\end{figure}
\end{frame}
答案1
有点奇怪,但我明白了。
代码:
\begin{frame}[fragile]
\frametitle{Introduction}
\begin{figure}
\centering
\begin{tikzpicture}[
block/.style={
draw=blockoutline, % Use custom block outline color
fill=blockbg, % Use custom block background color
line width=1.1pt,
minimum width=2cm,
minimum height=1.5cm,
rounded corners=8pt
},
arrow/.style={
->,
>=latex,
thick,
shorten >=2pt,
blockoutline % Use custom block outline color for arrows
}
]
% Define the blocks
\node [block] (block1) {Block 1};
\node [block, above right = 0.3cm and 2cm of block1] (block2) {Block 2};
\node [block, below right = 0.3cm and 2cm of block1] (block3) {Block 3};
\node [block, right=6cm of block1] (block4) {Block 4};
% Connect the blocks
\draw [arrow] (block1) -- ++(2cm,0) |- (block2);
\draw [arrow] (block1) -- ++(2cm,0) |- (block3);
\draw [blockoutline, line width=0.75pt] (block2.east) -- ++(1cm,0) coordinate (b2) |- (block3.east);
\draw [blockoutline, line width=0.75pt] (block3.east) -- ++(1cm,0) coordinate (b3) |- (block2.east);
\draw [arrow] ($(b2)!0.5!(b3)$) -- ++(0.5cm,0) |- (block4.west);
% Figure title
\node[below, font=\Large\bfseries] at (block3.south) {Block Diagram};
\end{tikzpicture}
\end{figure}
\end{frame}