Text FormattingVertical Spacing in 'array' or 'tabular' Environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Vertical Spacing in 'array' or 'tabular' Environment

Post by ghostanime2001 »

Is there a way to control vertical spacing in a array environment other than using \\ ? for example \par\smallskip (or \medskip or \bigskip) ?
Last edited by ghostanime2001 on Fri Nov 11, 2011 8:39 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical Spacing in 'array' or 'tabular' Environment

Post by localghost »

I see several possible approaches.
  • You can control (globally or locally) the height of array or tabular rows by redefining \arraystretch.

    Code: Select all

    \renewcommand{\arraystretch}{1.2}
  • The \\ command accepts an optional argument where you can add valid lengths.

    Code: Select all

    \\[\medskipamount]
  • The booktabs package provides the \addlinespace command which adds a predefined amount of space but also accepts an optional argument.
  • The tabu package provides the \extrarowsep command which stretches also table rows, but is restricted to the »tabu« environment provided by this package.

Thorsten
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Vertical Spacing in 'array' or 'tabular' Environment

Post by ghostanime2001 »

Are you sure
\\[\medskipamount]
this works? because I tried it in a array environment and it doesn't produce any desirable effect if I use \\[\smallskipamount] or \\[\medskipamount] or \\[\bigskipamount]
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical Spacing in 'array' or 'tabular' Environment

Post by localghost »

ghostanime2001 wrote:Are you sure
\\[\medskipamount]
this works? […]
Yes.

Code: Select all

\documentclass[11pt]{article}

\begin{document}
  \begin{tabular}{cc}\hline
    Table Content & Table Content \\[\smallskipamount]\hline
    Table Content & Table Content \\[\medskipamount]\hline
    Table Content & Table Content \\[\bigskipamount]\hline
  \end{tabular}

  \[
    \begin{array}{r@{\,=\,}l}\hline
      (a+b) & a^2+2ab+b^2 \\[\smallskipamount]\hline
      (a-b) & a^2-2ab+b^2 \\[\medskipamount]\hline
      (a+b)(a-b) & a^2-b^2 \\[\bigskipamount]\hline
    \end{array}
  \]
\end{document}
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Vertical Spacing in 'array' or 'tabular' Environment

Post by ghostanime2001 »

For anything else other than the below code it works but not with this code specifically. I don't understand why

Code: Select all

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}
\usepackage[version=3]{mhchem}
\begin{document}
$\begin{array}[t]{@{}l@{}}
\ce{2Cu2O_{(s)} + $\underset{\begin{tabular}[t]{@{}c@{}}25.8 g\end{tabular}}{\ce{Cu2S_{(s)}}}$ -> 6Cu_{(s)} + SO2_{(g)}} \\[\bigskipamount]
\begin{aligned}[t]\ce{n_{\ce{Cu}}}&=\smash{\text{0.162 mol \cancel{\ce{Cu2S}}}\times\dfrac{\text{6 mol \ce{Cu}}}{\text{1 mol \cancel{\ce{Cu2S}}}}} \\ &=\text{0.972 mol}\end{aligned} \\[\bigskipamount]
\begin{aligned}[t]\text{theoretical yield}_{\ce{Cu}}&=\text{0.972 mol}\times\text{63.6 g/mol} \\ &=\text{61.82 g}\end{aligned}
\end{array}$
\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical Spacing in 'array' or 'tabular' Environment

Post by localghost »

ghostanime2001 wrote:For anything else other than the below code it works but not with this code specifically. I don't understand why […]
The array environment is in in-line math mode. Try my first suggestion.
krikru
Posts: 1
Joined: Tue Mar 09, 2021 4:43 am

Vertical Spacing in 'array' or 'tabular' Environment

Post by krikru »

Inserting "[\bigskipamount]" after "\\" in the array environment doesn't have any effect at all for me. Maybe it matters how high your rows are? On each row in my array, I have a 4-by-4 matrix, which makes the rows quite high.
Post Reply