In tablular
, we use {r|c|l}
to define alignment. Is there anything similar for Tikz matrix
. For example, by using matrix
, the following MWE produces matrix of nodes, which appear to be center aligned for each column.
However, I would like to have the nodes in the first column right-aligned, the middle column center-aligned, while the third column left-aligned. How would I achieve this? (also note, the nodes may have different styles)
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[align=center]
\matrix[matrix of nodes,row sep=0.5cm,column sep=2cm,
nodes={rectangle, draw}]{
col1 & col2 & col3 \\
col111111111 & col2222222222 & col33333\\
col1111 & col22222 & col3333333333 \\
};
\end{tikzpicture}
\end{document}
yields this:
Best Answer
Tikz matrices define the styles
column X
which allows to pass separate options (in this case, anchor) for different columns. For the record, therow X
styles are the equivalent for rows, and you can combine both to refer to a specific cell.More information is available in the
pgfmanual
(section 17.3.3).