6

I am still a newbie in LaTeX and I am trying to write something like that but I couldn't find how to do so.

enter image description here

Is there an efficient way to write this and if I have multiple steps to show in the reduction how do I align them?

Thanks!

  • 1
    Welcome to TeX.SE. Please do tell us what you've tried so far and where you feel you're getting stuck. – Mico Oct 13 at 17:03
  • Minor nit: I’m more used to seeing columns of numbers align right than left or center. Sebastiano’s answer already matches the output you want, so +1. – Davislor Oct 14 at 21:49
7

I would use something like this:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
  \left(
  \begin{array}{*4{l}|l}
    1 & 1 & 1 & 1 & b_1\\
    0 & 2 & 3 & 3 & b_2-b_1\\
    0 & 2 & 3 & 3 & b_3-b_1\\
    0 & 4 & 4 & 5 & b_4-b_1\\
  \end{array}
  \right)
  \xrightarrow[L_4 \rightarrow L_4-2L_2]{L_3 \rightarrow L_3-L_2}
  \left(
  \begin{array}{*4{l}|l}
    1 & 1 & 1 & 1 & b_1\\
    0 & 2 & 3 & 3 & b_2-b_1\\
    0 & 0 & 0 & 0 & b_3-b_1-b_2\\
    0 & 0 & -2 & -1 & b_4+b_1-2b_2\\
  \end{array}
  \right).
\]
\end{document}

enter image description here

  • Since you're using array, you might consider aligning the first four columns as 4r instead of 4l so that the minus signs don't shove the negative values out of line. – barbara beeton Oct 13 at 17:40
  • Thanks! However, I have another question. I am trying to write this [\left(\begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix},\begin{pmatrix} 0 \\ \frac{1}{4} \\ \frac{1}{2} \\ 0 \end{pmatrix},\begin{pmatrix} 1 \\ \frac{1}{4} \\ -\frac{1}{2} \\ 0 \end{pmatrix},\begin{pmatrix} 0 \\ -\frac{1}{2\sqrt{2}} \\ \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \\ 0\end{pmatrix}\right)] but is there a way to align number with \begin{pmatrix} and the fractions are a little too close of each others (I don't know how to space them) – Moh18 Oct 13 at 18:12
  • @barbarabeeton this is what I would have done for myself, but I wanted to reproduce what Moh18 wanted. – Franck Pastor Oct 13 at 18:41
  • @Moh18 I suggest opening another subject to address this new problem :-) – Franck Pastor Oct 13 at 18:42
  • @FranckPastor tex.stackexchange.com/questions/512111/… – Moh18 Oct 13 at 19:08
6

Another option could be using the nicematrix package. Here there is my approach:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{nicematrix}
\usepackage{mathtools}
\begin{document}
\[\left(\begin{NiceArray}{CCCC|L}
1 & 1 & 1 & 1 & b_1\\
0 & 2 & 3 & 3 & b_2-b_1\\
0 & 2 & 3 & 3 & b_3-b_1\\
0 & 4 & 4 & 5 & b_4-b_1
\end{NiceArray}\right)
\xrightarrow[L_4 \rightarrow L_4-2L_2]{L_3 \rightarrow L_3-L_2}
\left(\begin{NiceArray}{CCCC|L}
1 & 1 & 1 & 1 & b_1\\
0 & 2 & 3 & 3 & b_2-b_1\\
0 & 0 & 0 & 0 & b_3-b_1-b_2\\
0 & 0 & -2 & -1 & b_4+b_1-2b_2\\
\end{NiceArray}\right).\]
\end{document}

ADDENDUM by comment of the user

There are several procedures to have, for example, on the same arrow your reductions: see this link how to force text to write in two or more lines in overset command for example.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{nicematrix}
\usepackage{mathtools}
\begin{document}
\[\left(\begin{NiceArray}{CCCC|L}
1 & 1 & 1 & 1 & b_1\\
0 & 2 & 3 & 3 & b_2-b_1\\
0 & 2 & 3 & 3 & b_3-b_1\\
0 & 4 & 4 & 5 & b_4-b_1
\end{NiceArray}\right)
\xrightarrow{
            \begin{subarray}{l}
                L_4 \rightarrow L_4-2L_2\\
                L_3 \rightarrow L_3-L_2\\
                L_2 \rightarrow \frac{1}{2}
                %%% here you can add other steps
            \end{subarray}
        }
\left(\begin{NiceArray}{CCCC|L}
1 & 1 & 1 & 1 & b_1\\
0 & 2 & 3 & 3 & b_2-b_1\\
0 & 0 & 0 & 0 & b_3-b_1-b_2\\
0 & 0 & -2 & -1 & b_4+b_1-2b_2\\
\end{NiceArray}\right).\]
\end{document}

You, if it is possible, read the guide of nicematrix package you could get a better result (see the image of the guide to pag. 18, for example).

enter image description here

  • 1
    Thank you for you response! – Moh18 Oct 13 at 19:15
  • @Moh18 I'm happy when I help someone. Glad I helped you. – Sebastiano Oct 13 at 19:16
  • If, between the two matrices, I have to show more that two steps. For example, $L_4 \rightarrow L_4-2L_2$ ,$L_3 \rightarrow L_3-L_2$,$L_2 \rightarrow \frac{1}{2}$. How can I write them under or over the $\xrightarrow$? – Moh18 Oct 14 at 3:52
  • @Moh18 Hi, I have done an addendum for your request. My best regards, – Sebastiano Oct 14 at 20:58

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.