# Add extra row height except the first for “array”

I know for tabular, there is \extrarowheight that can add the extra row height to every row. Now I have a special purpose that I must need the array environment. However, \extrarowheight does not work in array. If I don't want to manually put \\[1ex] at each line, is there a way to add the extra row height in array? Moreover, I want the vertical space of first line to be unchanged.

\documentclass[12pt,a4paper]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,array}
\parindent=0pt

\begin{document}
\renewcommand{\arraystretch}{0}
\setlength{\extrarowheight}{15pt} % not work
$\begin{array}{l}\hline cccc\\cccc\\\hline\end{array}$
$\begin{array}{l}\hline ccdd\\cccc\\\hline\end{array}$
$\begin{array}{l}\hline ccdd\\ccgg\\\hline\end{array}$
\end{document}


Output: Explanation: I do want the top line be adjacent to the top glyph of the letter, like c, d, etc. This is why I previously set the \arraystretch to be 0. (Otherwise, the short letters like c will leave the top line if it is the tallest letter appear in that row!)

• you could use \hline\noalign{\vspace{2pt}} – David Carlisle Aug 6 '18 at 8:18
• you can use \extrarowheight with array (which is really the same thing as tabular apart from using math mode in some places) (setting \arraystretch to 0 makes the array spacing verry inconsistent) – David Carlisle Aug 6 '18 at 8:19
• @DavidCarlisle Is it to be\renewcommand{\arraystretch}{0}\setlength{\extrarowheight}{15pt} $\begin{array}{l}\hline cccc\\cccc\\\hline\end{array}$? However, it appears nothing changes for me. I guess the \arraystretch prevented the \extrarowheight from changing. – Eric Aug 6 '18 at 8:23
• you had not provided a test example otherwise I may have posted more code. (I see Skillmon has provided one now, but it should have been in the question) I do not think you want arraystretch or extrarowheight at all, just use vspace as I suggested but with a negative space as Skillmon has shown – David Carlisle Aug 6 '18 at 8:26
• @DavidCarlisle Yes, I have found that I forgot to mention that I'd already adjust the \arraystretch. Sorry about that.. Now I edit. – Eric Aug 6 '18 at 8:38

Without changing \arraystretch:

\documentclass[]{article}

\begin{document}
\begin{array}[]{l} \hline \noalign{\vspace{-1ex}} cccc\\ cccc\\ \hline \end{array}
\end{document}


Though I definitely do not encourage the following, it does what you asked. Still, I don't think this is a good idea and you should not use it.

\documentclass[]{article}

\usepackage{array}

\begin{document}
\begin{array}[]{l} \hline \noalign{\vspace{-1ex}} dcccc\\ cccc\\ \hline \end{array}
\bgroup
\def\arraystretch{0}%
$\begin{array}[]{>{\mystretchedbackslash}l} \hline dcccc\\ cccc\\[1ex] \hline \end{array}$
\egroup
\end{document}


• Yes, it is what I want. But one more thing, can I automatically set the vertical space? (i.e., don't need to type\\[2ex] at every end of row.) – Eric Aug 6 '18 at 8:27
• @Eric I don't quite get what you want. There is no \\[2ex] in my code, only one negative \vspace. Do you intend to use your \def\arraystretch{0} approach and put space there by using \\[2ex] syntax? If so: why? – Skillmon likes topanswers.xyz Aug 6 '18 at 8:37
• @Eric you should use skillmon's original answer, shown first here, and if you want the bottom line to touch add a similar vspace before the final \hline – David Carlisle Aug 6 '18 at 8:44
• @Skillmon I have edited my post to be clearer. Actually I want to use \left\{ \begin{array}cccc\\ddd \end{array}\right., with the brackets { as tall as c, if it is the tallest letter in that line. – Eric Aug 6 '18 at 8:44
• @Eric your question doesn't even mention \{ ???? – David Carlisle Aug 6 '18 at 8:45

Stacks? The default is 3pt between row data, but the default can be changed with \setstackgap{S}{...}.

\documentclass[12pt,a4paper]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,array}
\parindent=0pt
\usepackage[usestackEOL]{stackengine}
\stackMath
\begin{document}
\renewcommand{\arraystretch}{0}
\setlength{\extrarowheight}{15pt} % not work
$\begin{array}{l}\hline \Shortstack[l]{cccc\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Shortstack[l]{ccdd\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Shortstack[l]{ccdd\\ccgg}\\\hline\end{array}$
\end{document}


You also have the choice of short stacks (constant interrow gap) or long stacks (constant interrow baselineskip). Changing your data slightly shows the difference...top row, short; bottom row, long:

\documentclass[12pt,a4paper]{book}
\usepackage[margin=2cm, top=2cm]{geometry}
\usepackage{amsmath,array}
\parindent=0pt
\usepackage[usestackEOL]{stackengine}
\stackMath
\begin{document}
\renewcommand{\arraystretch}{0}
$\begin{array}{l}\hline \Shortstack[l]{ccdg\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Shortstack[l]{ccdd\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Shortstack[l]{ccdd\\ccgg}\\\hline\end{array}$
\bigskip

$\begin{array}{l}\hline \Longstack[l]{ccdg\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Longstack[l]{ccdd\\cccc}\\\hline\end{array}$
$\begin{array}{l}\hline \Longstack[l]{ccdd\\ccgg}\\\hline\end{array}$
\end{document}