4

This minimal example

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

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

produces the following result

enter image description here

What if one wants to put the tag next to the second or the third equation, keeping the horizontal alignment at the centre for each column? Is there a way to do it automatically without specifying space for each cell? I need to have exactly this alignment, hence the align environment does not fit in this case.

EDIT: Since I only got comments on the fact I do not use align, I publish another example to explain the reason for the choice.

\begin{equation}
\begin{array}{cccc}
    (2x+1)^p & =&c(p)&(x+1)^{p+1}\\[.2cm]
    \downarrow&& \downarrow&\downarrow\\
   (2x+1)&=&2&(x+1)^2 \\[1ex]
    x^2-1&=&0&
    \end{array}
\end{equation}

enter image description here

4
  • this really should be done with align, array is not suitable for setting equations the horizontal spacing is wrong and here all but one cell are set in inline math mode not displaystyle. It will then handle the number placement as you need as well. Commented Oct 1, 2021 at 13:17
  • I know the horizontal spacing is wrong, but I need to separate many terms with this space. It is a conscious choice. Commented Oct 1, 2021 at 13:21
  • Hope the combination of \begin{equation} and \begin{aligned} will helps you...
    – MadyYuvi
    Commented Oct 1, 2021 at 13:56
  • It has almost the same behaviour of align. Commented Oct 1, 2021 at 14:07

2 Answers 2

5

You can, if you must, push everything into the array (or rather tabular* to force full width)

enter image description here

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{frame}
\[
    \begin{tabular*}{\textwidth}{
@{}
c
@{\extracolsep{\textwidth minus \textwidth}}
>{$\displaystyle}c<$
!{\extracolsep{0pt}}
>{$\displaystyle}c<$
>{$\displaystyle}c<$
@{\extracolsep{\textwidth minus \textwidth}}
r}
&        f(x) & =& \int_0^1 f'(x) d x\\[.2cm]
&        e^{i\pi} +1 &=& 0 &(\refstepcounter{equation}\theequation)\\
&        g(x)&=& 2 f(x)\\
&        2x+12&=&3
        \end{tabular*}
\]

zzz
\[
\begin{tabular*}{\textwidth}{
@{}
c
@{\extracolsep{\textwidth minus \textwidth}}
>{$\displaystyle}c<$
!{\extracolsep{0pt}}
>{$\displaystyle}c<$
>{$\displaystyle}c<$
>{$\displaystyle}c<$
@{\extracolsep{\textwidth minus \textwidth}}
r}
&    (2x+1)^p & =&c(p)&(x+1)^{p+1}&(\refstepcounter{equation}\theequation)\\[.2cm]
&    \downarrow&& \downarrow&\downarrow\\
&   (2x+1)&=&2&(x+1)^2 &(\refstepcounter{equation}\theequation)\\[1ex]
&    x^2-1&=&0&
    \end{tabular*}
\]
\end{frame}
\end{document}
4

You can use align with the help of eqparbox.

The first mandatory argument to \eqmathbox should be a unique key for the boxes you want to set to the same width.

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{eqparbox}

\newcommand{\eqmathbox}[3][c]{\eqmakebox[#2][#1]{$\displaystyle#3$}}

\begin{document}

\begin{frame}

\begin{align}
  \eqmathbox{L1}{f(x)}        &= \eqmathbox{R1}{\int_0^1 f'(x)\,dx} \notag\\
  \eqmathbox{L1}{e^{i\pi} +1} &= \eqmathbox{R1}{0} \\
  \eqmathbox{L1}{g(x)}        &= \eqmathbox{R1}{2 f(x)}\\
  \eqmathbox{L1}{2x+12}       &= \eqmathbox{R1}{3} \notag
\end{align}

\begin{align}
  \eqmathbox{L2}{(2x+1)^p}   &=                     \eqmathbox{R2-1}{c(p)} \;
                                                    \eqmathbox{R2-2}{(x+1)^{p+1}} \notag\\
  \eqmathbox{L2}{\downarrow} &\mathrel{\phantom{=}} \eqmathbox{R2-1}{\downarrow} \;
                                                    \eqmathbox{R2-2}{\downarrow} \notag\\
  \eqmathbox{L2}{(2x+1)}     &=                     \eqmathbox{R2-1}{2}\;
                                                    \eqmathbox{R2-2}{(x+1)^2} \\
  \eqmathbox{L2}{x^2-1}      &= \eqmathbox{R2-1}{0} \notag
\end{align}

\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .