我正在尝试将矩形节点分成两半矩形分割命令,但我收到未知命令的编译错误。我正在尝试执行以下操作:
\documentclass{article}
\usepackage{geometry}
\geometry{
a4paper,
total={210mm,297mm},
left=5mm,
right=5mm,
top=20mm,
bottom=20mm,
}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\usegdlibrary{circular}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={rectangle,rectangle split, rectangle split parts=2,rectangle split part fill={red!30,white!20}, draw, minimum size=0.75cm}, node sep=5cm]
\graph [simple necklace layout]
{
1,2,6,4,5,3;
1->[xshift=1pt,yshift=2pt]3 -> 2, 3 ->[xshift=-1pt,yshift=-2pt]1 -> 2;
3 -> 5 -> 6 ->[xshift=-1pt,yshift=-2pt] 4 ->[xshift=1pt,yshift=-2pt]5, 5 ->[xshift=-1pt,yshift=2pt] 4 ->[xshift=1pt,yshift=2pt] 6;
};
\end{tikzpicture}
\end{document}
我做错了什么?提前致谢。
答案1
您需要加载 Ti钾Z 库shapes
以便执行rectangle split
:
% arara: lualatex
\documentclass{article}
\usepackage{geometry}
\geometry{
a4paper,
%total={210mm,297mm}, % <= that looks a bit doubled, doesn't it?
left=5mm,
right=5mm,
top=20mm,
bottom=20mm
}
\usepackage{tikz}
\usetikzlibrary{%
,graphdrawing
,graphs
,shapes % <= added new library here!
}
\usegdlibrary{circular}
\begin{document}
\begin{tikzpicture}[%
,>=stealth
,every node/.style={%
,rectangle
,rectangle split
,rectangle split parts=2
,rectangle split part fill={red!30,white} % <= it is enough to have white here...
,draw
,minimum size=0.75cm
}
,node sep=5cm
]
\graph [simple necklace layout]
{%
1,2,6,4,5,3;
1->[xshift=1pt,yshift=2pt]3 -> 2, 3 ->[xshift=-1pt,yshift=-2pt]1 -> 2;
3 -> 5 -> 6 ->[xshift=-1pt,yshift=-2pt] 4 ->[xshift=1pt,yshift=-2pt]5, 5 ->[xshift=-1pt,yshift=2pt] 4 ->[xshift=1pt,yshift=2pt] 6;
};
\end{tikzpicture}
\end{document}