I am using tikz to generate a table with the following code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\definecolor{light-gray}{gray}{0.95}
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}
\usepackage{tikz} % package for fancy tables
\usetikzlibrary{matrix}
\usepackage{varwidth}
\begin{document}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
text width=10em,
rectangle,
draw=black
},
%minimum height=1.5em,
text centered
text depth=1.5ex,
text height=2.5ex,
nodes in empty cells,
%%
every even row/.style={
nodes={fill=cyan!5}
},
column 1/.style={ % first column
nodes={text width=30em}
},
row 1/.style={ % first row
nodes={
fill=white,
text=black,
align=center
%font=\bfseries
}
}
}
}
\begin{tikzpicture}%[every node/.style={anchor=base,text depth=1.5ex,text height=3ex,text width=1em}]
\matrix (first) [table,text width=6em]
{
Command & Description \\
\code{git init} & Initialize a local Git repository \\
\code{git clone ssh://git@github.com/[usrname]/[repo-name].git} & Create a local copy of a remote repository \\
};
\end{tikzpicture}
\end{document}
However, I got the result as shown below. Everything is fine except that the height of the cell varies with the height of the texts in it and the baselines of the cells are not aligned. I had a really hard time figuring this out and I'm wondering how I could solve the problem. Thank you for your time in advance and I appreciate any suggestions or experience shared.


\documentclass{article}\usepackage{geometry} \usepackage{ragged2e}\usepackage{booktabs,tabularx} \begin{document} \noindent\begin{tabularx}{\linewidth}{@{} >{\hsize=0.75\hsize\RaggedRight}X>{\hsize=0.25\hsize\RaggedRight}X@{}} \toprule Command & Description \\\midrule \verb+git init+ & Initialize a local Git repository \\\addlinespace \verb+git clone ssh://git@github.com/[usrname]/[repo-name].git+ & Create a local copy of a remote repository \\ \bottomrule \end{tabularx}\end{document}. I may give you idea for different approach. – Zarko Jun 28 '19 at 23:02text centeredandalign=center, but both did not work. Could you suggest me how I can align the text to the center vertically? Also, I hope that I can use alternating colors for all the even rows. I've triedevery even line./style={nodes={fill=cyan!5}}, but it still did not work. I'm wondering if there is a way to do this (without specifying each even row separately). Thanks a lot! – Jack Jun 29 '19 at 10:16