# Matrix multiplication on both rows is badly aligned

I try to make matrix multiplication like

\begin{align*}
~ & \begin{bmatrix}
m_{0} & m_{1} & m_{2} & m_{3} \\
m_{4} & m_{5} & m_{6} & m_{7} \\
m_{8} & m_{9} & m_{10} & m_{11} \\
m_{12} & m_{13} & m_{14} & m_{15}
\end{bmatrix} \\
\begin{bmatrix}
v_{0} & v_{1} & v_{2} & v_{3}
\end{bmatrix} & \begin{bmatrix}
r_{0} & r_{1} & r_{2} & r_{3}
\end{bmatrix}
\end{align*}


But vector r is not correctly align (vertically) with matrix m. Moreover, I don't want specifics packages (I use Latext inside MathJax).

Do you have some tips for me ?

Thanks

EDIT
I add another way with same issue:

$\begin{array}{cc} ~ & \begin{bmatrix} m_{0} & m_{1} & m_{2} & m_{3} \\ m_{4} & m_{5} & m_{6} & m_{7} \\ m_{8} & m_{9} & m_{10} & m_{11} \\ m_{12} & m_{13} & m_{14} & m_{15} \end{bmatrix} \\ \begin{bmatrix} v_{0} & v_{1} & v_{2} & v_{3} \end{bmatrix} & \begin{bmatrix} r_{0} & r_{1} & r_{2} & r_{3} \end{bmatrix} \end{array}$


I want this kind of design

• please provide complete but small document with your matrix. what is \X? welcome to tex.se! – Zarko Mar 27 '18 at 14:30

The big bracket has different side bearings than the smaller one.

\documentclass{article}
\usepackage{amsmath,calc}

\begin{document}

\begin{align*}
& \begin{bmatrix}
m_{0} & m_{1} & m_{2} & m_{3} \\
m_{4} & m_{5} & m_{6} & m_{7} \\
m_{8} & m_{9} & m_{10} & m_{11} \\
m_{12} & m_{13} & m_{14} & m_{15}
\end{bmatrix}
\\
\begin{bmatrix}
v_{0} & v_{1} & v_{2} & v_{3}
\end{bmatrix}
& \mspace{5mu}
\bigl[\begin{matrix}
\makebox[\widthof{$m_{12}$}]{$r_{0}$} &
\makebox[\widthof{$m_{13}$}]{$r_{1}$} &
\makebox[\widthof{$m_{14}$}]{$r_{2}$} &
\makebox[\widthof{$m_{15}$}]{$r_{3}$}
\end{matrix}
\mspace{5mu}
\bigr]
\end{align*}

\end{document}


• I valid solution BUT I can't use calc package on MathJax. I think now I must find a way to improve my Latex/MathJax. Thanks ! – Rominitch Mar 28 '18 at 6:51
• @Rominitch MathJax has nothing to do with this site. – egreg Mar 28 '18 at 6:52

First of all, there is nothing here to align, why do you use align*? two $ and $ are enough. Also, this is a vector-matrix multiplication, the inner dimensions must match and the result taking outer dimensions, so v[1-by-4] x M[4-by-4] = r[1-by-4]. I re-ordered the multiplication accordingly and removed align*.

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

$\begin{bmatrix} v_{0} & v_{1} & v_{2} & v_{3} \end{bmatrix} \begin{bmatrix} m_{0} & m_{1} & m_{2} & m_{3} \\ m_{4} & m_{5} & m_{6} & m_{7} \\ m_{8} & m_{9} & m_{10} & m_{11} \\ m_{12} & m_{13} & m_{14} & m_{15} \end{bmatrix} = \begin{bmatrix} r_{0} & r_{1} & r_{2} & r_{3} \end{bmatrix}$

\end{document}


• I don't search to write on one row but two – Rominitch Mar 27 '18 at 15:32
• @Rominitch - Please post an image of the desired alignment, your question is not clear; you say But vector r is not correctly align (vertically) with matrix m, r and m are on two different lines, in this case you can only horizontally align them. – AboAmmar Mar 27 '18 at 16:37