2

I am trying to align an entire matrix with a system of equations with an arrow between them. Here is what I have so far,

\begin{align*}
    \left[\begin{array}{ccc|c}
        1 & 0 & 0 & \redtt{b1}  \\
        0 & 1 & 1 & \redtt{b2}  \\
        0 & 0 & 1 & \redtt{b3} 
    \end{array}\right] \longrightarrow && \\
        && x &= \redtt{b1} \\
        && y + z &= \redtt{b2} \\
        && z &= \redtt{b3}
\end{align*}

and it is producing the image below. I would like it to be all inline with itself. Any help would be greatly appreciated. \redtt is just a shortcut I made. It is equivalent to \newcommand{\redtt}[1]{\textcolor{red}{\texttt{#1}}} enter image description here

  • Will there be more than one "block" in vertical alignment? If not, it would be better to use \[...\] or equation* (or forget the * if you would like this numbered. – barbara beeton May 29 at 20:03
5

Please consider posting complete examples such that others do not have to reverse engineer commands like \redtt. As for your question, you can use aligned or an array.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{xcolor}
\newcommand{\redtt}[1]{\textcolor{red}{\mathtt{#1}}}
\begin{document}
\begin{align*}
    \left[\begin{array}{ccc|c}
        1 & 0 & 0 & \redtt{b1}  \\
        0 & 1 & 1 & \redtt{b2}  \\
        0 & 0 & 1 & \redtt{b3} 
    \end{array}\right]\quad \longrightarrow\quad \begin{aligned}
        x &= \redtt{b1} \\
        y + z &= \redtt{b2} \\
        z &= \redtt{b3}\\
    \end{aligned} \\
\end{align*}

\begin{align*}
    \left[\begin{array}{ccc|c}
        1 & 0 & 0 & \redtt{b1}  \\
        0 & 1 & 1 & \redtt{b2}  \\
        0 & 0 & 1 & \redtt{b3} 
    \end{array}\right]\quad \longrightarrow\quad \begin{array}{@{}r<{{}}@{}>{{}}l@{}}
        x &= \redtt{b1} \\
        y + z &= \redtt{b2} \\
        z &= \redtt{b3}
    \end{array} \\
\end{align*}
\end{document}

enter image description here

IMHO aligned looks better but in the array you maintain the same spacing between the rows as in the matrix. (Of course one can adjust aligned to give the same spacing, and so on.)

ADDENDUM: As barbara beeton points out, if you only have a one-line equation it is more appropriate to use \[...\].

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{xcolor}
\newcommand{\redtt}[1]{\textcolor{red}{\mathtt{#1}}}
\begin{document}
\[
    \left[\begin{array}{ccc|c}
        1 & 0 & 0 & \redtt{b1}  \\
        0 & 1 & 1 & \redtt{b2}  \\
        0 & 0 & 1 & \redtt{b3} 
    \end{array}\right]\quad \longrightarrow\quad \begin{aligned}
        x &= \redtt{b1} \\
        y + z &= \redtt{b2} \\
        z &= \redtt{b3}\\
    \end{aligned} 
\]
or
\[
    \left[\begin{array}{ccc|c}
        1 & 0 & 0 & \redtt{b1}  \\
        0 & 1 & 1 & \redtt{b2}  \\
        0 & 0 & 1 & \redtt{b3} 
    \end{array}\right]\quad \longrightarrow\quad \begin{array}{@{}r<{{}}@{}>{{}}l@{}}
        x &= \redtt{b1} \\
        y + z &= \redtt{b2} \\
        z &= \redtt{b3}
    \end{array} \]
\end{document}
| improve this answer | |
  • Thank you! I didn't even think to use aligned. I was trying to nest another align* in there but it didn't like that of course. – Buddy Kings Galletti May 29 at 15:37
  • See my comment on the question regarding use of align for "one-line" displays. – barbara beeton May 29 at 20:05
  • 1
    @barbarabeeton Yes, this is a good point. – user194703 May 29 at 20:15
2

I'd simply use a single column array (and avoid pure colors):

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\newcommand{\redtt}[1]{\textcolor{red!90!blue}{\mathtt{#1}}}

\begin{document}

\[
\left[\begin{array}{@{}ccc|c@{}}
  1 & 0 & 0 & \redtt{b1}  \\
  0 & 1 & 1 & \redtt{b2}  \\
  0 & 0 & 1 & \redtt{b3} 
\end{array}\right]
\;\longrightarrow\;
\begin{array}{@{}r@{}}
      x = \redtt{b1} \\
  y + z = \redtt{b2} \\
      z = \redtt{b3}
\end{array}
\]

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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