# How to extend the table when text longer then the size of a cell is inserted?

 \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
draw=black,
align=center
},
minimum height=1.5em,
text depth=0.5ex,
text height=2ex,
nodes in empty cells,
%%
every even row/.style={
nodes={fill=gray!20}
},
column 1/.style={
nodes={text width=2em,font=\bfseries}
},
row 1/.style={
nodes={
fill=black,
text=white,
font=\bfseries
}
}
}
}

\begin{tikzpicture}

\matrix (first) [table,text width=6em]
{
& Monday   & Tuesday & Wednesday & Thursday & Friday\\
1   & A & B & C & D & E \\
2   & F & G & H & J & K \\
3   & A & B & C & D & E \\
4   & F & G & H & J & K \\
};

\end{tikzpicture}
\end{document}


What if I write to the first cell 'Monday is the first day of the day' instead of just monday?

I want the cell to adapt vertically, increasing the height of the whole row, to accomodate the text

How to do that?

-
 You mean the linebreaks are added or the cell width is increased? – percusse Mar 5 at 10:03 the extra text that would exceed the cell width simply doesnt show up...I want the extra text to automatically go to a new newline. – user494461 Mar 5 at 11:03 For that you need to read the entries in advance and I don't think such automation is possible right away without a hack. But instead remove the minimum height=1.5em, and add row 1 column 2/.style={nodes={text width=6em}}. But note that the options are parsed before the content so the height must be given anyhow. Or at least I don't see right away how to circumvent that. – percusse Mar 5 at 14:40