0

Currently, I am using gather and align environments when I want to write down several math equations in a single environment. When I have several of them, it works fine when there is a text between them, but the spacing is too much when there is no text between them: enter image description here

\usepackage{mathtools}
\newcommand\algn[1]{\begin{align*}#1\end{align*}}
\newcommand\gthr[1]{\begin{gather*}#1\end{gather*}}
\newcommand{\ind}[1]{\mathbbold{#1}}
\DeclareMathOperator{\rank}{rank}
\newcommand{\trp}{\text{t}}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}

\gthr{ \sum_{n\in\ind{n}}m_n = \rank\langle \Lambda \rangle = \rank\langle T\Lambda T^{\trp} \rangle = \rank \langle \Delta^{1/2}A\Delta^{1/2} \rangle = \rank \langle A \rangle
} \algn{ f^{\trp}Af & = f^{\trp}\Delta^{-1/2}(\Delta^{1/2}A\Delta^{1/2})\Delta^{-1/2}f\ &= (T^{\trp}\Delta^{-1/2}f)^{\trp}\Lambda (T^{\trp}\Delta^{-1/2}f)\ & = \sum_{r\in\ind{r}}\lambda_r (T_{,r}^{\trp}\Delta^{-1/2}f)^2\ & = \sum_{n\in\ind{n}}\lambda_n \norm{P_n^{\trp}\Delta^{-1/2}f}^2 }

The top is the gather environment and the below is the align environment, and there is no text between them. I cannot incorporate the top equation in the align environment since I cannot center it properly. I want to reduce the spacing without using vspace every time. I have find a similar problem here Avoiding extra vertical space between groups of equation environments, but it did not work for me; when using align*, it ruined the horizontal positioning of the equations. Any help would be appreciated.

Taxxi
  • 459
  • 4
  • 12
  • 1
    as always, a test file that produced that input would help people answer. A simple solution in this case would be just to use align and place the & before the second =, but the general case is a bit harder – David Carlisle Jun 06 '21 at 10:49
  • 1
    please post the code as a complete document that works, this has multiple undefined copmmands, \ind, \rank, , \trp, ... – David Carlisle Jun 06 '21 at 11:22
  • You gain nothing significant in using \gthr and \algn instead of the full environment form while losing in flexibility. By the way, use \mathrm{t} instead of \text{t} for the transpose. – egreg Jun 06 '21 at 12:15
  • Even after your edit the code as posted above can not be run, please always post complete documents, as in my answer. As egreg says avoid hiding the enviornments behind macros, it makes it harder to read harder to get correct syntax colouring in the editor and makes it impossible to use verbatim and similar constructs. – David Carlisle Jun 06 '21 at 17:45

1 Answers1

3

enter image description here

\documentclass{article}

\usepackage{amsmath}

\def\ind{?????} \def\rank{???} \def\trp{???} \def\norm{???} \begin{document}

aligned in gather \begin{gather} \sum_{n\in\ind{n}}m_n = \rank\langle \Lambda \rangle = \rank\langle T\Lambda T^{\trp} \rangle = \rank \langle \Delta^{1/2}A\Delta^{1/2} \rangle = \rank \langle A \rangle
\ \begin{aligned} f^{\trp}Af & = f^{\trp}\Delta^{-1/2}(\Delta^{1/2}A\Delta^{1/2})\Delta^{-1/2}f\ &= (T^{\trp}\Delta^{-1/2}f)^{\trp}\Lambda (T^{\trp}\Delta^{-1/2}f)\ & = \sum_{r\in\ind{r}}\lambda_r (T_{,r}^{\trp}\Delta^{-1/2}f)^2\ & = \sum_{n\in\ind{n}}\lambda_n \norm{P_n^{\trp}\Delta^{-1/2}f}^2 \end{aligned} \end{gather
}

\end{document}

David Carlisle
  • 757,742
  • Hi David the user have put the MWE. – Sebastiano Jun 06 '21 at 11:41
  • 1
    @Sebastiano no even after the edit the code in the question is incomplete – David Carlisle Jun 06 '21 at 17:43
  • I'm sure this has been asked/answered before, but can't find it. (But this is the correct answer.) – barbara beeton Jun 06 '21 at 18:49
  • @barbarabeeton (naturally:-) but this was the easy case (not numbered) how would you markup the same, numbered? – David Carlisle Jun 06 '21 at 19:07
  • I'm pretty sure that align can be nested in gather. It's an exception. See examples in section A.5 of testmath. – barbara beeton Jun 06 '21 at 19:42
  • @barbarabeeton yes in fact that is what the answer linked from the question does. I decided to use aligned here though as it's conceptually simpler I think. The OP didn't say why couldn't simply use the previous answer. – David Carlisle Jun 06 '21 at 19:59
  • OP said it didn't work -- "it ruined the horizontal positioning of the equations". Maybe the difference between align and align* needs to be tested; there have been changes to amsmath since testmath was last updated. If there is a difference, should probably be pointed out there. – barbara beeton Jun 06 '21 at 20:30