![设置图表中矩形的最大宽度](https://linux22.com/image/414122/%E8%AE%BE%E7%BD%AE%E5%9B%BE%E8%A1%A8%E4%B8%AD%E7%9F%A9%E5%BD%A2%E7%9A%84%E6%9C%80%E5%A4%A7%E5%AE%BD%E5%BA%A6.png)
我正在尝试绘制如下图所示的图表:
我的主要问题是我不知道如何设置矩形的最大宽度,也不知道如何复制 \Delta t 周围的“重做”符号。
我的代码是:
\documentclass[t]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{block} = [rectangle, draw, minimum height = 1cm]
\tikzstyle{line} = [draw, -latex']
\begin{document}
\begin{frame}{Model}
\centering
\begin{tikzpicture}
\node [block] (load) {Load macro-particles};
\node [block, below of=load] (step1) {Integration of equations of motion, moving particles};
\node [below of=step1] (evol) {$\Delta t$};
\node [block, right of=evol] (step2) {Weighting};
\node [block, below of=evol] (step3) {Integration of field equations on grid};
\node [block, left of=evol] (step4) {Weighting};
\path[line] (load) -- (step1);
\draw (step1) |- (step2);
\draw (step2) |- (step3);
\draw (step3) |- (step4);
\end{tikzpicture}
\end{frame}
\end{document}
我的图表看起来像这样,我猜它会被适当的宽度所固定:
答案1
这是一种方法。没有,maximum width
但您可以选择text width
以获得有效的最大宽度。我还切换到使用positioning
进行节点定位,arrows.meta
而不是arrows
,去掉了\tikzstyle
命令,并添加了缺失的线和弧。
\documentclass[t]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,positioning,shapes.geometric}
\begin{document}
\begin{frame}{Model}
\centering
\begin{tikzpicture}[block/.style={rectangle, draw, minimum height = 1cm,
text width=4.2cm,align=center},
line/.style={draw, -Latex},node distance=2em]
\node [block] (load) {Load macro-particles};
\node [block, below=1em of load] (step1) {Integration of equations of motion, moving particles};
\node [below=of step1] (evol) {$\Delta t$};
\node [block, right=of evol] (step2) {Weighting};
\node [block, below=of evol] (step3) {Integration of field equations on grid};
\node [block, left=of evol] (step4) {Weighting};
\path[line] (load) -- (step1);
\draw (step1) -| (step2) |- (step3) -| (step4) |- (step1);
\draw[thick,-{Stealth[bend]}]
(evol.center) ++ (45:1.5em) arc[start angle=45,end angle=-225,radius=1.5em];
\end{tikzpicture}
\end{frame}
\end{document}