1

a

In the image above, we can see that blockarray barely leaves any clearance between the matrix content and the brackets around it. The distance from the first row to the orange line is extremely small. I would like the edges of the brackets to stretch above and below the contents to leave some extra vertical space so that the matrix looks less crowded. Something like this (except that the space should be added on top and bottom)

enter image description here

Also, it is possible to increase horizontal clearance by using a syntax like >{\medspace} and <{\medspace} in the block preamble, resulting in something like this

enter image description here

Even though the matrix looks better now, it is still too redundant to specify the amount of space after and before brackets every time in the preamble of the block. Is there a way to automatically insert that space near the interiors of the brackets?

\documentclass[11pt, a4paper]{IEEEtran}

\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\renewcommand{\arraystretch}{1.2}
\usepackage{blkarray}


\begin{document}


\begin{blockarray}{r c c c c}

    & A & B & C & D
    \\
    \begin{block}{r [>{\medspace}c c c c<{\medspace}]}  

        A & 245 & 321 & 572 & 214
        \\

        B & 574 & 710 & 230 & 130
        \\

        C & 790 & 211 & 570 & 325
        \\

        D & 621 & 240 & 390 & 170
        \\
    \end{block}

\end{blockarray}


\end{document}
  • yoy could define a new BA columntype that was [>{\medspace} – David Carlisle May 24 at 11:05
  • Thanks for the answer. How about the vertical clearance? – Al-Motasem Aldaoudeyeh May 24 at 11:07
  • you could insert >{\medspace\rule{0pt}{20pt} it's a long time since I looked at blockarray internals:-) – David Carlisle May 24 at 11:15
2

You can use the bigstrut package:

\documentclass[11pt, a4paper]{IEEEtran}

\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\renewcommand{\arraystretch}{1.2}
\usepackage{blkarray}
\usepackage{bigstrut}

\begin{document}

\setlength{\bigstrutjot}{1ex}
\begin{blockarray}{r c c c c}
    & A & B & C & D
    \\
    \begin{block}{r [>{\medspace}c c c c<{\medspace}]}
        A & 245 & 321 & 572 & 214\bigstrut[t]
        \\
        B & 574 & 710 & 230 & 130
        \\
        C & 790 & 211 & 570 & 325
        \\
        D & 621 & 240 & 390 & 170\bigstrut[b]
        \\
    \end{block}
\end{blockarray}

\end{document} 

enter image description here

1

Here another proposal using kbordermatrix package:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{kbordermatrix}


\begin{document}
\[
\kbordermatrix{
  & \text{\small A} & \text{\small B} & \text{\small C} & \text{\small D} \cr
\text{\small A} & 245 & 321 & 572 & 214 \cr
\text{\small B} & 574 & 710 & 230 & 130 \cr
\text{\small C} & 790 & 211 & 570 & 325 \cr
\text{\small D} & 621 & 240 & 390 & 170 \cr
}
\]

\end{document}

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.