1

This minimal example

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{equation}
    \begin{array}{ccc}
        f(x) & = &\displaystyle\int_0^1 f'(x) d x  \\[.2cm]
        e^{i\pi} +1 &= & 0
    \end{array}
\end{equation}

\end{document}

produces the following result enter image description here

I would like the tag to refer to the first equation, keeping the horizontal alignment in each column. Is there a way to do it automatically without setting the space for each cell?

1 Answer 1

0

Use align environment, in conjunction with \notag. It provides better math spacing than array.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{align}
        f(x) &= \displaystyle\int_0^1 f'(x) d x  \\[.2cm]
        e^{i\pi} +1 &= 0 \notag
    \end{align}

\end{document}

enter image description here

If you need to use the array environment, top align it:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{equation}
    \begin{array}[t]{ccc}
        f(x) & = &\displaystyle\int_0^1 f'(x) d x  \\[.2cm]
        e^{i\pi} +1 &= & 0
    \end{array}
\end{equation}

\end{document}

enter image description here

3
  • I usually use the align environment, but I want that horizontal alignment. I used the article class, but actually, the code is for a presentation that requires each term to be centred. Oct 1, 2021 at 12:39
  • @LucaBenatti See my edit. You can top-align the array. Oct 1, 2021 at 12:42
  • Okay, this fits in this case since the equation to be tagged is the first. But if I would have five equations and I have to refer to the second one? Maybe it is off-topic, I'll open a different question for that. Oct 1, 2021 at 12:48

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.