I'm trying to create a table in TikZ with
- the first column right-aligned, and the texts in each cell on the same line
- the rest of the columns center-aligned, and each has width of 1cm
My attempt is as follows:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix(dict)[matrix of nodes,below=of game,
nodes={align=center,text width=1cm},
row 1/.style={anchor=south},
column 1/.style={text width=2cm,align=right},
]{
meaning & $b_1$ & $b_2$ & $b_3$ & $b_1b_2$ & $b_1b_3$ & $b_2b_3$ & $b_1b_2b_3$\\
common list \\
private list\\
};
\draw(dict-1-1.south west)--(dict-1-8.south east);
\draw(dict-1-1.north east)--(dict-3-1.south east);
\end{tikzpicture}
\end{document}
The output is not as desired, since the texts in cells dict-2-1
and dict-3-1
spread over two lines. Also, texts in column 1 is not right aligned, despite column 1/.style
being specified after node/.style
.
What should I do?
\matrix
doesn’t matter because here you only append to styleevery node
and define stylecolumn 1
. The order of usage matters (in the internals of the\matrix
macro). Either way, you need to docolumn 1/.style={nodes={text width=2cm,align=right}}
. What is the purpose ofrow 1
? – Qrrbrbirlbel Jul 31 '13 at 1:25row 1
aligns the nodes by their bottom border, so that the horizontal line doesn't have a slope. – Herr K. Jul 31 '13 at 3:32