更新

更新

更新

感谢@marmot的回答(如下),我能够定位我遇到的问题。以下代码中rectangle split horizontal似乎缺少N和显示的两个锚节点名称:S

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\begin{document}

\begin{tikzpicture}
\node[%
name=s,
shape=rectangle split, 
rectangle split parts=4, 
rectangle split horizontal,
draw,text width=2in,draw=lightgray, line width=20pt,%shape example, 
inner ysep=0.75cm]
{\nodepart{text}text\nodepart{two}two
\nodepart{three}three\nodepart{four}four};
\foreach \anchor/\placement in
{text/left, text east/above, text west/above,
 two/left, two north/above, two south/below,
 three/left, three north/above, three south/below,
 four/left, four north/above, four south/below,
 text split/left, text split east/right, text split west/left,
 two split/left, two split north/above, two split south/below,
 three split/left, three split north/above, three split    south/below,
 north/below, south/above, east/below, west/below,
 north west/above, north east/above, south west/below, south   east/below, center/above, mid/above, base/below}
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
   node[\placement] {\scriptsize\texttt{(s.\anchor)}};
   \coordinate (stextsplitnorth) at (s.two north -| s.text split); %% <nodname>.text split north ?
   \coordinate (stextsplitsouth) at (s.two south -| s.text split); %% <nodname>.text split south ?
   \node[blue] at (stextsplitnorth) {N};
   \node[red] at (stextsplitsouth) {S};
\end{tikzpicture}


\end{document}

在此处输入图片描述

这些锚点很容易找到,如代码所示,但它们似乎没有定义,这让我很沮丧(我只使用了两个分割)。当然,我完全有可能使用了错误的咒语(实际上尝试了几种——最有可能出现在示例代码中)。我很高兴知道正确的咒语。如果您查看下面@marmot 的更正图,您会发现它们也缺失了——这似乎仅适用于第一和第二个分割。这是一个错误吗?

原始问题

Z 手册(第 729 页,版本 3.0.1a)给出了以下代码:

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = XeLaTeX

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\begin{document}

\Huge
\begin{tikzpicture}
\node[%
    name=s,
    shape=rectangle split, 
    rectangle split parts=4, 
    %rectangle split horizontal,
    draw,text width=2in,draw=lightgray, line width=20pt,%shape example, 
    inner ysep=0.75cm]
{\nodepart{text}text\nodepart{two}two
\nodepart{three}three\nodepart{four}four};
  \foreach \anchor/\placement in
    {text/left, text east/above, text west/above,
     two/left, two east/above, two west/above,
     three/left, three east/below, three west/below,
     four/left, four east/below, four west/below,
     text split/left, text split east/above, text split west/above,
     two split/left, two split east/above, two split west/above,
     three split/left, three split east/below, three split west/below,
     north/above, south/below, east/below, west/below,
north west/above, north east/above, south west/below, south east/below, center/above, 70/above, mid/above, base/below}
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}

\end{document}

基本上产生了以下内容(shape example为了简单起见,我扩展了样式):

原来的。

取消注释rectangle split horizontal给出的是:

水平分割

显然,的命名约定rectangle split horizontal改变了分割部分的锚点名称。我查看了pgflibraryshapes.multipart.code.tex但(经过大量实验)没有找到解决方案。的节点锚点名称是什么rectangle split horizontal

答案1

我按照你的做法做了:取消注释rectangle split horizontal,然后基本上leftnorthright用替换south,并调整锚点以使文本可读。

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\begin{document}

\Huge
\begin{tikzpicture}
\node[%
    name=s,
    shape=rectangle split, 
    rectangle split parts=4, 
    rectangle split horizontal,
    draw,text width=2in,draw=lightgray, line width=20pt,%shape example, 
    inner ysep=0.75cm]
{\nodepart{text}text\nodepart{two}two
\nodepart{three}three\nodepart{four}four};
  \foreach \anchor/\placement in
    {text/left, text east/above, text west/above,
     two/left, two north/above, two south/below,
     three/left, three north/above, three south/below,
     four/left, four north/above, four south/below,
     text split/left, text split east/right, text split west/left,
     two split/left, two split north/above, two split south/below,
     three split/left, three split north/above, three split south/below,
     north/below, south/above, east/below, west/below,
north west/above, north east/above, south west/below, south east/below, center/above, mid/above, base/below}
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
       node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容