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.

4
  • 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 Jun 6 at 10:49
  • 1
    please post the code as a complete document that works, this has multiple undefined copmmands, \ind, \rank, , \trp, ... Jun 6 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 6 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. Jun 6 at 17:45
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}
7
  • Hi David the user have put the MWE.
    – Sebastiano
    Jun 6 at 11:41
  • 1
    @Sebastiano no even after the edit the code in the question is incomplete Jun 6 at 17:43
  • I'm sure this has been asked/answered before, but can't find it. (But this is the correct answer.) Jun 6 at 18:49
  • @barbarabeeton (naturally:-) but this was the easy case (not numbered) how would you markup the same, numbered? Jun 6 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. Jun 6 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.