How to create assignment border matrix like this [duplicate]

I want to create assignment matrix like this

\usepackage{kbordermatrix,blkarray}
\usepackage{amsmath}
\usepackage{amsmath,stackengine}
\stackMath
$\stackinset{c}{-2.8\baselineskip}{c}{}{\rule{.4pt}{5.2\baselineskip}}{% \stackinset{c}{1.9\baselineskip}{c}{}{\rule{.4pt}{5.2\baselineskip}}{% \stackinset{c}{3.1\baselineskip}{c}{}{\rule{.4pt}{5.2\baselineskip}}{% \stackinset{c}{}{c}{2\baselineskip}{\rule{6.9\baselineskip}{.4pt}}{% \stackinset{c}{}{c}{-3\baselineskip}{\rule{6.9\baselineskip}{.4pt}}{% \bbordermatrix{ & 1 & 2 & 3 & 4 & 5 & 6 \cr 1 & 1.5 & 3.5 & 1 & (1) & 1 & 4 \cr 2 & 1.8 & (1) & 3.1 & 2.6 & 1.9 & 1.8 \cr 3 & (1) & 1 & 1 & 1.4 & 1.1 & 2.1 \cr 4 & 3.8 & 4 & (1) & 5.6 & 2.8 & 2.2 \cr 5 & 3 & 3.3 & 1 & 4.6 & 4.6 & 5 \cr 6 & 4.8 & 4.9 & 3.2 & 5.5 & 2.8 & (1) \cr }}}}}}$


marked as duplicate by Andrew, Stefan Pinnow, Troy, TeXnician, SchweinebackeJun 27 '17 at 17:51

• I have added the code in which tried by me. in this i am unable to fix the row line and column line from first row to last row and first column to last one. – user51868 Jun 27 '17 at 15:28
• Fix how exactly? – Bernard Jun 27 '17 at 15:39
• Do you really want the numbers 1 2 3 4 5 6 as in the picture, not in line with the columns of the matrix? What do they mean? – Benjamin McKay Jun 27 '17 at 15:41
• I need that it will appear above the first column (top border – user51868 Jun 27 '17 at 15:47
• Tell us what class you have used?@user51868 – Biki Teron Jun 27 '17 at 16:44

Here is a way to obtain it with blkarray and pstricks. I added auto-pst-pdf to compile with pdflatex, but this requires to launch the compiler with the enable-write18 switch (MiKTeX) or -shell-escape (TeX Live, MacTeX):

\documentclass[12pt, svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage{blkarray, bigstrut, amsmath}
\usepackage{pst-node, auto-pst-pdf}
\begin{document}

$\begin{postscript} \begin{blockarray}{c*{6}{c}} \begin{block}{c*{6}{>{ \footnotesize }c}} & \thead{1} & \thead{2} & \thead{3} & \thead{4} & \thead{5} & \thead{6} \\ \end{block} \begin{block}{>{\footnotesize }c(*{6}{c})} 1 & \rnode{A}{1.5} & 3.5 & 1 & (1) & \Rnode{E}{1} & \rnode{B}{4}\bigstrut[t] \\ 2 & 1.8 & (1) & 3.1 & 2.6 & 1.9 & 1.8 \\ 3 & (1) & 1 & 1 & 1.4 & 1.1 & 2.1 \\ 4 & 3.8 & 4 & (1) & 5.6 & 2.8 & 2.2 \\ 5 & 3 & 3.3 & 1 & 4.6 & 4.6 & 5 \\ 6 & \Rnode{D}{4.8} & 4.9 & 3.2 & 5.5 & \Rnode{F}{2.8} & \Rnode{C}{(1)}\bigstrut[b] \\ \end{block} \end{blockarray} \psset{linewidth=0.4pt, linecolor=LightSteelBlue, nodesep = -1.4em} \ncline[nodesepB=-.8em]{A}{B} \ncline{C}{D} \psset{nodesep=-1em} \ncline{A}{D} \ncline{B}{C} \ncline{E}{F} \end{postscript}$

\end{document}