Math & Scienceeqnarray*: writing text aligned right from equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
panard
Posts: 1
Joined: Mon Mar 23, 2009 7:52 pm

eqnarray*: writing text aligned right from equations

Post by panard »

Hello,

I would like to write some text flushed at right of equations :

Code: Select all

equation1              first comment in text
equation2 and 3               second comment
I tried something like

Code: Select all

\begin{eqnarray*}
equation1 \hfill\text{first comment in text}\\
equation2 and 3 \hfill\text{second comment}
\end{eqnarray*}
but it doesn't work (no space is insered).

Any help?
I tried to understand how equations numbers are put at right, but the code looks too complex for me...

Thx

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

eqnarray*: writing text aligned right from equations

Post by localghost »

At first please read a paper why not to use the eqnarray environment [1]. The next step is to include the amsmath package and use its align environment. It lets you typeset your equation system with aligned text as desired.

Code: Select all

\begin{align*}
  (a+b)^2&=a^2+2ab+b^2 & \text{Your first comment} \\
  (a-b)^2&=a^2-2ab+b^2 & \text{Second comment} \\
  (a+b)(a-b)^{\hphantom{2}}&=a^2-b^2 & \text{Last comment}
\end{align*}
For more information refer to the manual of the package. Other useful hints are listed in the "Math mode" document.

[1] The PracTeX Journal - Lars Madsen: Avoid eqnarray!


Best regards and welcome to the board
Thorsten¹
Post Reply