[Tex/LaTex] Array spacing in multiple line environment

arraysspacing

Consider the following MWE

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
  \renewcommand{\arraystretch}{1.2}
  \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix} \\
  \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}
\end{gather*}

\begin{gather*}
  \renewcommand{\arraystretch}{1.2}
  \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix} \\
  \renewcommand{\arraystretch}{1.2}
  \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}
\end{gather*}
\end{document}

The first gather produces two arrays; in the first, the fractions are properly spaced, while in the second, they are crowded together with the default vertical spacing. Why do I need to re-specify \renewcommand{\arraystretch}{1.2} after the newline? Is there a better way to do this? (I realize I could enclose the whole gather inside a {} pair with a \renewcommand{\arraystretch}{1.2} after the opening {).

Best Answer

Each entry between line breaks inside the gather environment are placed inside a group. To that end, the scope of \renewcommand{\arraystretch}{1.2} only lasts until the end \\, after which you have to issue it again.

A very similar problem is showcased when you use, for example

enter image description here

\documentclass{article}
\begin{document}
\begin{tabular}{c}
  \bfseries ABC DEF \\
  GHI KLM
\end{tabular}
\end{document}

The bold switch (\bfseries) doesn't span further than \\, and would have to be re-issued to have an effect.

For the stretch to have a global effect across line breaks, you have to issue it outside the environment.