3

Update

Thanks to @marmot's answer (below), I was able to localize the problem I had with rectangle split horizontal. There seem to be two missing anchor node names shown byN and S in the following code:

\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}

enter image description here

These anchors are easily located as demonstrated in the code, but it was a considerable source of frustration (I'm using only two splits) that they appear not to be defined. It is, of course, perfectly possible that I have used the incorrect incantation (tried several, actually -- the most likely appear in the sample code). I would be glad to know the correct one. If you look at @marmot's corrected graphic below, you will see that they are missing there as well -- this seems to apply only to the first and second splits. Is this a bug?

Original question

The TikZ manual (page 729, version 3.0.1a) gives the following code:

% !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}

and essentially yields the following (I expanded the shape example style for simplicity):

Original.

Uncommenting rectangle split horizontal gives this:

Horizontal split

Clearly, the naming convention for rectangle split horizontal alters the names of the anchors of the split parts. I looked at pgflibraryshapes.multipart.code.tex but (after considerable experimentation) did not find the solution. What are the node anchor names for rectangle split horizontal?

1 Answer 1

4

I did what you started: uncommented rectangle split horizontal and then basically replaced left with north and right with south, and adjusted the anchors such that the text is readable.

\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}

enter image description here

2
  • Well done. What has bothered me (as I'm using only two split parts for a project) is that there are no points (s.two split south -| s.text split) and (s.two split north -| s.text split) though I can locate them easily enough. Those were the two points I particularly wanted and could not find their anchor names -- if they exist.
    – sgmoye
    Aug 27, 2018 at 16:45
  • @sgmoye I am not sure but I would guess these anchors are not predefined. I think all the split parts are just standard rectangle nodes that inherit their anchors from the rectangle shape. I am however not sure since the code is very "rich" and one may just miss some anchors, yet a quick search turned negative.
    – user121799
    Aug 27, 2018 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .