Wo ist \ arraystretch?

Sep 25 2020

setspace.styzeigt, dass sich doublespacingändert baselinestretch, aber wo ist die Beziehung zwischen baselinestretchund arraystretch? Ich benötige die genaue Anzahl, arraystretchum die Größe meiner bmatrixs zu ändern . Die vertikale Ausrichtung der Matrix in Kombination mit dem doppelten Abstand zeigt baselinestretch= 1/arraystretch, aber wo finde ich diese Informationen? Es scheint weder setspace.stynoch amsmath.styhat die Informationen.

Antworten

2 egreg Sep 25 2020 at 15:06

Wenn ein \setstretchoder ein abgeleiteter Befehl wie \doublespacingausgegeben wird, wird der Normalwert von \baselineskipmit dem angegebenen multipliziert \baselinestretch.

Wenn arrayoder tabulargestartet werden, wird der aktuelle Wert von \baselineskipmit multipliziert \arraystretch. Sie möchten also, dass dies \arraystretchauf den Kehrwert von eingestellt ist \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}

Sie können die Notwendigkeit einer expliziten Ausgabe vermeiden, \fixstretchindem Sie neu definieren \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}