1

I'm trying to figure out how to create a table with the \matrix command.

Almost got it, but not quite:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes,
nodes={draw=black, font={\ttfamily}, align=left, text width=1.5cm},
column sep=0,row sep=0,
column 1/.style={minimum width=2cm},
column 2/.style={minimum width=3cm},
]{
foo & 1 \\
bar & "Wilson"\\
baz & true \\
quux & 8.736e22 \\
};

\end{tikzpicture}
\end{document}

The space between cells is screwed up; how can I fix?

enter image description here

1

Set the text height for the nodes, currently the nodes are adjusting their height to the box within them.

See also https://tex.stackexchange.com/a/191240/113380

  • any way to do that on a row-by-row basis in case some rows are oddball? – Jason S Oct 21 '16 at 2:50
  • This might help: tex.stackexchange.com/questions/191239/… – stephematician Oct 21 '16 at 3:28
  • Wait -- this doesn't work, I tried adding minimum height=2cmto line 8 and it does increase the height of all the cells but there's still that damned gap before quux. – Jason S Oct 21 '16 at 4:52
  • Try setting text height and text depth. See revised answer – stephematician Oct 21 '16 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.