# Array stretch only for certain rows

When having inline math in tables, fractions etc. appear "squeezed". I have now added the line

\everymath{\displaystyle}


to my preamble after finding the answer here to another question. This very neatly let's every equation in my document be displayed in large format.

But apparently the table rows do not detect these larger equations. Fractions etc. "bulge" out of the row and the rows therefore overlap. From this answer I got the following code to add to the preamble:

\def\arraystretch{2}


This stretches the table rows to double size. But this happens on all rows. Is there a way to reach only the rows with too wide content, so only those rows will be stretched?

An example:

\begin{center}
\begin{tabular}{l c l}
$k^0$ &$=$& $1$\\
$k^{-1}$ &$=$& $\frac1k$\\
$k^{-2}$ &$=$& $\frac1{k^2}=\frac{1}{k\cdot k}$\\
$k^{-3}$ &$=$& $\frac1{k^3}=\frac{1}{k\cdot k\cdot k}$\\
\end{tabular}
\end{center}


Giving the result:

Adding the \arraystretch command will make the rows higher - but all rows will be higher, also rows that do not have any problematic math content. Therefore everything fills more. I am looking for a way to reach only the rows with too tall content with the \arraystretch command.

• you should not get overlapping rows, if you do supply a small example that shows the problem otherwise impossible to debug. Oct 15 '15 at 9:47
• @DavidCarlisle Thank you for your comment. I have now added a code piece showing the result of overlapping row content. Oct 15 '15 at 10:08
• Off-topic: You could use a special column type to prevent $...$ continously .. or use the array environment ;-)
– user31729
Oct 15 '15 at 10:12
• why make it hard for people to guess? You must have had a complete document to produce that image please post that. If I make a document out of your fragment adding \documentclass{article} \begin{document} and \end{document} the rows are close but do not overlap. Oct 15 '15 at 10:33
• Doing \everymath{\displaystyle} is a bad idea, in general. Oct 15 '15 at 12:20

Only a rough solution: use \1.2ex] (i.e. provide more space after a 'line' break) \documentclass{article} \begin{document} \begin{center} \begin{tabular}{l c l} k^0 &=& 1\\ k^{-1} &=& \frac1k\\[1.2ex] k^{-2} &=& \frac1{k^2}=\frac{1}{k\cdot k}\\[1.2ex] k^{-3} &=& \frac1{k^3}=\frac{1}{k\cdot k\cdot k}\\ \end{tabular} \end{center} \end{document}  Edit Improved version with special column type \documentclass{article} \usepackage{array} \usepackage{mathtools} \newcolumntype{M}{>{}l<{}} \newlength{\extraarrayvspace} \setlength{\extraarrayvspace}{1.4ex} \begin{document} \begin{center} \begin{tabular}{M>{}c<{}M} k^0 &=& 1\tabularnewline k^{-1} &=& \dfrac{1}k\tabularnewline[\extraarrayvspace] k^{-2} &=& \dfrac{1}{k^2}=\dfrac{1}{k\cdot k}\tabularnewline[\extraarrayvspace] k^{-3} &=& \dfrac{1}{k^3}=\dfrac{1}{k\cdot k\cdot k}\tabularnewline \end{tabular} \end{center} \end{document}  And here is a solution with cellspace cellspace defines a S columntype (S stands for stretch, I assume) which must have the actual columntype as parameter, i.e. Sl or Sc etc. and calculates better heights for the cell depending on math etc. content. With the lengths \cellspacetoplimit and \cellspacebottomlimit the space above and below the relevant cells can be changed. \documentclass{article} \usepackage{array} \usepackage{mathtools} \usepackage{cellspace} \newcolumntype{M}{>{}Sl<{}} \addtolength{\cellspacetoplimit}{1.5pt} \addtolength{\cellspacebottomlimit}{1.5pt} \begin{document} \begin{center} \begin{tabular}{M>{}Sc<{}M} k^0 &=& 1\tabularnewline k^{-1} &=& \dfrac{1}k\tabularnewline k^{-2} &=& \dfrac{1}{k^2}=\dfrac{1}{k\cdot k}\tabularnewline k^{-3} &=& \dfrac{1}{k^3}=\dfrac{1}{k\cdot k\cdot k}\tabularnewline \end{tabular} \end{center} \end{document}  • @touhami: Why? Using \tabularnewline alone without [] isn't sufficient – user31729 Oct 15 '15 at 10:19 • Sorry may be i still not understand the question. Oct 15 '15 at 10:21 • Package cellspace could be of help too – user31729 Oct 15 '15 at 10:29 This is a math alignment, and environments for that use display style by default: \documentclass{article} \usepackage{amsmath} \begin{document} align \begin{align*} k^0 &=1\\ k^{-1} &= \frac1k\\ k^{-2} &= \frac1{k^2}=\frac{1}{k\cdot k}\\ k^{-3} &= \frac1{k^3}=\frac{1}{k\cdot k\cdot k} \end{align*} \end{document}  • +1 for the answer, –1 for each typo. Ouch, this adds to a negative value. ;-) Oct 15 '15 at 12:24 • @egreg Be careful or you'll grow up to be barbara, you have edit rights, you could fix the typos:-) Oct 15 '15 at 12:31 You can add 3pt of stackgap (vertical buffer, above and below) to the 3rd row fraction. \documentclass{article} \usepackage{stackengine} \begin{document} \begin{center} \begin{tabular}{l c l} k^0 &=& 1\\ k^{-1} &=& \frac1k\\ k^{-2} &=& \addstackgap[3pt]{\frac1{k^2}=\frac{1}{k\cdot k}}\\ k^{-3} &=& \frac1{k^3}=\frac{1}{k\cdot k\cdot k}\\ \end{tabular} \end{center} \end{document}  You can do that with the cellspace package: it defines minimal vertical padding above and below cells in columns with qualifier prefixed with S. I took the opportunity to simplify your code: 2 columns are enough. Alternatively, why not use the align* environment? \documentclass{article} \usepackage{array} \usepackage{mathtools} \usepackage{cellspace} \setlength\cellspacetoplimit{2pt} \setlength\cellspacebottomlimit{2pt} \begin{document} \[ \everymath{\displaystyle}\begin{tabular}{ >{}l<{}@{} >{{}}Sl<{}} k^0 & =1 \\ k^{-1} & = \frac1k \\ k^{-2} & = \frac1{k^2}=\frac{1}{k\cdot k} \\ k^{-3} & = \frac1{k^3}=\frac{1}{k\cdot k\cdot k} \end{tabular}