1

I have a labelled matrix generated through the blockarray package.

\documentclass{article}
\usepackage{blkarray}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\bm{\tilde{T}}_{(2,1)} =
\begin{blockarray}{cccccccc}
1 & 2 & & N-1 & N & N+1 & & N(N+1)\\
\begin{block}{(cccccccc)}
-1 & 0 & \cdots & 0 & 1 & 0 & \cdots & 0\\
0 & -1 & 0 & \cdots & 0 & 1 & \ddots & \vdots\\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & 0\\
0 & \dots & 0 & -1 & 0 & \cdots & 0 & 1\\
\end{block}
\end{blockarray}
\end{equation}
\end{document}

enter image description here

As you can see, there is no alignment between the diagonals of the matrix and the diagonal dots, because of the changing width of the columns, in turn caused by the labels.

How can I get a nice diagonal alignment, so that it is clear for the reader what elements the diagonal dots are connecting?

2

I propose this solution, with smaller labels and a width equal to the width of –1:

\documentclass{article}
\usepackage{blkarray}
\usepackage{amsmath, bm, amssymb}
\usepackage{makebox, bigstrut, relsize}

\begin{document}


\begin{equation}
\setlength{\arraycolsep}{3pt}
\bm{\widetilde{T}}_{(2,1)} =
\begin{blockarray}{*{8}{c}}
\mathsmaller{1} & \mathsmaller{2} & & \makebox*{$-1$}{$\mathsmaller{N-1}$} & \makebox*{$-1$}{$\mathsmaller{N}$} & \makebox*{$-1$}{$\mathsmaller{N+1}$} & & \makebox*{$-1$}{$\mathsmaller{N(N+1)}$}\\
\begin{block}{(cccccccc)}
-1 & 0 & \cdots & 0 & 1 & 0 & \cdots & 0 \bigstrut \\
0 & -1 & 0 & \cdots & 0 & 1 & \ddots & \vdots\\
\vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \ddots & 0 \bigstrut[b]\\
0 & \dots & 0 & -1 & 0 & \cdots & 0 & 1\bigstrut \\
\end{block}
\end{blockarray}
\end{equation}

\end{document} 

enter image description here

  • Thanks, it looks good! May I ask you to check whether I understand what you did? So, you increase the column separation to 3pt, then you employ \mathsmaller to reduce the size of the label and \makebox to set a width equal to the width of -1 for long labels. However I do not understand the use of \bigstrut. Why do you have \bigstrut for first and last row, \bigstrut[b] for the third row and nothing for the second row? – Francesco Jan 23 at 16:25
  • 1
    I added \bigstrut for two reasons: first, the delimiters in blockarray are often a bit too short. \bigstrut adds \bigstrutjot (defaults to 2pt) at the top and bottom of the cellin which it is found, so I obtain sensible delimiters. The second reason is to adjust the vertical spacing between rows, so as to have a better alignment of the diagonals. The [b] option is to add \bigstrutjot only at the bottom of the cell in that particular row. All this was decided by trial and error, I must say. – Bernard Jan 23 at 17:58

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.