使用 positioning
库可以以相对位置排布 node,容易排出第二行。之后使用使用第二行的宽度与第三行单个 node 的宽度可以计算出第三行 node 之间的间距,然后用和第二行一样的方法即可。
字体为 霞鹜文楷:https://github.com/lxgw/LxgwWenKai 。
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning,decorations.pathreplacing,shapes.misc,arrows.meta}
\usepackage{ctex}
\setCJKmainfont{LXGW WenKai} % https://github.com/lxgw/LxgwWenKai
\begin{document}
\definecolor{col1}{HTML}{4faabc}
\definecolor{col2}{HTML}{e26a6f}
\definecolor{col3}{HTML}{4eab93}
\definecolor{col4}{HTML}{b85f84}
\makeatletter
\newcommand\tvtext[2]{\pgfmathparse{#1}\vbox to\pgfmathresult\p@{\vss\hsize=1em#2\vss}}
\newcommand\getsepoffixedwidth[5]{%
\begingroup
\pgf@process{\path#1;}\pgf@xa=\pgf@x
\pgf@process{\path#2;}\pgf@xb=\pgf@x
\pgf@process{\path#3;}\pgf@xc=\pgf@x
\pgfmathparse{(\pgf@xb-\pgf@xa-(#4)*2*(\pgf@xc-\pgf@xa))/(#4-1)}%
\edef\x{\endgroup\def\noexpand#5{\pgfmathresult pt}}\x}
\makeatother
\begin{tikzpicture}[
l0style/.style={draw=#1,thick,rectangle,rounded corners=3pt},
l1style/.style={l0style=#1,text width=76pt,align=center},
l2style/.style={l0style=#1,text width=76pt,align=center},
l3style/.style={l0style=#1,text height=76pt,inner xsep=5pt},
llstyle/.style={draw=#1,thick,-Latex},
]
% level 1
\node(l1) [l1style=col1] at (0,0) {电磁学};
% level 2 node 2
\node(l2-2) [below left=7pt and 3pt of l1.south, l2style=col2] {基础:实验定律};
\node(l2-1) [left=6pt of l2-2.west, l2style=col1] {方法:归纳法};
\node(l2-3) [right=6pt of l2-2.east, l2style=col3] {核心:四大定理};
\node(l2-4) [right=6pt of l2-3.east, l2style=col4] {线索:相互作用};
\def\TV#1{\tvtext{76pt}{\linespread{1}\selectfont \noindent#1}}
\node(l3-1) [below right=15pt and 0pt of l2-1.south west, l3style=col1]{\TV{现象到本质}};
\getsepoffixedwidth{(l2-1.west)}{(l2-4.east)}{(l3-1.center)}{13}{\sep}
\node(l3-2) [right=\sep of l3-1, l3style=col1]{\TV{特殊到一般}};
\node(l3-3) [right=\sep of l3-2, l3style=col2]{\TV{库伦定律}};
\node(l3-4) [right=\sep of l3-3, l3style=col2]{\TV{安培定律}};
\node(l3-5) [right=\sep of l3-4, l3style=col2]{\TV{电磁感应定律}};
\node(l3-6) [right=\sep of l3-5, l3style=col3]{\TV{电场高斯定理}};
\node(l3-7) [right=\sep of l3-6, l3style=col3]{\TV{电场环路定理}};
\node(l3-8) [right=\sep of l3-7, l3style=col3]{\TV{磁场高斯定理}};
\node(l3-9) [right=\sep of l3-8, l3style=col3]{\TV{磁场环路定理}};
\node(l3-10) [right=\sep of l3-9, l3style=col4]{\TV{物质与电场}};
\node(l3-11) [right=\sep of l3-10, l3style=col4]{\TV{物质与磁场}};
\node(l3-12) [right=\sep of l3-11, l3style=col4]{\TV{电场与磁场}};
\node(l3-13) [right=\sep of l3-12, l3style=col4]{\TV{磁场与电场}};
\path[decorate,decoration={brace,amplitude=7pt},draw=col1,thick] (l2-1.north) -- (l2-4.north);
\begin{scope}[shorten >=-.4pt]
\foreach \i in {1,2} \path[llstyle=col1](l2-1.south)--(l3-\i.north);
\foreach \i in {3,...,5} \path[llstyle=col2](l2-2.south)--(l3-\i.north);
\foreach \i in {6,...,9} \path[llstyle=col3](l2-3.south)--(l3-\i.north);
\foreach \i in {10,...,13} \path[llstyle=col4](l2-4.south)--(l3-\i.north);
\end{scope}
\end{tikzpicture}
\end{document}
完美还原了ppt图片!
雾老师太牛了,直接百分百还原!已收藏备用
已收藏备用