4

How can I increase the size of the brackets? They are not enclosing the whole matrix.

enter image description here

\documentclass{article}
\usepackage{blkarray}
\begin{document}

\begin{figure}[htbp]

\begin{spacing}{0.5}
\usepackage{amsmath}
\usepackage{setspace}


    \[ \mathbf{\hat R }= \begin{blockarray}{r*{5}{ >{\color{black}}c}}
    & A & B & C & D & E \\
    \begin{block}{ >{\scriptstyle}r!{\,}[ccccc]}
    1 & 5 & 3.09  & 4.90 & - & \textbf{4.62} \\
    2 & - & 2.89 & 4.69  & \textbf{3.49}  & 4.42 \\
    3 & 4.10 & 2.19 & - & \textbf{2.78}  & 3.71 \\
    4 & - & \textbf{1.00} & 2.49 & 1.29  & 2.22  \\
    5 & 4.90 & - & \textbf{4.79} & 3.58   & 4.51 \\
    6 & \textbf{4.88} & 2.96 & - & 3.56  & 4.48 \\
    7 & 3.15 & \textbf{1.23} & 3.03 & 1.82  & - \\
    8 & 4.84 & \textbf{2.92} & 4.72 & -  & 4.61 \\
    9 & \textbf{4.84} & 2.92 & 4.72 & 3.51  & - \\ 
    10& \textbf{4.61} & - & 4.49 & 3.29  & 4.22 \\
    \end{block}
    \end{blockarray} \]%

\end{spacing}
\caption{}

\end{figure}
\end{document}
  • 2
    How or where is the spacing environment defined? – Mico Oct 14 at 19:01
  • I have edited the OP – Delan Oct 14 at 19:03
  • The macros and environments of the setspace package are meant to be employed n text mode. It's asking for trouble to use a spacing environment inside a display-math environment. Don't do it. Instead, insert the instruction \renewcommand\arraystretch{0.8} immediately after \[. – Mico Oct 14 at 19:18
  • @Mico Thank you. It worked but now the numbers look very close to each other. That's why I used spacing before – Delan Oct 14 at 19:25
4

In my opinion, increasing the total height of the square brackets should be the least of your (typographic) priorities. I'd focus most (all?) of my energy on telling TeX to use the regular-bold rather than (default) bold-extended font weight for the numbers in the five data columns. I would also expend some energy on increasing the horizontal separation between the tall [ and ] symbols and the columns they enclose. In the code shown below, that's accomplished with the >{\,} and <{\,} particles.

Oh, and don't use a spacing environment inside a display-math setting. If you absolutely, positively must shrink the distance between rows, reset the parameter \arraystretch to a value less than 1. In the example shown below, I use a value of 0.5 -- which, in my opinion, is much too small. Do try something like 0.8 or 0.9 instead.

enter image description here

\documentclass{article}
\usepackage{blkarray}

\begin{document}
\[ 
\renewcommand{\bfdefault}{b}   % use bold, not bold-extended
\renewcommand\arraystretch{.5} % choose a suitable factor
\widehat{\mathbf{R}}= 
\begin{blockarray}{@{} r *{5}{c} }
      & A & B & C & D & E \\
    \begin{block}{@{} >{\scriptscriptstyle}r [>{\,}ccccc<{\,}] }
    1 & 5.00 & 3.09  & 4.90 & - & \textbf{4.62} \\
    2 & - & 2.89 & 4.69  & \textbf{3.49} & 4.42 \\
    3 & 4.10 & 2.19 & - & \textbf{2.78}  & 3.71 \\ 
    4 & - & \textbf{1.00} & 2.49 & 1.29  & 2.22 \\
    5 & 4.90 & - & \textbf{4.79} & 3.58  & 4.51 \\
    6 & \textbf{4.88} & 2.96 & - & 3.56  & 4.48 \\
    7 & 3.15 & \textbf{1.23} & 3.03 & 1.82 & -  \\
    8 & 4.84 & \textbf{2.92} & 4.72 & -  & 4.61 \\
    9 & \textbf{4.84} & 2.92 & 4.72 & 3.51 & -  \\ 
    10& \textbf{4.61} & - & 4.49 & 3.29  & 4.22 \\
    \end{block}
    \end{blockarray} 
\]
\end{document}
5

There's a workaround for the brackets size: use \bigtrut[t] in a cell of the first row and \bigstrut[b] in the last row. I added a simplication of the code for the first column, using the BAenum row counter defined by the package Last, I removed the unnecessary colon after the figure label, since there's no caption text.

\documentclass{article}
\usepackage{xcolor}
\usepackage{blkarray, bigstrut}
\usepackage{caption}

\usepackage{amsmath}

\begin{document}

\begin{figure}[htbp]\bigstrutjot=1ex \captionsetup{labelsep=none, skip=0pt}
    \[ \mathbf{\widehat R }=\begin{blockarray}{r*{5}{ >{\color{black}}c}}
    & A & B & C & D & E \\\noalign{\setcounter{BAenumi}{1}}
    \begin{block}{ >{\scriptstyle\theBAenumi}r!{\,}[ccccc]}
    & 5 & 3.09 & 4.90 & - & \mathbf{4.62}\bigstrut[t] \\
    & - & 2.89 & 4.69 & \mathbf{3.49} & 4.42 \\
    & 4.10 & 2.19 & - & \mathbf{2.78} & 3.71 \\
    & - & \mathbf{1.00} & 2.49 & 1.29 & 2.22 \\
    & 4.90 & - & \mathbf{4.79} & 3.58 & 4.51 \\
    & \mathbf{4.88} & 2.96 & - & 3.56 & 4.48 \\
    & 3.15 & \mathbf{1.23} & 3.03 & 1.82 & - \\
    & 4.84 & \mathbf{2.92} & 4.72 & - & 4.61 \\
    & \mathbf{4.84} & 2.92 & 4.72 & 3.51 & - \\
    & \mathbf{4.61} & - & 4.49 & 3.29 & 4.22 \bigstrut[b]\\
    \end{block}
    \end{blockarray} \]%
\caption{}
\end{figure}

\end{document} 

enter image description here

2

You could consider using kbordermatrix:

enter image description here

\documentclass{article}

\usepackage{kbordermatrix}

\begin{document}

\[ 
  \renewcommand{\bfdefault}{b}   % use bold, not bold-extended
  \widehat{\mathbf{R}} = 
  \kbordermatrix{%
       &   A  &   B  &   C  & D & E \\
    1  & 5.00 & 3.09 & 4.90 & - & \textbf{4.62}  \\
    2  & - & 2.89 & 4.69  & \textbf{3.49} & 4.42 \\
    3  & 4.10 & 2.19 & - & \textbf{2.78}  & 3.71 \\
    4  & - & \textbf{1.00} & 2.49 & 1.29  & 2.22 \\
    5  & 4.90 & - & \textbf{4.79} & 3.58  & 4.51 \\
    6  & \textbf{4.88} & 2.96 & - & 3.56  & 4.48 \\
    7  & 3.15 & \textbf{1.23} & 3.03 & 1.82 & -  \\
    8  & 4.84 & \textbf{2.92} & 4.72 & -  & 4.61 \\
    9  & \textbf{4.84} & 2.92 & 4.72 & 3.51 & -  \\
    10 & \textbf{4.61} & - & 4.49 & 3.29  & 4.22
  }
\]

\end{document}

The above code is taken partially from Mico's answer.

  • When I run it, it throws this error File kbordermatrix.sty' not found. ^^M` – Delan Oct 15 at 20:27
  • @Delan: Download kbordermatrix.sty and store it in C:\texlive\texmf-local\tex\latex\local - do you have TeX Live? Then run texhash from the command prompt. Alternatively, just download kbordermatrix.sty and place it in your working folder. – Werner Oct 15 at 20:30

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.