Take the 2-minute tour ×
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.

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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

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.