TikZ 矩形形状有一个绘制分割键“/pgf/rectangle split draw splits=boolean”,但在 TikZ 手册中没有类似键的参考:圆形分割、椭圆形滑动、圆形实线等... 是否有类似的键?如果没有,有什么关于如何创建它们的建议吗?那就是我们如何压制分割线? 是否相当于矩形分割绘制分割=false是否适用于其他形状?如果没有,有什么建议可以实现吗?
MWE(圆形分割绘制 split=false 也不起作用,但对于矩形,如手册中所述,它确实起作用)
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{external,automata,trees,
positioning,shadows,matrix,arrows,shapes.geometric,shapes.multipart,trees,
calc, fit,decorations.pathmorphing}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node [circle split, circle split draw splits=false]
{test 1 \nodepart{lower} test 2};
\end{tikzpicture}
\begin{tikzpicture}
\node [rectangle split, rectangle split parts=2, rectangle split draw splits=false]
{test 1 \nodepart{two} test 2};
\end{tikzpicture}
\end{frame}
\end{document}
答案1
circle split
为此,需要进行一些黑客攻击。不幸的是,由于和形状之间的实现存在一些不一致,因此ellipse split
必须对两者使用不同的方法。
如果不希望进行黑客攻击,那么可能值得考虑的是,circle split
没有绘制“分割”的形状只是一个circle
内部垂直堆叠文本的形状(调整间距以匹配节点部分的分离)。
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{shapes.multipart}
\makeatletter
\pgfutil@namelet{pgf@sh@fbg@circle split@original}{pgf@sh@fbg@circle split}%
\newif\ifpgfshapecirclesplitdrawsplits
\pgfshapecirclesplitdrawsplitstrue
\pgfkeys{%
/pgf/circle split draw splits/.is if=pgfshapecirclesplitdrawsplits
}
\def\pgf@sm@shape@name{circle split}
\pgf@sh@beforebgpath{%
\ifpgfshapecirclesplitdrawsplits%
\csname pgf@sh@fbg@circle split@original\endcsname%
\fi
}
\newif\ifpgfshapeellipsesplitdrawsplits
\pgfshapeellipsesplitdrawsplitstrue
\pgfkeys{%
/pgf/ellipse split draw splits/.is if=pgfshapeellipsesplitdrawsplits
}
\def\pgf@sm@shape@name{ellipse split}
\pgf@sh@bgpath{%
\radii%
\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
\pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
\pgfutil@tempdima\pgf@x%
\pgfutil@tempdimb\pgf@y%
\pgfpathellipse{\centerpoint}{\pgfqpoint{\the\pgfutil@tempdima}{0pt}}{\pgfqpoint{0pt}{\the\pgfutil@tempdimb}}%
\ifpgfshapeellipsesplitdrawsplits
\pgfpathmoveto{\centerpoint\advance\pgf@x-\pgfutil@tempdima}%
\pgfpathlineto{\centerpoint\advance\pgf@x\pgfutil@tempdima}%
\fi%
}
\begin{document}
\begin{tikzpicture}
\node [circle split,draw]
at (0,0) {A \nodepart{lower} B};
\node [circle split,draw,circle split draw splits=false]
at (2,0) {C \nodepart{lower} D};
\node [ellipse split,draw]
at (0,2) {ABCD \nodepart{lower} EFGH};
\node [ellipse split,draw,ellipse split draw splits=false]
at (2,2) {IJKL \nodepart{lower} MNOP};
\end{tikzpicture}
\end{document}