1
\documentclass[journal]{IEEEtran}
\usepackage{kbordermatrix}
\begin{document}
\renewcommand{\kbldelim}{[}% Left delimiter
\renewcommand{\kbrdelim}{]}% Right delimiter
\[
\kbordermatrix{
    & t_1 & t_2 & t_3 & t_4 & t_5 \\
    N_1 & 0 & 1 & 1 & 0 & 1  \\
    N_2 & 1 & 0 & 1 & 1 & 0  \\
    N_3 & 0 & 1 & 1 & 0 & 1  \\
    N_4 & 0 & 1 & 0 & 0 & 0  \\
    N_5 & 1 & 0 & 1 & 0 & 1 
}
\]
\end{document}

Wants to create a box around first two columns of the given matrix.

2 Answers 2

1

I am not familiar with the kbordermatrix package, nor could I find a manual. So my answer may be a complete overkill. This is just to show you that you can draw boxes on any content with TikZ.

\documentclass[journal]{IEEEtran}
\usepackage{kbordermatrix}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikznode}[2]{\tikz[remember picture,baseline=(#1.base)]{\node(#1)[inner sep=0pt]{#2};}}
\begin{document}
\renewcommand{\kbldelim}{[}% Left delimiter
\renewcommand{\kbrdelim}{]}% Right delimiter
\[
\kbordermatrix{
    & t_1 & t_2\tikznode{t2}{\strut} & t_3 & t_4 & t_5 \\
    N_1 & 0 & 1 & 1 & 0 & 1  \\
    N_2 & 1 & 0 & 1 & 1 & 0  \\
    N_3 & 0 & 1 & 1 & 0 & 1  \\
    N_4 & 0 & 1 & 0 & 0 & 0  \\
    N_5 & \tikznode{1}{\strut}1 & 0 & 1 & 0 & 1 
}
\]
\tikz[overlay,remember picture]{%
\draw ([xshift=-2pt,yshift=-2pt]1.south west) rectangle ([xshift=2pt,yshift=2pt]t2.north east);}
\end{document}

enter image description here

1

With {bNiceMatrix} of nicematrix and Tikz.

\documentclass{article}
\usepackage{nicematrix,tikz}
\usetikzlibrary{fit}

\begin{document}

$\begin{bNiceMatrix}[first-row,first-col,left-margin]
    & t_1 & t_2 & t_3 & t_4 & t_5 \\
N_1 & 0   & 1   & 1   & 0   & 1 \\
N_2 & 1   & 0   & 1   & 1   & 0 \\
N_3 & 0   & 1   & 1   & 0   & 1 \\
N_4 & 0   & 1   & 0   & 0   & 0 \\
N_5 & 1   & 0   & 1   & 0   & 1 
\CodeAfter
  \tikz \node [draw,fit=(0-1)(5-2)] { } ; 
\end{bNiceMatrix}$

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .