0

I have a tikz matrix of nodes. The first column are "bullets" and the second column is the "text".

I would like each line of "text" to occupy the same height. Unfortunately, variations in the actual text seem to change these heights - i.e., whether the text contains capital letters and/or descenders (like "g", "j", ..)

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

\begin{tikzpicture} [
mat/.style={draw=red, line width=1pt, rectangle, matrix of nodes, inner sep=0pt, outer sep=0pt, text width=5cm, 
%text width=5cm, text height=2ex, text depth=1ex,
nodes={draw=blue, line width=0.2pt, anchor=base}}]

% first matrix - single line
\matrix[mat,
column 1/.style={text width=3cm},
column 2/.style={text width=5cm},
] (single) at (0, 0) {
March 2020&txt\\
May 2019&txt\\
May 2018&txt\\
March 2017&txt\\
};

% second matrix - multi line
\matrix[mat, anchor=north west,
column 1/.style={text width=3cm},
column 2/.style={text width=5cm}] (multi) at (single.south west) {
Bullet A: & Notice the uneven spacing between the rows above. I want it to be even.\\
Bullet B: & The text in this matrix is multi-line. I want it to follow the same alignment, with respect to text height and depth, as the matrix above.\\
};

\end{tikzpicture}
\end{document}

In the MWE above, I show how the spacing is uneven. I have tried fixing this by setting text height and text depth (you can uncomment the line above to see my attempt). While this fixes the issue in the first matrix (where the text is single-line) it completely ruins the second matrix.

Is there a setting that I can apply to both of these cases? That way I don't have to worry about whether the text is single-line or multi-line.

2
  • 1
    This looks like a tabular, is there any reason to use TikZ? BTW, welcome to TeX-SX – Ignasi Jan 10 at 19:49
  • @Ignasi - Thanks for the suggestion. I will try with tabular and report back if this meets my needs. – John Mahoney Jan 10 at 21:08

Your Answer

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

Browse other questions tagged or ask your own question.