I know that I must not use vertical rules but I'm trying to reproduce a SAS output like this:
When I use a simple tabular my code works well (see the first table below), but when I use one or more X column from tabularx some undesired vertical space appears (see the 2nd and the 3rd tables below).
What am I doing wrong?
\documentclass{book}
\usepackage{array}
\usepackage{tabularx}
\renewcommand*{\arraystretch}{1.1}
\usepackage{tcolorbox}
\newcommand{\stilecomandoa}{\color{blue!60!black}\bfseries}
\begin{document}
\begin{center}
\begin{tabular}{|>{\stilecomandoa}r|l|l|r|}
\hline
\multicolumn{4}{|c|}{\stilecomandoa Alphabetic List of Variables and Attributes}\\
\hline
\# & {\stilecomandoa Variable} & {\stilecomandoa Type} & {\stilecomandoa Len} \\
\hline
3 & Age & Num & 8 \\
\hline
4 & Height & Num & 8 \\
\hline
1 & Name & Char & 8 \\
\hline
2 & Sex & Char & 1 \\
\hline
5 & Weight & Num & 8 \\
\hline
\end{tabular}
\end{center}
\begin{center}
\begin{tabularx}{.7\linewidth}{|>{\stilecomandoa\arraybackslash}X|X|X|X|}
\hline
\multicolumn{4}{|c|}{\stilecomandoa Alphabetic List of Variables and Attributes}\\
\hline
\# & {\stilecomandoa Variable} & {\stilecomandoa Type} & {\stilecomandoa Len} \\
\hline
3 & Age & Num & 8 \\
\hline
4 & Height & Num & 8 \\
\hline
1 & Name & Char & 8 \\
\hline
2 & Sex & Char & 1 \\
\hline
5 & Weight & Num & 8 \\
\hline
\end{tabularx}
\end{center}
\begin{center}
\begin{tabularx}{.7\linewidth}{|>{\stilecomandoa\arraybackslash}r|X|X|r|}
\hline
\multicolumn{4}{|c|}{\stilecomandoa Alphabetic List of Variables and Attributes}\\
\hline
\# & {\stilecomandoa Variable} & {\stilecomandoa Type} & {\stilecomandoa Len} \\
\hline
3 & Age & Num & 8 \\
\hline
4 & Height & Num & 8 \\
\hline
1 & Name & Char & 8 \\
\hline
2 & Sex & Char & 1 \\
\hline
5 & Weight & Num & 8 \\
\hline
\end{tabularx}
\end{center}
\end{document}


\leavevmodebefore\color. – David Carlisle Jan 05 '18 at 07:52texdoc grfguidefootnote on page 6 – David Carlisle Jan 05 '18 at 07:54ltopcolumn type – David Carlisle Jan 05 '18 at 07:55