Tikz: 分割された四角形に対するラベルの配置

Tikz: 分割された四角形に対するラベルの配置

分割された四角形の各部分の中心を基準にしてラベルを正確に配置する方法はありますか? 次の例には 2 つのエラーが示されています。

  • 位置合わせはサブパーツの左側に合わせます
  • 垂直方向の位置合わせが間違っているようです。

以下は最小限の動作例です。

 \documentclass{standalone}
 \usepackage{tikz}
 \usetikzlibrary{positioning,shapes.multipart}

 \begin{document}
 \begin{tikzpicture}[
     date/.style= {
       rectangle split,
       rectangle split horizontal, 
       rectangle split parts=3,
       draw
   }]
   \node[date] (today) {
     \nodepart{one}   {\texttt{2014}}
     \nodepart{two}   {\texttt{01}}
     \nodepart{three} {\texttt{01}}
   };
   \node[below=2mm of today.one] {\texttt{y}};
   \node[below=2mm of today.two] {\texttt{m}};
   \node[below=2mm of today.three] {\texttt{d}};
 \end{tikzpicture}
 \end{document}

上記の文書をレンダリングすると

答え1

水平方向の配置を修正するには、などを基準にして配置しますtoday.one south。垂直方向の配置を修正するには、ノードのアンカーをbase、テキストのベースラインである に設定します。

ここに画像の説明を入力してください

 \documentclass{standalone}
 \usepackage{tikz}
 \usetikzlibrary{positioning,shapes.multipart}

 \begin{document}
 \begin{tikzpicture}[
     date/.style= {
       rectangle split,
       rectangle split horizontal, 
       rectangle split parts=3,
       draw
   }]
   \node[date] (today) {
     \nodepart{one}   {\texttt{2014}}
     \nodepart{two}   {\texttt{01}}
     \nodepart{three} {\texttt{01}}
   };
   \node[below=3mm of today.one south,anchor=base] {\texttt{y}};
   \node[below=3mm of today.two south,anchor=base] {\texttt{m}};
   \node[below=3mm of today.three south,anchor=base] {\texttt{d}};
 \end{tikzpicture}
 \end{document}

関連情報