I am looking for a way, to draw lines in a given matrix, that connect two chosen entries. So, for example I would like to use

\begin{pmatrix} 1 & 2 \\ 3 & 4\end{pmatrix}

to initiate the 2x2-matrix with entries 1,2,3,4 and draw a line from 1 to 4 and a line from 3 to 2 within or rather over this matrix.

I would also be interested in drawing such lines in a matrix, whose entries simply are dots.

Thanks a lot!


Here is an example of what is easy to do with pstricks : define as nodes the elements in the matrix you want to link, then connect them by a node connection:

\usepackage{mathtools} %
\usepackage{auto-pst-pdf} % To compile with pdflatex --enablewrite18 (MiKTeX) or pdflatex --shell-escape (TeX Live, MacTeX)


\[ \begin{pspicture}
    \Rnode{a}{1} & \Rnode{b}{2} \\ \Rnode{c}{3} & \Rnode{d}{4}
    \psset{linewidth = 0.5pt, nodesep = 0.5pt}
     \ncline{b}{c}\ncline[border = 0.5pt]{a}{d}


enter image description here

\newcommand\tikznode[2]{\tikz[remember picture,baseline=(#1.base)]{\node(#1)[inner sep=0pt]{#2};}}
\[ M=
\begin{pmatrix} \tikznode{1}{1} & \tikznode{2}{2} \\ \tikznode{3}{3} & \tikznode{4}{4}\end{pmatrix}\]
\tikz[overlay,remember picture]{\draw[-](1)--(4);\draw[dotted,thick](2)--(3);}

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.