I'm wondering if anyone can help me typeset this border matrix with lines inside it. Dashed or solid lines are okay but I would prefer the lines to not extend past the brackets. I would also prefer to not need to load 3+ packages to get this to happen.
I have tried several other solutions I've found on StackExchange but they don't seem to work (I don't have kbordermatrix and nicematrix doesn't draw lines for some reason).
Any advice is appreciated.
EDIT: Here's my current code:
\bbordermatrix{
& {\bf 1} & {\bf 5} & {\bf 2} & {\bf 4} & {\bf 3} \cr
{\bf 1}\, & \nicefrac16 & \nicefrac56 & 0 & 0 & 0 \cr
{\bf 5}\, & \nicefrac16 & \nicefrac56 & 0 & 0 & 0 \cr
{\bf 2} & 0 & 0 & \nicefrac23 & \nicefrac13 & 0 \cr
{\bf 4} & 0 & 0 & \nicefrac23 & \nicefrac13 & 0 \cr
{\bf 3} & \nicefrac1{36} & \nicefrac5{36} & \nicefrac59 & \nicefrac5{18} & 0
}
I've started to troubleshoot what's going wrong with NiceMatrix. I have a header file that I include as \include{…}. Something in that header file seems to make this matrix (source: bordermatrix with blocks):
come out like this:
The problem is, I went through and commented out every line of code in that header and nothing seems to specifically be the problem. In fact, if I don't include the header but just copy in every line, when I typeset the document the matrix first comes out wrong, but the second time I typeset it comes out right. I've never seen this sort of behavior before… how can I get different results?
Then if I remove the lines of the header file and replace them with \include, I get the reverse behavior: the first time it will typeset correctly, and all subsequent times it will typeset incorrectly.
I have no idea what's going on.
Best Answer
Here is a solution using
nicematrix
and two custom rules.Used
nicematrix.sty 2022/05/08 v6.8a
Update After follow-up question: bold face for the first column and the first row of the array. Use the keys
code-for-first-row
andcode-for-first-col