2

Good evening (or morning, as you wish) everyone

I am using tikz and I encounter some little annoyance while using multi-parts nodes in a matrix. It may be trivial but I cannot find out why using multi-parts nodes in a matrix gets me some additionnal row :

\documentclass{standalone}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}


\usepackage{lmodern}
\usetikzlibrary{positioning,shapes.multipart, fit,backgrounds}


\begin{document}
\begin{tikzpicture}[every node/.style = {
        shape=rectangle split, rectangle split parts=2}]

  \node[matrix,draw,align=center]
  {\node{
  \nodepart{one}coucou
  \nodepart{two}double coucou};&\node{recoucou};\\};

\end{tikzpicture}
\end{document}

enter image description here

Thanks for any explanation

  • You defined, that ęvery node is multi part node. Your image show exactly what you define. – Zarko Oct 5 '15 at 19:40
4

The problem here is caused by your matrix-shaped node being, well, another node, so your every node/.style also applies to it. Either define a style for the multipart nodes and apply it to them or redefine the shape for the matrix, or use the nodes option for the matrix:

\documentclass{standalone}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{lmodern}
\usetikzlibrary{positioning,shapes.multipart, fit,backgrounds}

\begin{document}
\begin{tikzpicture}[every node/.style = {
        shape=rectangle split, rectangle split parts=2}]
  \node[matrix,draw,align=center,shape=rectangle,]
  {\node{\nodepart{one}coucou\nodepart{two}double coucou};&\node{recoucou};\\
};
\end{tikzpicture}\qquad
\begin{tikzpicture}[mynode/.style = {
        shape=rectangle split, rectangle split parts=2}]
  \node[matrix,draw,align=center]
  {\node[mynode]{\nodepart{one}coucou\nodepart{two}double coucou};&\node[mynode]{recoucou};\\
};
\end{tikzpicture}\qquad
\begin{tikzpicture}
  \node[matrix,draw,align=center,nodes = {
        shape=rectangle split, rectangle split parts=2}]
  {\node{\nodepart{one}coucou\nodepart{two}double coucou};&\node{recoucou};\\
};
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.