How to write 2 x 2 rows equation on a single line separated by a text in the middle of the form:

enter image description here

The picture example is the result that I want to reproduce and can't (which I found in a textbook)

An imperfect try to reproduce the output would be:

\begin{flalign*}
a_n &= c_n + c_{-n} && && c_n &= \frac{1}{2} (a_n - ib_n)\\
&& \text{or} && \\
b_n &= i(c_n - c_{-n}) && && c{_n} &= \frac{1}{2} (a_n + ib_n)
\end{flalign*}

with the following rendering:

enter image description here

However:

  • the or separating the two sides takes an entire row (instead of sitting on the half row between the 2 row equations)
  • the 2 row equation of the right is put way to far on the right
  • I added a MWE @CarLaTeX – ecjb Nov 18 at 9:40
up vote 4 down vote accepted

As Mico advised in the comments that the spacing is not good, I edited my answer. Thanks Mico!

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \begin{array}{rcl}
        a_n & = & c_n+c_{-n}\\[1ex]
        b_n & = & i(c_n-c_{-n})
    \end{array} \qquad \text{or} \qquad
    \begin{array}{rcl}
        c_n & = & \frac{1}{2}(a_n-ib_n)\\[1ex]
        c_{-n}&=& \frac{1}{2}(a_n+ib_n)
    \end{array}.
\]
\end{document}

enter image description here

  • 2
    If there is only one line, what is the purpose of using align here? – Artificial Stupidity Nov 18 at 11:06
  • The horizontal spacing around the four = symbols is too loose with this solution. – Mico Nov 18 at 11:51
  • 1
    @ArtificialStupidity Actually I tried \begin{align*} Hello & \text{or} & Hello \end{align*} at first. But it failed. I changed to this one and forget changing \begin\end{align*} to something like \[\]. Thanks for your feedback! – JouleV Nov 18 at 12:53
  • @Mico You know, one can always change the spacing between lines by \\[1ex], for example. Thanks for your feedback! I will edit my answer now. – JouleV Nov 18 at 12:54
  • 1
    My earlier comment was meant to address the horizontal spacing around the = symbols. The vertical distance between the rows is a separate matter. – Mico Nov 18 at 13:06

Here's a version of @DüngVü's answer that applies the correct amount of whitespace around the four = symbols.

enter image description here

\documentclass{article}
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{C}{>{{}}c<{{}}}
\begin{document}
\[
\setlength\arraycolsep{0pt}
    \begin{array}{rCl}
        a_n & = & c_n+c_{-n}    \\[1ex]
        b_n & = & i(c_n-c_{-n})
    \end{array} 
    \qquad \mbox{or} \qquad
    \begin{array}{rCl}
        c_n   & = & \frac{1}{2}(a_n-ib_n) \\[1ex]
        c_{-n}& = & \frac{1}{2}(a_n+ib_n)
    \end{array}
\]
\end{document}
\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
\[
    \begin{aligned}
        a_n &= c_n + c_{-n}\\
        b_n &= i(c_n - c_{-n})
    \end{aligned}
    \qquad
    \text{or}
    \qquad
    \begin{aligned}
        c_n         &= \frac{a_n-ib_n}{2}\\
    c_{-n}  &= \frac{a_n+ib_n}{2}
    \end{aligned}
\]
Is it what you are looking for?
\end{document}

enter image description here

My proposal

\documentclass[preview,border=12pt]{standalone}
\usepackage[a6paper,landscape,margin=2cm]{geometry}
\usepackage{mathtools}
\begin{document}
I prefer the following style because it is clearer what we are grouping, how about you?
\[
    \left\{
        \begin{aligned}
        a_n &= c_n + c_{-n}\\
        b_n &= i(c_n - c_{-n})
    \end{aligned}\right.
    \qquad
    \text{or}
    \qquad
        \left\{
    \begin{aligned}
        c_n &= \tfrac12(a_n-ib_n)\\
    c_{-n}  &= \tfrac12(a_n+ib_n)
    \end{aligned}\right.
\]
\end{document}

enter image description here

I wouldn't use flalign* that spreads out the equations too much.

\documentclass{article}
\usepackage{amsmath,mathtools}

\begin{document}

\begin{flalign*}
a_n &= c_n + c_{-n} & c_n &= \frac{1}{2} (a_n - ib_n)\\
\shortintertext{\centering or}
b_n &= i(c_n - c_{-n}) & c{_n} &= \frac{1}{2} (a_n + ib_n)
\end{flalign*}

\begin{alignat*}{2}
a_n &= c_n + c_{-n} &\hspace{5em} c_n &= \frac{1}{2} (a_n - ib_n)\\
\shortintertext{\centering or}
b_n &= i(c_n - c_{-n}) & c{_n} &= \frac{1}{2} (a_n + ib_n)
\end{alignat*}

\end{document}

enter image description here

On the other hand, it is not really clear what “or” refers to; I'd suggest placing “or” at the left margin. Just remove \centering from the second example to get

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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