0

I use setspace to change the spacing in texts.

\usepackage{setspace}
\setstretch{1.435}

The spacing in equations can be managed by changing \arraystretch

@egreg 's approach in here

\usepackage{etoolbox}
\pretocmd{\array}{\renewcommand{\arraystretch}{0.69686}}{}{} % 1/1.435=0.69686

or @campa 's approach in here

\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.435}
\everydisplay=\expandafter{\the\everydisplay\setstretch{1.0}}

However, in either way, the row spacing in table is signal spacing and cannot be changed by changing the value in \arraystretch or \setstretch.

I prefer increasing a little the row spacing in tables rather than the signal spacing. How can I do that?

\documentclass{article}
\usepackage{lipsum} % just for this example
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{setspace}
\setstretch{1.435}

\usepackage{etoolbox}
\pretocmd{\array}{\renewcommand{\arraystretch}{1}}{}{} % increase a little for the row spacing in equations

\begin{document}

\lipsum*[1]

\begin{equation}
    X=\begin{cases}
        \frac{1}{2}, & \text{if $a=1$} \\
        \frac{3}{2} & \text{otherwise}
    \end{cases}
\end{equation}

\begin{table}[htbp]
    \centering
    \caption{Changing the row spacing in the table}
    \begin{tabular}{ c c c }
    \toprule
     cell1 & cell2 & cell3 \\
     \midrule
     cell4 & cell5 & cell6 \\  
     cell7 & cell8 & cell9 \\
     \bottomrule
    \end{tabular}
\end{table}

\end{document}

enter image description here

Bernard
  • 271,350
WZhao
  • 263

1 Answers1

1

For the spacing of multineline equations, it is possible to play with the spreadlines environment from mathtools. It doesn't work with the plain cases environment but you can use the variant of this environment introduced by mathtools.

For tables, you can use cellspace, which defines a minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you load siunitx). Last, I recommend loading the caption package, which enables you to set the skip between caption and float.

Here is an exaggerated example code:

\documentclass{article}
\usepackage{lipsum} % just for this example
\usepackage{mathtools, empheq, nccmath}
\usepackage{booktabs, caption}
\captionsetup{skip=20pt}
\usepackage[math]{cellspace}
\renewcommand{\cellspacetoplimit}{10pt}
\renewcommand{\cellspacebottomlimit}{10pt}

\usepackage{etoolbox}
\BeforeBeginEnvironment{equation}{\begin{spreadlines}{20pt}}%{\spreadlines{20pt}}%
\AfterEndEnvironment{equation}{\end{spreadlines}}
\BeforeBeginEnvironment{empheq}{\begin{spreadlines}{20pt}}%{\spreadlines{20pt}}%
\AfterEndEnvironment{empheq}{\end{spreadlines}}

\usepackage{setspace}
\setstretch{1.435}
\pretocmd{\array}{\renewcommand{\arraystretch}{1}}{}{} % increase a little for the row spacing in equations

\begin{document}

\lipsum*[1]
\begin{equation}
    X=\begin{cases*}
        \mfrac{1}{2}, & \text{if $a=1$} \\
        \mfrac{3}{2} & \text{otherwise}
    \end{cases*}
\end{equation}

 \begin{empheq}[left ={ X = \empheqlbrace}]{alignat*=2}
     & \mfrac{1}{2}, &\quad & \text{if $a=1$} \\
      & \mfrac{3}{2} & & \text{otherwise}
\end{empheq}

\begin{table}[htbp]
    \centering
    \caption{Changing the row spacing in the table}
    \begin{tabular}{ Sc c c }
    \toprule
     cell1 & cell2 & cell3 \\
     \midrule
     cell4 & cell5 & cell6 \\
     cell7 & cell8 & cell9 \\
     \bottomrule
    \end{tabular}
\end{table}

\end{document} 

enter image description here

leandriis
  • 62,593
Bernard
  • 271,350