2

What's your question?

Currently I have this matrix:

enter image description here

Now I want to do a sum on this matrix by adding an arrow on the right which describes what I'm doing, like that:

enter image description here

What have you tried yet?

Well I found the witharrows package but I don't understand how I should apply it.

Minimal code

Code from first image

\documentclass[a4paper, 12pt]{scrartcl}

% =============
% Packages 
% =============
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                % west european chars
\usepackage{amsmath, amsthm, amssymb}   % math symbols
\usepackage{blkarray}

\parskip5pt
\parindent0pt

% ------------
% Content 
% ------------
\begin{document}
\begin{align*}
    \begin{blockarray}{ccccccc}
        \begin{block}{(ccc|ccc)c}
            1 & 5 & 4 & 1 & 0 & 0 & | \cdot 2\\
            3 & 5 & 6 & 0 & 1 & 0 & \\
            1 & 2 & 4 & 0 & 0 & 1 &
        \end{block}
    \end{blockarray}
\end{align*}
\end{document}

Code from second image

So that's how I tried to apply witharrows to the matrix:

\documentclass[a4paper, 12pt]{scrartcl}

% =============
% Packages 
% =============
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                % west european chars
\usepackage{amsmath, amsthm, amssymb}   % math symbols
\usepackage{blkarray}
\usepackage{witharrows}

\parskip5pt
\parindent0pt

% ------------
% Content 
% ------------
\begin{document}
\begin{align*}
    \begin{blockarray}{ccccccc}
        \begin{block}{(ccc|ccc)c}
            \begin{WithArrows}[c]
                1 & 5 & 4 & 1 & 0 & 0 & | \cdot 2 \Arrow{test}\\
                3 & 5 & 6 & 0 & 1 & 0 & 
                1 & 2 & 4 & 0 & 0 & 1 &\\
            \end{WithArrows}
        \end{block}
    \end{blockarray}
\end{align*}
\end{document}

but I'm getting a bunch of errors.

EDIT

Here are the error messages:

Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: You should use the command \Arrow only in the last of your environment {WithArrows}. However you can go on for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: The environments of witharrows ({WithArrows} and should not end by \\. However, you can go on for this time. No similar error will be raised in this document.
Document.tex|30 error| Misplaced \noalign.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: You should use the command \Arrow only in the last of your environment {WithArrows}. However you can go on for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Package witharrows Error: Your environment {WithArrows} has 2 columns and you try to use one more. Maybe you have forgotten a \\. If you really want to use more you should use the option 'more-columns' at a global level or for an environment. However, you can go one for this time.
Document.tex|30 error| Misplaced \noalign.
6
  • What are the bunch of errors?
    – CroCo
    Apr 17, 2021 at 22:07
  • Added them to my post. Thank you for the hint!
    – TornaxO7
    Apr 17, 2021 at 22:11
  • Well, the error is extremely clear. look at the second row 3 & 5 & 6 & 0 & 1 & 0 & , you've forgotten to add `\\` to start the new row.
    – CroCo
    Apr 17, 2021 at 22:17
  • According to the documents of WithArrows, I should not add a `\\` in the line, were the arrow should end.
    – TornaxO7
    Apr 17, 2021 at 22:26
  • Well, the arrow ends at the last row not the second one.
    – CroCo
    Apr 17, 2021 at 22:28

2 Answers 2

6

Probably it would be better if you used the nicematrix package (see below), but you can also add the arrow with TikZ and the tikzmark library.

\documentclass[a4paper, 12pt]{scrartcl}

% =============
% Packages 
% =============
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                % west european chars
\usepackage{amsmath, amsthm, amssymb}   % math symbols
\usepackage{blkarray}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\parskip5pt
\parindent0pt

% ------------
% Content 
% ------------
\begin{document}
\begin{align*}
    \begin{blockarray}{ccccccc}
        \begin{block}{(ccc|ccc)c}
            1 & 5 & 4 & 1 & 0 & 0 & \tikzmarknode{times2}{| \cdot 2}\\
            3 & 5 & 6 & 0 & 1 & 0 & \\
            1 & 2 & 4 & 0 & 0 & \tikzmarknode{1}{1} &\\
        \end{block}
    \end{blockarray}
    \begin{tikzpicture}[overlay,remember picture]
     \draw[cyan,semithick,-latex] (times2.east) -- ++ (1em,0) 
      |- node[pos=0.25,right]{$(+)$} (times2.west|-1);
    \end{tikzpicture}
\end{align*}
\end{document}

enter image description here

With nicematrix it works very similar. Note that this code requires the latest (as of April 2021) version of the package.

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}
\[
 \begin{pNiceArray}{ccc|ccc}[last-col]
            1 & 5 & 4 & 1 & 0 & 0 & | \cdot 2\\
            3 & 5 & 6 & 0 & 1 & 0 & \\
            1 & 2 & 4 & 0 & 0 & 1 &\\
 \CodeAfter
  \begin{tikzpicture}
   \draw[cyan,semithick,-latex] (1-7.east) -- ++ (1em,0) 
      |- node[pos=0.25,right]{$(+)$} (1-7.west|-3-6);           
  \end{tikzpicture}
 \end{pNiceArray}
\]
\end{document}

enter image description here

3
  • How would you do that with the nicematrix package? Could you please provide an example with this package please?
    – TornaxO7
    Apr 17, 2021 at 22:05
  • @TornaxO7 I added a version. Notice that you need a very recent version of the package, i.e. if you plan to upload the code to the arXiv it may be better to stick to the first code.
    – user240002
    Apr 17, 2021 at 22:17
  • Thank you sir/madam :)
    – TornaxO7
    Apr 17, 2021 at 22:22
1

Ashort code with pstricks`: I define two nodes, and connect them with the relevant node connection.

\documentclass[svgnames]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{blkarray, bigstrut}
\usepackage{pst-node}

 \begin{document}%

\begin{align*}
& \begin{blockarray}{(ccc|ccc)l}
        1 & 5 & 4 & 1 & 0 & 0\bigstrut[t] & \rnode{A}{| \cdot 2}\\
        3 & 5 & 6 & 0 & 1 & 0 & \\
        1 & 2 & 4 & 0 & 0 & 1 & \pnode[0,0.5ex]{B}
\end{blockarray}
\ncbar[linecolor=Cyan, linejoin=1, arrowinset =0, nodesepA=2pt]{->}{A}{B}\naput{\color{Cyan}({+})}
\end{align*}

\end{document} 

enter image description here

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.