我正在为我的关键路径方法讲座创建一个活动节点项目图。我可以为其创建自定义节点,如附图所示。但是,我想自定义/修改现有节点(代码),以生成修改后的节点,如附图中预期结果所示。请帮助我。
最小工作示例如下:
\documentclass[border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{chains}
\usetikzlibrary{positioning}
\tikzset{sectors/.style n args={5}{%
circle,
draw,
minimum width=#4,
append after command={%
\pgfextra{ %
\draw (\tikzlastnode.center) -- (\tikzlastnode.south);
\draw (\tikzlastnode.west) -- (\tikzlastnode.east);
\path (\tikzlastnode.center) -- node[#5] {#1} (\tikzlastnode.north west);
\path (\tikzlastnode.center) -- node[#5] {#2} (\tikzlastnode.north east);
\path (\tikzlastnode.center) -- node[#5] {#3} (\tikzlastnode.south west);
\path (\tikzlastnode.center) -- node[#5] {#4} (\tikzlastnode.south east);}}}}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\begin{document}
\begin{tikzpicture}[node distance=7cm,ultra thick]
\node [circle split,
draw,
minimum width=2cm,
append after command={%
\pgfextra{\draw (\tikzlastnode.north) -- (\tikzlastnode.south) ;
}
}] (a) {};
\node[yshift=0em] at (a.center) {\LARGE \textbf{A}};
\node[xshift=-1.2em,yshift=1.2em] at (a.center) {\LARGE $a$};
\node[xshift= 1.2em,yshift=1.2em] at (a.center) {\LARGE $b$};
\node[xshift=-1.2em,yshift=-1.2em] at (a.center) {\LARGE $c$};
\node[xshift= 1.2em,yshift=-1.2em] at (a.center) {\LARGE $d$};
\end{tikzpicture}
\end{document}
答案1
对您的代码进行一些修改后,以下代码将提供所需的输出。
\documentclass[border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{chains}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=7cm,ultra thick]
\node [circle,
draw,fill=white,
minimum width=2cm,
% append after command={%
% \pgfextra{\draw (\tikzlastnode.north) -- (\tikzlastnode.south) ;
% }
% }
] (a) {};
\draw (a.north) -- (a.south) ;
\draw (a.west) -- (a.east) ;
\node [circle ,
draw,fill=white,
minimum width=0.7cm,
% append after command={%
% \pgfextra{\draw (\tikzlastnode.north) -- (\tikzlastnode.south) ;
% }
% }
] (b) {};
\node[yshift=0em] at (a.center) {\LARGE \textbf{A}};
\node[xshift=-1.2em,yshift=1.2em] at (a.center) {\LARGE $a$};
\node[xshift= 1.2em,yshift=1.2em] at (a.center) {\LARGE $b$};
\node[xshift=-1.2em,yshift=-1.2em] at (a.center) {\LARGE $c$};
\node[xshift= 1.2em,yshift=-1.2em] at (a.center) {\LARGE $d$};
\end{tikzpicture}
\end{document}