4

How can I create a tikz matrix where the first row is a header row with nodes that are centered and all other rows after that have the text left aligned

   H1      H2      H3
 adfsf   34993   ddddd
 234     220     ,,,,,,
 239494  349     ...

H1 is centered horizontally in it's column. Same for H2 and H3. All the other text is centered left in their columns

1 Answer 1

7

If you assign a value for text width for the column nodes, then you can use the align key (I only used draw to have a visual reference):

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

\begin{document}

\begin{tikzpicture}
\matrix[
matrix of nodes,
every node/.style={draw},
column 1/.style={text width=60pt,align=left},
column 2/.style={text width=80pt,align=left},
column 3/.style={text width=125pt,align=left},
row 1/.style={align=center},
]
{
Header 1 & Header2 & Header 3 \\
text text text & text text text & text text text text text\\
text text & text text text text & text text text text text text\\
};
\end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

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