Math & ScienceLatex matrix

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Mithrandir
Posts: 1
Joined: Wed Oct 23, 2019 11:20 pm

Latex matrix

Post by Mithrandir »

https://ibb.co/yycLztn
I need help implementing these matrices.
How can I implement these arrows in the picture into a project about latex

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Latex matrix

Post by Stefan Kottwitz »

Hi Mithrandir,

welcome to the forum!

What is the actual issue you see? We don't type matrices and long texts but we can help with issues. If you would like to post such matrix code, we can help to add such arrows.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Latex matrix

Post by Stefan Kottwitz »

Here is how I did it for the TikZ gallery years ago:

Code: Select all

% Highlighting elements in matrices
% Author: Stefan Kottwitz
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=red!15,draw,fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
    \tikz[overlay,remember picture]{
    \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}
\begin{document}
\[
  M = \left(\begin{array}{*5{c}}
    \tikzmark{left}{1} & 2 & 3 & 4 & 5\\
    6 & 7 & 8 & 9 & 10 \\
    11 & 12 & \tikzmark{right}{13} & 14 & 15 \\
    16 & 17 & 18 & 19 & 20
  \end{array}\right)
  \Highlight[first]
  \qquad
  M^T = \left(\begin{array}{*5{c}}
    \tikzmark{left}{1} & 6 & 11 & 16 \\
    2 & 7 & 12 & 17 \\
    3 & 8 & \tikzmark{right}{13} & 18 \\
    4 & 9 & 14 & 19 \\
    5 & 10 & 15 & 20
  \end{array}\right)
\]
\Highlight[second]

\tikz[overlay,remember picture] {
  \draw[->,thick,red,dashed] (first) -- (second) node [pos=0.66,above] {Transpose};
  \node[above of=first] {$N$};
  \node[above of=second] {$N^T$};
}
\end{document}​
highlighting-matrix.png
highlighting-matrix.png (12.82 KiB) Viewed 3143 times
Stefan
LaTeX.org admin
Post Reply