Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have the following two equalities displayed with the = aligned. I use the following code. The = are not aligned, and 2.5pt is typeset before the = in each line! Also, there is an unseemly amount of space between the left brace and the first equality. (The cases environment gives "the right" space between the left brace and the first equality, but it does not align the =.)

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
\left\{
\begin{array}{c@{2.5pt}c}
a^{3} + b^{3} &= -q \\
ab &= \dfrac{-1}{3} \, p
\end{array}
\right.
\end{equation*}

\end{document}
share|improve this question

4 Answers 4

I would use aligned rather than array here, because semantically it's not really a cases situation nor an array:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\left\{
\begin{aligned}
a^{3} + b^{3} &= -q \\
ab &= \dfrac{-1}{3} \, p
\end{aligned}
\right.
\end{equation*}
\end{document}

enter image description here

share|improve this answer

When I tried using cases, it aligned nicely and worked just fine:

\[
  \begin{cases}
    a^3+b^3 &= -q \\
    ab      &= -\dfrac{1}{3}\,p.
  \end{cases}
\]

If that isn't an answer and you really are stuck with using the array, you might try to change the column separator to an equals sign with a bit of space around it, and then put @{} before the first column to fix your problem with too much space:

\[
  \left\{ 
  \begin{array}{@{}c@{\;=\;}c} 
    a^{3} + b^{3} & -q \\
    ab            & \dfrac{-1}{3} \, p
  \end{array}
  \right.
\]

comparison of two pieces of code

share|improve this answer
    
I forgot to specify that I wanted each equality to have the typical 5 mu space about the equals sign. Thanks for telling me about putting "@{}" before the first column to suppress the extra space. I know the array environments puts space - I think the default is 5 pt - between columns. It is odd to me that it puts this space before the first column and after the last column. –  user143462 Jul 24 at 13:18
    
@user143462, I've changed the \,s to \;s, which will (er, should, I think...) give the spacing used around a binary relation like =. –  Trold Jul 24 at 19:24

The column separation specification @{<stuff>} inserts <stuff> between the columns, so the result is as expected in your case. If you want a 2.5pt gap, then you need to insert @{\hspace{2.5pt}}.

However, if your main aim is to align the parts at the = sign, then you can use

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
  \left\{
    \begin{array}{c@{}c@{}c}
      a^3 + b^3 &{}={}& -q \\
             ab &{}={}& \dfrac{-1}{3} \, p
    \end{array}
  \right.
\end{equation*}

\end{document}
share|improve this answer
    
maybe r@{}c@{}l ? –  tohecz Jul 23 at 22:48
    
I set the column space using the command "\setlength{\arraycolsep}{2.5pt}" and, as you suggested, I used "rcl" in the mandatory argument for the align environment. I would like to thank @Werner for his help, too. –  user143462 Jul 24 at 12:25
    
I have one other comment about this display. I like the spacing between the left brace and the beginning of the longer equalities in the cases environment. The space is significantly bigger using the array environment. You can see that in Werner's display. The code that @Trold gives uses the array environment, but the display that LaTeX typesets does not give too much space between the left brace and the first equality. Why are these different? –  user143462 Jul 24 at 12:35
    
A manual tells the syntax to eliminate the space that is inserted between columns in an array environment from the beginning of the first column. "With @{} before the first column and after the last column, the the additional space \arraysepcol is not used." So, here is the code for the array environment that I want. \begin{equation*}\setlength{\arraycolsep}{2.5pt}\left\{\begin{array}{@{}rcl} a^{3} + b^{3} &=& -q \\ ab &=& -\dfrac{1}{3} \, p\end{array}\right.\end{equation*} –  user143462 Jul 24 at 13:02
    
@user143462: My suggested use would be @{}r@{}c@{}l (or just \setlength{\arraycolsep}{0pt} and also &{}={}&, since it provides the correct spacing around the math relation =. In your @{}rcl case the = would be spaced very wide. –  Werner Jul 24 at 14:16

I suggest using the empheq package for a simpler syntax, with option overload. It loads mathtools, which in turn loadsamsmath. I also usenccmath` for its mediumsized fractions, that look better here, in my opinion:

\documentclass{article}

\usepackage[overload]{empheq}
\usepackage{nccmath}

\begin{document}

\begin{align*}[left = \empheqlbrace]
a^{3} + b^{3} &= -q \\
ab &= -\mfrac{1}{3}\, p
\end{align*}

\end{document} 

enter image description here

share|improve this answer
    
I should be more familiar with the array environment. So, I am going to use Werner's code. I like your display, too. What is the "empheq" package? –  user143462 Jul 24 at 1:33
    
It's a component of the mh bundle, along with mathtools (a must) and a few others. It's dedicated to `emph(asise) eq(uations) hence its name — coloured background, adding things on the left as here or on the right, boxing equations. As you can see the syntax is simple: you use the usual amsmath environment, and you have an optional key-valued systeM. You should take a look at the documentation to see what you can do with it. –  Bernard Jul 24 at 1:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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