# Matrices above matrix in LaTeX [duplicate]

This question already has an answer here:

Ok..How to put matrices above matrix when you work with complex equations? I have matrices, such as:

I was able to wrote equation in the LaTeX first two matrices on bottom, but the 1x1 matrix on top seems unreal to write in LaTeX.

Here is my code:

\begin{bmatrix}
(\textbf{u}_{1}\textbf{v}_{1}) & \cdots & (\textbf{u}_{1}\textbf{v}_{n}) \\
\vdots & \ddots & \vdots \\
(\textbf{u}_{n}\textbf{v}_{1}) & \cdots & (\textbf{u}_{n}\textbf{v}_{n})
\end{bmatrix}


Any suggestions regarding that matrix on very top shown in the attached picture?

## marked as duplicate by user13907, Mensch, Jesse, Svend Tveskæg, Martin SchröderDec 22 '15 at 12:18

• Would be using tikz environments an option? This is completely overkilled, but an example as this one could give you some ideas. – Clément Dec 22 '15 at 3:22

Another solution, with \blkarray:

\documentclass{article}%[border=2mm,prewiev]{standalone}
\usepackage{mathtools}
\usepackage{blkarray, bigstrut}

\newcommand\topstrut[1][1.2ex]{\setlength\bigstrutjot{#1}{\bigstrut[t]}}

\begin{document}

$\begin{blockarray}{clcr} \begin{block}{c[!{\mspace{-3.2mu}}lcr!{\!}]} & \mspace{3.2mu}\mathbf{v}_{1} & \cdots & \mathbf{v}_{n}\,\\ \end{block} \begin{block}{[c][lcl]} u_1 & \mathbf{u}_{1}\mathbf{v}_{1} & \cdots & \mathbf{u}_{1}\mathbf{v}_{n}\topstrut[1ex] \\ \vdots & \vdots & \ddots & \vdots \\ u_n & \mathbf{u}_{n}\mathbf{v}_{1} & \cdots & \mathbf{u}_{n}\mathbf{v}_{n}\\[0.9ex] \end{block} \end{blockarray}$

\end{document}


• But with some manual adjusting as well. – Clément Dec 22 '15 at 15:07
• @Clément: I didn't c!aim there was none. One of them seems to be inherent to blockarray: the brackets are slightly too short. The other is specific to this problem: vertically adjusting the right-hand side matrices. – Bernard Dec 22 '15 at 17:40
• No, of course, but at first I thought there was no manual tweaking in your solution. So it was more a comment to myself, because I looked for a solution without manual adjustment, and couldn't find any. Neither could any of us, as it seems. Thanks for the additional clarification. – Clément Dec 22 '15 at 18:02

With some manual adjusting:

\documentclass{article}%[border=2mm,prewiev]{standalone}
\usepackage{mathtools}

\begin{document}
\begin{align*}
~   & \,
\begin{bmatrix}
\mathbf{v}_{1}  & \\  \quad\cdots\quad & \\   \mathbf{v}_{n}
\end{bmatrix}                   \\
%
\begin{bmatrix}
u_{1} \\    \vdots \\   u_{n}
\end{bmatrix}
&
\begin{bmatrix}
\mathbf{u}_{1}\mathbf{v}_{1}    & \cdots & \mathbf{u}_{1}\mathbf{v}_{n} \\
\vdots                          & \ddots & \vdots                       \\
\mathbf{u}_{n}\mathbf{v}_{1}    & \cdots & \mathbf{u}_{n}\mathbf{v}_{n}
\end{bmatrix}
\end{align*}
\end{document}