Onde está \ arraystretch?

Sep 25 2020

setspace.stymostra que doublespacingmuda baselinestretch, mas onde está a relação entre baselinestretche arraystretch? Preciso do número exato de arraystretchpara redimensionar meus bmatrixs. O alinhamento vertical da matriz em combinação com o espaçamento duplo mostra baselinestretch= 1/arraystretch, mas onde posso encontrar essas informações? Parece que não tem setspace.stynem amsmath.stya informação.

Respostas

2 egreg Sep 25 2020 at 15:06

Quando um \setstretchcomando derivado ou como \doublespacingé emitido, o valor normal de \baselineskipé multiplicado pelo declarado \baselinestretch.

Quando arrayou tabularé iniciado, o valor atual de \baselineskipé multiplicado por \arraystretch. Assim, você deseja que \arraystretchseja definido como recíproco de \baselinestretch.

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{xfp}

\newcommand{\fixstretch}{\edef\arraystretch{\fpeval{1/(\baselinestretch)}}}

\doublespacing

\begin{document}

Some text that should be long enough to be broken across lines
so as to show the interline spacing. But now we show a matrix
\[
\begin{bmatrix}
1 & 0 \\
0 & 1 \\
0 & 0
\end{bmatrix}
\]
The result is really awful. Now we try in a different way.

\fixstretch
Some text that should be long enough to be broken across lines
so as to show the interline spacing. But now we show a matrix
\[
\begin{bmatrix}
1 & 0 \\
0 & 1 \\
0 & 0
\end{bmatrix}
\]
Now the matrix is nice. Of course, the double spaced
text remains as ugly as it can be.

\end{document}

Você pode evitar a necessidade de emitir explicitamente \fixstretchredefinindo \setstretch.

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{xfp}

% fix \setstretch to also act on \arraystretch
\makeatletter
\renewcommand{\setstretch}[1]{%
  \def\baselinestretch{#1}%
  \edef\arraystretch{\fpeval{1/#1}}% <---- added code
  \@currsize
}
\makeatother

\doublespacing

\begin{document}

Some text that should be long enough to be broken across lines
so as to show the interline spacing. But now we show a matrix
\[
\begin{bmatrix}
1 & 0 \\
0 & 1 \\
0 & 0
\end{bmatrix}
\]
Now the matrix is nice. Of course, the double spaced
text remains as ugly as it can be.

\end{document}