Search code examples
latex

problem in separating equations in different lines in latex


I have the following equations in latex format: I want the second line to be in a separate line but now it shows all the lines in the same line. how can I separate them:

\begin{equation}\label{GNN_update_aggr_formula}
\begin{aligned}
    m^{(k-1)} &\leftarrow \text{AGGREGATE}^{(k-1)}(\{h^{(k-1)}, \forall v \in \mathcal{N}(u) \cup \{u\}\}) \\
    h^{(k)}_u &\leftarrow \text{UPDATE}^{(k-1)} (h^{(k-1)}_u, m^{(k-1)}_u)
\end{aligned}
\end{equation}

Solution

  • A minimal working example would have been appreciated. I could reproduce your described output with the following:

    \documentclass{minimal}
    
    \begin{document}
    \begin{equation}\label{GNN_update_aggr_formula}
    \begin{aligned}
        m^{(k-1)} &\leftarrow \text{AGGREGATE}^{(k-1)}(\{h^{(k-1)}, \forall v \in \mathcal{N}(u) \cup \{u\}\}) \\
        h^{(k)}_u &\leftarrow \text{UPDATE}^{(k-1)} (h^{(k-1)}_u, m^{(k-1)}_u)
    \end{aligned}
    \end{equation}
    \end{document}
    

    which is, by not including the amsmath package where the aligned environment is defined. Adding \usepackage{amsmath} or its superset \usepackage{mathtools} in the preamble may fix your problem.