0

During preparing a note about elementary row operations, I did the following as similar as I had found through the site:

\documentclass[a4paper,12pt]{book}‎
\usepackage{amsmath,amssymb,amsthm,amsfonts}‎ 
\begin{document}‎‎
‎‎\begin{pmatrix}
‎2‎‎ & 1 \\ 
1 & -5\\‎
3 & \circled{7} 
\end{pmatrix}‎
‎‎\xrightarrow ‎{‎\tfrac{-12}{2}‎R_1+ R_3‎\mapsto ‎R_3}‎‎
\begin{pmatrix}
‎2‎‎ & 1 \\ 
1 & -5\\‎
-21 & \circled{5-‎}‎ 
\end{pmatrix}
‎\end{document}‎

‎ Is it possible to do it as the picture?

enter image description here

I think, If I can do that, they will be illustrated nicely.

6
  • Hi. Please a compilable MWE. You have been on this network for more than 4 years, you must know what a MWE is.
    – user156344
    Dec 3, 2018 at 6:30
  • Which package do you use for the \circled command?
    – user156344
    Dec 3, 2018 at 6:47
  • @DũngVũ I see you deleted your answer, but you can undelete it, saying "to simplify CarLaTeX's answer, you could use an array instead of a tabular." I rejected your edit to my question because I already edited it meanwhile.
    – CarLaTeX
    Dec 3, 2018 at 9:33
  • @CarLaTeX Oh yeah, that's right. However, your answer is much better than mine, so I decided to do so, in addition with upvote your answer. Even I got help from you in your answer! As for the edit, everyone sees the mistake in the link, so I know you will edit it. However, in case you left TeX.SX right after you posted this question and forgot to edit your answer (sometimes I do so :)) I just want to complete your answer :))
    – user156344
    Dec 3, 2018 at 9:52
  • @DũngVũ: Thanks for evey second my friend! I wish I had you answer here before I lost that. May I ask you to undelete it again. It would be kind of you. Thanks.
    – Mikasa
    Dec 4, 2018 at 3:08

3 Answers 3

7

Since you didn't provide a complete MWE, I used a \circled command found here.

By the way, the parts already written in your MWE don't exactly correspond to the image, I've replicated the image.

Edit: modified to remedy the Command \scriptsize invalid in math mode warning pointed out by egreg.

\documentclass[a4paper,12pt]{book}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(A.base)]{\node[circle,draw,inner 
sep=1](A){$#1$};}}% code from: https://tex.stackexchange.com/a/304891/101651
\usepackage{array}
\newcolumntype{R}{>{$\scriptstyle}r<{$}}
\usepackage{booktabs}
\begin{document}
    \[
    \begin{pmatrix}
    2 & 1 \\ 
    1 & -5\\
    3 & \circled{7} 
    \end{pmatrix}
    \xrightarrow[{ 
    \renewcommand*{\arraystretch}{0.8}\begin{tabular}{R@{$\scriptstyle 
    :\;\;$}R@{\hspace{4pt}}R}
        -12R_{1}  &  -24 & -12\\
        R_{3} & 3 & 7\\
        \cmidrule(r){2-3}
        \text{(new) } R_{3} & -21 & -5
        \end{tabular}}]{-12R_1+ R_3\mapsto R_3}
    \begin{pmatrix}
    2 & 1 \\ 
    1 & -5\\
    -21 & \circled{-5} 
    \end{pmatrix}
    \]
\end{document}

enter image description here

8
  • Thanks for every second! That I didn't attach the requisite link and codes was due to the way I ask the question. I was not at home to give you whole 40 packages which I had called before the main codes. I apologize you and all who read this question. Thanks and regards again.
    – Mikasa
    Dec 4, 2018 at 3:12
  • Yes. It is what I was looking for. Regards.
    – Mikasa
    Dec 4, 2018 at 3:16
  • Command \scriptsize invalid in math mode
    – egreg
    Dec 4, 2018 at 9:47
  • @egreg Overleaf strikes back: v2.overleaf.com/project/5bfa6d1b8dbef14ea3d0e63b (click on "show logs")
    – CarLaTeX
    Dec 4, 2018 at 9:52
  • typo in last row, -21 should replace -2
    – user4686
    Dec 4, 2018 at 10:57
4

You want a properly defined array using \scriptstyle. The explain environment takes as argument the number of columns after the colon.

\documentclass[a4paper,12pt]{book}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage{tikz}
\usepackage{array}
\usepackage{booktabs}

\newcolumntype{R}{>{\scriptstyle}r}

% code from: https://tex.stackexchange.com/a/304891/101651
\newcommand*\circled[1]{%
  \tikz[baseline=(A.base)]{\node[circle,draw,inner sep=1](A){$#1$};}%
}
\newenvironment{explain}[1]
 {%
  \renewcommand{\arraystretch}{0.7}%
  \setlength{\aboverulesep}{0.5\aboverulesep}%
  \setlength{\belowrulesep}{0.5\belowrulesep}%
  \begin{array}{@{} R @{\scriptstyle\;:\;} *{#1}{R} @{}}
 }
 {\end{array}}

\begin{document}

\[
\begin{pmatrix}
2 & 1 \\ 
1 & -5\\
3 & \circled{7} 
\end{pmatrix}
\xrightarrow[
  \begin{explain}{2}
    -12R_{1} & -24 & -12\\
       R_{3} &   3 &   7\\
     \cmidrule(l){2-3}
     \text{(new) } R_{3} & -21 & -5
  \end{explain}
]{-12R_1+ R_3 \to R_3}
\begin{pmatrix}
2 & 1 \\ 
1 & -5\\
-21 & \circled{-5} 
\end{pmatrix}
\]

\end{document}

enter image description here

An alternative definition for explain is

\usepackage{environ}

\NewEnviron{explain}[1]
 {%
  \mbox{%
    \scriptsize
    \setlength{\aboverulesep}{0.5\aboverulesep}%
    \setlength{\belowrulesep}{0.5\belowrulesep}%
    $\begin{array}{@{} r @{\;:\;} *{#1}{r} @{}}
    \BODY
    \end{array}$%
  }%
}

Without environ it could be

\newenvironment{explain}[1]
 {%
  \hbox\bgroup
    \scriptsize
    \setlength{\aboverulesep}{0.5\aboverulesep}%
    \setlength{\belowrulesep}{0.5\belowrulesep}%
    $\begin{array}{@{} r @{\;:\;} *{#1}{r} @{}}%
  }
  {\end{array}$\egroup}
0
1

@CarLaTeX's answer is very good! However, as an alternative solution, you can also use an array for the "table" below the arrow:

\documentclass[a4paper,12pt]{book}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage{array}
\begin{document}
\[
\left(\begin{array}{cc}
    2 & 1\\
    1 & -5\\
    3 & 7
\end{array}\right)\xrightarrow[
    \begin{scriptsize}
    \begin{array}{rrr}
        -12R_1: & -24 & -12\\
        R_3: & 3 & 7\\
        \cline{2-3}
        \text{(new) }R_3: & -21 & -5
    \end{array}
    \end{scriptsize}
]{-12R_1+R_3\rightarrow R_3}\left(\begin{array}{cc}
    2 & 1\\
    1 & -5\\
    -21 & -5
\end{array}\right)
\]
\end{document}

enter image description here

5
  • Command \scriptsize invalid in math mode
    – egreg
    Dec 4, 2018 at 9:47
  • @egreg See here. I get no errors not only in Overleaf.
    – user156344
    Dec 4, 2018 at 10:14
  • 1
    LaTeX Font Warning: Command \scriptsize invalid in math mode on input line 19.
    – user4686
    Dec 4, 2018 at 10:59
  • @egreg In that case, use \tiny etc. in mathmode :).
    – user156344
    Dec 4, 2018 at 11:39
  • 1
    @DũngVũ On Overleaf, click on "Logs and output files" and then on "View Raw Logs" and go more or less at the end of the log and you'll see it.
    – CarLaTeX
    Dec 4, 2018 at 15:38

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.