Math & ScienceMultiple Alignment Points in a System of Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Multiple Alignment Points in a System of Equations

Post by svend_tveskaeg »

Hi all.

Consider the following example:

Code: Select all

\documentclass{article}

\usepackage[danish]{babel}
\usepackage{mathtools}
\usepackage[version=3]{mhchem}

\newcommand{\imp}{\qquad \Longrightarrow \qquad}

\begin{document}

\begin{alignat}{2}
  \left.
  \begin{alignedat}{3}
    K_{\textup{v}} &= [\ce{H+}] \cdot [\ce{OH-}] &&\Rightarrow& [\ce{OH-}] &= \frac{K_{\textup{v}}}{[\ce{H+}]}\\
    [\ce{H+}]      &= [\ce{OH-}] + [\ce{$S$-}]   &&\Rightarrow& [\ce{OH-}] &= [\ce{H+}] - [\ce{$S$-}]
  \end{alignedat}
  \right\}
  &\imp&
  a &= b\\
  &\imp&
  c &= d.
\end{alignat}

\end{document}
I would like to align at both equal signs and at \Rightarrow. In the example above, the spacing between \Rightarrow and [\ce{OH-}] is wrong.

How do I fix this?

Thank you in advance!
Last edited by svend_tveskaeg on Sun Jun 17, 2012 11:02 am, edited 3 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

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
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Multiple Alignment Points in a System of Equations

Post by cgnieder »

You have to keep in mind what a & means in what place:

Code: Select all

\begin{alignedat}{6}
 &(middle of first) &(end of first) &(middle of second) &(end of second) &(middle of third)
\end{alignedat}
So this should do the trick:

Code: Select all

\documentclass{article}

\usepackage[danish]{babel}
\usepackage{mathtools}
\usepackage[version=3]{mhchem}

\newcommand{\imp}{\qquad \Longrightarrow \qquad}

\begin{document}

\begin{alignat}{2}
  \left.
  \begin{alignedat}{3}
    K_{\textup{v}} &= [\ce{H+}] \cdot [\ce{OH-}] &&\Rightarrow [\ce{OH-}] &&= \frac{K_{\textup{v}}}{[\ce{H+}]}\\
    [\ce{H+}]  &= [\ce{OH-}] + [\ce{$S$-}]   &&\Rightarrow [\ce{OH-}] &&= [\ce{H+}] - [\ce{$S$-}]
  \end{alignedat}
  \right\}
  &\imp&
  a &= b\\
  &\imp&
  c &= d.
\end{alignat}
Regards
site moderator & package author
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Multiple Alignment Points in a System of Equations

Post by svend_tveskaeg »

Thank you very much.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply