TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having trouble aligning text inside a TikZ table. It currently just centres the middle letter, despite the align=left.

I also tried using:

row 1/.style={nodes={align=left}}

(as suggested in Creating table using TikZ matrix)

Table text alignment


    table/.style={matrix of nodes,
                  row sep=-\pgflinewidth,
                  column sep=-\pgflinewidth,
                         text width=2ex,
                         minimum width=1.5cm
                  text depth=0.25ex,
                  text height=2ex,
                  nodes in empty cells
    my top text/.style={font=\small\sffamily},
    my bottom text/.style={font=\sffamily\footnotesize}

  \node[texto,left=of mat#1,anchor=east]
  at (mat#1.west)

\newcommand\SlText[2]{\node[my top text,anchor=base] at ($(mat#1.north)+(0,1.0ex)$) {#2};}
\newcommand\SIundertext[2]{\node[my bottom text,anchor=base] at ($(mat#1.south west)-(0,2.0ex)$) {#2};}

\node[title,left=6.3cm of mat#1,anchor=west]
  at (mat#1.north west)

\begin{tikzpicture}[node distance=0pt and 0.5cm]

  \matrix[table] (mat11) {  1,53& |[draw=none,alias=gap A]| & 22 & 22 & 22,24  & |[draw=none,alias=gap B]| & 1 \\ };

  \foreach \x/\y in {1/$0$,
  { \SlText{11-1-\x}{\y} }

  \foreach \x/\y in {1/$0$,
    { \SIundertext{11-1-\x}{\y} }
    \node at (mat11-1-2.center) {$\ldots$};
    \node at (mat11-1-6.center) {$\ldots$};
    \node[my bottom text] at ($(mat11-1-7.south east)-(0,1.5ex)$) { $(\xi+1)\epsilon$ };

  %% create ragged edges for ellipsis in time line
  \coordinate (intrusion for box)     at (1.75ex,   0  );
  \coordinate (vertical border adj)   at (  0  , 0.2pt);
  \coordinate (horizontal border adj) at (0.2pt,   0  );

  \foreach \x in {A,B}{
  \draw ($(gap \x.south west)+(intrusion for box)+(vertical border adj)$)     -- 
        ($(gap \x.south west)+(horizontal border adj)+(vertical border adj)$) --
        ($(gap \x.north west)+(horizontal border adj)-(vertical border adj)$) --
        ($(gap \x.north west)+(intrusion for box)-(vertical border adj)$);                                                                                                                   
  \draw [decorate,decoration={zigzag,segment length=4pt,amplitude=2pt}]                                                                                                                      
        ($(gap \x.north west)+(intrusion for box)-(vertical border adj)$) --
        ($(gap \x.south west)+(intrusion for box)+(vertical border adj)$);

  \draw ($(gap \x.south east)-(intrusion for box)+(vertical border adj)$)     -- 
        ($(gap \x.south east)-(horizontal border adj)+(vertical border adj)$) --
        ($(gap \x.north east)-(horizontal border adj)-(vertical border adj)$) --
        ($(gap \x.north east)-(intrusion for box)-(vertical border adj)$);
  \draw [decorate,decoration={zigzag,segment length=4pt,amplitude=2pt}]                                                                                                                      
        ($(gap \x.north east)-(intrusion for box)-(vertical border adj)$) --
        ($(gap \x.south east)-(intrusion for box)+(vertical border adj)$);

  \node[my top text,anchor=base east]    at ($(mat11-1-1.north west)-(2ex,0)+(0,1.0ex)$) {Bin};
  \node[my bottom text,anchor=base east] at ($(mat11-1-1.south west)-(2ex,0)-(0,2.0ex)$) {Time};
  \node[title,anchor=east]          at ($(mat11-1-1.west)-(1.5cm,0)$) {Vehicle $k$};


Previous question where I was very kindly helped to this point can be found in TikZ table with floating labels + time discontinuity.

share|improve this question
minimum width is only the width of the node (including inner xseps and the width of the text box), text width is the actual with of the text box. The align key changes the alignment of text inside the text box not the alignment of the text box inside the node. – Qrrbrbirlbel Sep 22 '13 at 13:07
You can find other solutions in create-an-array-in-tikz-with-underbrace-in-different-colors – Ignasi Sep 22 '13 at 20:57
up vote 4 down vote accepted

2ex is too short for allowing any alignment. If I use

text width=1.5cm,

in the table style, I get

enter image description here

such that there is room for text to be aligned differently

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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