Long matrix equation splitting

I am trying to write a long equation which includes a long matrix. I have tried many solutions (multiline, split) from the other so answers but the problem still exists. Could you help me to find out the problem? Thank you in advance.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

$$\begin{multiline} \label{nineth} \begin{bmatrix} \dot{x}\\ \dot{y}\\ \dot{z}\\ \end{bmatrix} = \begin{bmatrix} R_{0}^{0} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{0}) & R^{0}_{1} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{1}) & R^{0}_{2} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{2}) & R^{0}_{3} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{3}) & \\ R^{0}_{4} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{4}) & \end{bmatrix} \begin{bmatrix} \dot{\theta_{1}} \\ \dot{\theta_{2}} \\ \dot{\theta_{3}} \\ \dot{\theta_{4}} \\ \dot{\theta_{5}} \\ \end{bmatrix} \end{multiline}$$
\end{document}


As you can see there are 3 terms in the equation, 2nd term should be splitted but the result of the code is wrong in the image.

• Welcome to TeX.SE! multiline does not exist and should be multline, which cannot be nested in an equation. But apart from this I really do not understand how the equation is supposed to look like. Aug 4, 2021 at 16:10
• The secondterm in the image is a one matrix R_{0}_{4} ... should be on the same row as well others element of the matrix or the 3rd term should be near to the R_{0}_{4} element of the 2nd term. multline did not give any result btw. Aug 4, 2021 at 16:14
• Exactly it is 1x5 row vector. Yes everyting what you explained, (-) is also supposed to be (=). Aug 4, 2021 at 16:30
• If I understand your setup correctly, the big matrix is supposed to be a 3x5 matrix; is this correct? (The x characters denote multiplication, right?) If my assumption is correct, why not just state that \dot{x}=0, \dot{y}=0, and provide an inline math expression for \dot{z}?
– Mico
Aug 4, 2021 at 16:33
• Yes it is for cross product. The matrix is as you said 3x5. Aug 4, 2021 at 16:35

I'm not sure that the matrix form is really helpful for your readers; in this case a summation seems much better:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$$\begin{bmatrix} \dot{x} \\ \dot{y} \\ \dot{z} \end{bmatrix} - \sum_{k=0}^4 R^{0}_{k} \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} x(d^{0}_{5}-d^{0}_{k}) \dot{\theta}_{k+1}$$

\end{document}


Alternatively,

$$\begin{bmatrix} \dot{x} \\ \dot{y} \\ \dot{z} \end{bmatrix} - \begin{bmatrix} S_0 & S_1 & S_2 & S_3 & S_4 \end{bmatrix} \begin{bmatrix} \dot{\theta}_1 \\ \dot{\theta}_2 \\ \dot{\theta}_3 \\ \dot{\theta}_4 \\ \dot{\theta}_5 \end{bmatrix}, \qquad S_k=R^{0}_{k}\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}x(d^{0}_{5}-d^{0}_{k})$$


I propose to use multlined environment (from mathtools) inside the large matrix, and the geometry package to have more decent margins by default.

Unrelated: needless to load inputenc with option [utf8] nowadays (unless you have an old version of LaTeX), nor amsfonts if you load amssymb – the latter does it for you.

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{bigstrut}
\setlength{\bigstrutjot}{1ex}

\begin{document}

$$\label{nineth} \begin{bmatrix} \dot{x}\bigstrut[t]\\ \dot{y}\\ \dot{z}\bigstrut[b] \end{bmatrix} = \begin{bmatrix} \begin{multlined} R_{0}^{0} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{0}) \quad R^{0}_{1} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{1})\quad R^{0}_{2} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{2})\\[-2ex] R^{0}_{3} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{3}) \quad R^{0}_{4} \begin{bmatrix} 0\\ 0\\ 1 \end{bmatrix} x (d^{0}_{5}-d^{0}_{4}) \end{multlined} \end{bmatrix} \begin{bmatrix} \dot{\theta_{1}}\bigstrut[t] \\[0.5ex] \dot{\theta_{2}} \\[0.5ex] \dot{\theta_{3}} \\[0.5ex] \dot{\theta_{4}} \\[0.5ex] \dot{\theta_{5}}\bigstrut[b] \end{bmatrix}$$

\end{document}


• Thank you so much but it is not like I wanted. I have found the answer here link Aug 4, 2021 at 18:20
• I only wanted to show that multline can be nested if you load mathtools and use multlined in the right place. This being said, I don't understand what you wanted. Aug 4, 2021 at 18:44