Math & ScienceNon-aligned Equation in 'align' Environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
maxmax
Posts: 29
Joined: Sat Sep 03, 2011 11:19 am

Non-aligned Equation in 'align' Environment

Post by maxmax »

Hi,

is there any way of excluding a single line in the align environment from being aligned with the others? This question might sound strange, but let me explain...
It should look like:

Code: Select all

a1=b1    c1=d1    e1=f1
a2=b2    c2=d2    e2=f2
a2=a+b+c+d+e+f+g+h=b2
a3=b3    c3=d3    e3=f3
The problem is when i do the following

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\begin{document}
  \begin{align*}
    a1&=b1    &c1&=d1    &e1&=f1\\
    a2&=b2    &c2&=d2    &e2&=f2\\
    a2&=a+b+c+d+e+f+g+h=b2  &&&&\\
    a3&=b3    &c3&=d3    &e3&=f3
  \end{align*}
\end{document}
it looks like

Code: Select all

a1=b1                    c1=d1    e1=f1
a2=b2                    c2=d2    e2=f2
a2=a+b+c+d+e+f+g+h=b2
a3=b3                    c3=d3    e3=f3
If i split the equations into one align- followed by one equation- followed by one align-environment, the equations of the two different align environments are naturally not aligned with each other (unlike they all have the same size).

Any ideas?
Last edited by maxmax on Sun Sep 04, 2011 6:17 pm, edited 1 time in total.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Non-aligned Equation in 'align' Environment

Post by localghost »

Load the mathtools package instead and use its \mathrlap command to get the desired result.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}   % loads »amsmath«

\begin{document}
  \begin{align*}
    a1 &=b1    &c1&=d1    &e1&=f1\\
    a2 &=b2    &c2&=d2    &e2&=f2\\
    a2 &=\mathrlap{a+b+c+d+e+f+g+h=b2} \\
    a3 &=b3    &c3&=d3    &e3&=f3
  \end{align*}
\end{document}
For details refer to the package manual. You can find more useful stuff about math typesetting in the excellent »Math mode« document.


Thorsten
maxmax
Posts: 29
Joined: Sat Sep 03, 2011 11:19 am

Re: Non-aligned Equation in 'align' Environment

Post by maxmax »

This is, again, exactly what i was looking for. :)

Vielen Dank!

Max
Post Reply