9

I have a MWE where I use eqnarray for multiline equations. I want to right align those two text, but \hfill is not working here.

I think I may use align, but here just want to know how to do it with eqnarray.

\documentclass[]{beamer}

\begin{document}

\begin{frame}
\frametitle{Example}
\begin{eqnarray*}
A &=& B + C \hfill (\Leftarrow \text{from Theorem 1}) \\
  &=& D + E \hfill (\Leftarrow \text{from Corollary 2}) \\
  &=& F 
\end{eqnarray*}
\end{frame}

\end{document}
3

2 Answers 2

9

Try this with align:

enter image description here

\documentclass[]{beamer}

\begin{document}

\begin{frame}
\frametitle{Example}
\begin{align*}
A &= B + C && (\Leftarrow \text{from Theorem 1}) \\
  &= D + E && (\Leftarrow \text{from Corollary 2}) \\
  &= F &&
\end{align*}
\end{frame}

\end{document}

Or alternatively exploiting the \tag{<content>} command:

enter image description here

\documentclass[]{beamer}

\begin{document}

\begin{frame}
\frametitle{Example}
\begin{align}
A &= B + C  \tag{$\Leftarrow$ from Theorem 1} \\
  &= D + E  \tag{$\Leftarrow$ from Corollary 2} \\
  &= F \notag
\end{align}
\end{frame}
2
  • 3
    I wouldn't recommend the \tag method.
    – egreg
    Jan 12, 2014 at 21:05
  • @egreg The OP did not specify any specific technique so I opted with what I quickly had in my mind. Please do edit my question and explain why the \tag is not advisable or post a comment here so that I can amend my answer.
    – azetina
    Jan 12, 2014 at 22:17
5

Here's a solution that uses the IEEEeqnarray environment of the IEEEtrantools package. This package uses syntax that's very similar to that of the (severely deprecated!) eqnarray environment while (i) avoiding all of the shortcomings of the eqnarray environment and (ii) providing some nifty enhancements, such as being able to place text (via the "x" column specifier) on the far-right-hand end of a row. ( The full documentation of the IEEEeqnarray environment may be found in Appendix F of the article "How to Use the IEEEtran LATEX Class" by Michael Shell.)

enter image description here

\documentclass{beamer}
\usepackage{IEEEtrantools}
\begin{document}
\begin{frame}[t] % "[t]" just for this example
\frametitle{Example}
\begin{IEEEeqnarray*}{+rCl+x*}
A &=& B + C \hfill &($\Leftarrow$ from Theorem 1) \\
  &=& D + E \hfill &($\Leftarrow$ from Corollary 2) \\
  &=& F 
\end{IEEEeqnarray*}
\end{frame}
\end{document}

For beamer users, a major advantage of using the IEEEeqnarray environment rather than, say, the math environments of the amsmath package is that it's straightforward to create overlays using the \visible<...>{...} way. For instance, the following setup

\begin{IEEEeqnarray*}{+rCl+x*}
             A &=& B + C \hfill &($\Leftarrow$ from Theorem 1) \\
\visible<2->{  &=& D + E \hfill &($\Leftarrow$ from Corollary 2)} \\
\visible<3>{   &=& F }
\end{IEEEeqnarray*}

will show the first line on all three overlays, the second line from the second overlay onwards, and the third line only on the third (and last) overlay.

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