# Format long equation in Array

I have a 3 X 1 array that is too long. I have used the multline command to write it but it is not easily readable. Please, is there a better way to write this equation?

Code Updated to show the intended 3 X 1 matrix

\begin{multline}
\left[
\begin{matrix}[2]
- \frac{K_i ^2}{m^2} \bigg( \frac{\partial z }{\partial x}  \tan(mm^2 e + mm^2 y) + z \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \bigg) \times z (\cot(m^2 b(x) + m^2 y)  + \bigg( \frac{K_i}{m} z \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \bigg)   \bigg( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\cot(m^2 b(x) + m^2 y) \bigg)\\
%%
- \frac{K_i}{m \tau} \left( \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \right) \left(  \frac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \right) + \frac{K_i}{m \tau} \left( \cot(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \right) \left(  \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 b(x) + m^2 y) \right) \\
%%%
\frac{K_i}{m} \bigg( \frac{\partial^2 y}{\partial^2 x} z \tan(m^2 e + m^2 y)  + \frac{\partial y}{\partial x}  \tan(m^2 e + m^2 y) \frac{\partial z}{\partial x} + \frac{\partial y}{\partial x} z  \cot(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \bigg) \times   \frac{K_i}{m} z \cot(m^2 b(x) + m^2 y) - \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 e + m^2 y) . m^2  \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  \cot(m^2 b(x) + m^2 y)
\end{matrix}
\right]
\\
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\left[
\begin{matrix}[2]
-\frac{K_i ^2}{m^2} \bigg( \frac{\partial z }{\partial x}  \cot(m^2 e + m^2 y) - z \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}    \bigg) \times z (\tan(m^2 b(x) + m^2 y)  +  \bigg( \frac{K_i}{m} z \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)} {\partial x} \bigg)   \bigg( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\tan(m^2 b(x) + m^2 y) \bigg)\\
%%
\frac{K_i}{m \tau} \left( \tan(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x}  \right) \left(  \frac{K_i}{m} z (\tan(m^2 b(x) + m^2 y) \right)- \frac{K_i}{m \tau} \left( \tan(m^2 b(t) + m^2 y) . m^2  \frac{\partial b(t)}{\partial x}  \right) \left(  \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 b(x) + m^2 y) \right) \\
%%%
\frac{K_i}{m} \bigg( \frac{\partial^2 y}{\partial^2 x} z \cot(m^2 e + m^2 y)  + \frac{\partial y}{\partial x}  \cot(m^2 e + m^2 y) \frac{\partial z}{\partial x} - \frac{\partial y}{\partial x} z  \tan(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \bigg) \times   \frac{K_i}{m} z \tan(m^2 b(x) + m^2 y)  - \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 e + m^2 y) . m^2  \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m}  \tan(m^2 b(x) + m^2 y)
\end{matrix}
\right]
\end{multline}



I have included my preamble code.

\usepackage[left=30mm,top=20mm,right=30mm,bottom=20mm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{commath,amsmath}
\usepackage{siunitx}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{float}
\usepackage{booktabs}
\setcounter{secnumdepth}{5}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\usepackage{amsfonts}
\usepackage{xparse,mathtools}
\def\mtrm#1{\rule{#1}{1.5ex}}
\usepackage{bm}
%\usepackage{derivative}
%\usepackage{epstopdf}
%\renewcommand\thechapter{\Roman{chapter}}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amssymb}
\usepackage{upgreek}
\usepackage{physics}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclarePairedDelimiterX{\rvect}[1]{[}{]}{\,\makervect{#1}\,}

\ExplSyntaxOn
\NewDocumentCommand{\makervect}{m}
{
\seq_set_split:Nnn \l_tmpa_seq { , } { #1 }
\begin{matrix}
\seq_use:Nn \l_tmpa_seq { & }
\end{matrix}
}
\ExplSyntaxOff

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
\edef\arraystretch{#1}%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols c}}
\makeatother

• What does the [2] (optional argument for the matrix environment?) represent? Commented Jun 24, 2022 at 15:31
• @Bernard the [2] gives the matrix some vertical space.
– Tee
Commented Jun 24, 2022 at 16:39
• Which package do you use for that? Commented Jun 24, 2022 at 16:46
• To be honest, I can't remember. I defined a preamble a while ago. It has all the packages I use often. I am guessing that it's from \usepackage{commath,amsmath}
– Tee
Commented Jun 24, 2022 at 17:01
• Another question: is the content of a matrix a single long equation, or is it a set of several long equations? Commented Jun 24, 2022 at 17:10

Thanks for posting some additional explanations.

I have three major suggestions:

• I think that in order to typeset the matrix environments that contain the 3x1 vectors, you need to provide 1 line break each in the first 2 elements and 2 line breaks in the 3rd vector.
• I'd switch from \left[ \begin{matrix} ... \end{matrix} \right] to \begin{bmatrix*}[l] ... \end{bmatrix*}. I'd then provide some visual signposts as to which multi-line element is which inserting \qquad directives at the starts of the continuation lines.
• I think that \bigg is just too big for the equations at hand; I'd use \Bigl and \Bigr instead. I would also replace all instances of \left and \right with \Bigl and \Bigr, respectively.

• I'm sure what to make of the . ("dot", aka "full stop") characters that occur throughout the vectors. If they're supposed to indicate multiplication, I would either just omit them entirely or, as @Bernard does in his answer, replace . with \cdot.

• Don't use the commath package. As David Carlisle says, quite charitably: "the [commath] package is based on a misunderstanding of tex math mode". The fact that the package hasn't been updated in more than 15 years should also give you pause.

• Don't use the physics package unless you know what you're doing -- in which case you may not need the package to begin with. For instance, do you really want to put up with the package's irritating default setting of automatically increasing the sizes of "outer" pairs of parentheses (and other paired delimiters) that involve \tan and \cot? Now, this setting can be deactivated by loading the package with the option notrig. Let's be honest, though: how many users of the physics package are aware of the existence of this option -- or, for that matter, of the default setting with regard to autosizing "outer" parentheses, brackets, etc that involve trigonometric terms?

A separate comment: It's not clear to me why you chose to express the overall 3x1 vector as the difference of two 3x1 vectors, as both of these still need further line breaking in order to make them fit within the text block. Wouldn't it have been easier to just display a single 3x1 vector, in which the first two elements occupy four rows each and the final element occupies 6 rows? Maybe something like this (note the use of display-style math, as opposed to text-style math that was used in the preceding screenshot):

\documentclass{article}

\usepackage[hmargin=30mm,vmargin=20mm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}

%% math-y stuff:
%\usepackage{commath} % do yourself a favor and don't use commath
%\usepackage{amsmath} % amsmath is loaded automatically by mathtools
\usepackage{amssymb}
\usepackage{upgreek}
%%\usepackage{physics} % don't use 'physics' unless you know what you're doing
% (in which case you probably won't need it anyway...)
\usepackage{mathtools} % for 'bmatrix*' env.; loads 'amsmath' automatically
\usepackage{bm}
%\usepackage{derivative}

\usepackage{siunitx}

\usepackage{cite}
%%\usepackage{float} % please try to make do without '[H]' position specifier
\usepackage{booktabs}

\setcounter{secnumdepth}{5}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\usepackage{xparse}
\def\mtrm#1{\rule{#1}{1.5ex}}
%\usepackage{epstopdf} % no need, since you load 'graphicx'
%\renewcommand\thechapter{\Roman{chapter}}

\usepackage[dvipsnames]{xcolor}

\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage{hyperref} % it's a good idea to load this package last

\begin{document}

\begin{multline}
\begin{bmatrix*}[l]
- \frac{K_i ^2}{m^2}
\Bigl( \frac{\partial z }{\partial x}  \tan(mm^2 e + mm^2 y)
+ z \cot(m^2 e + m^2 y) . m^2  \frac{\partial y}{\partial x} \Bigr)
\times z (\cot(m^2 b(x) + m^2 y)  \\ % there seems to be a surplus '(' char. on this line
\Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m}  (\cot(m^2 b(x) + m^2 y) \Bigr) \2\jot] %% - \frac{K_i}{m \tau} \Bigl( \cot(m^2 e + m^2 y) . m^2 \frac{\partial y}{\partial x} \Bigr) \Bigl( \frac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \Bigr) \\ \qquad{}+ \frac{K_i}{m \tau} \Bigl( \cot(m^2 b(t) + m^2 y) . m^2 \frac{\partial b(t)}{\partial x} \Bigr) \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m} \cot(m^2 b(x) + m^2 y) \Bigr) \\[2\jot] %% \frac{K_i}{m} \Bigl[ \frac{\partial^2 y}{\partial^2 x} z \tan(m^2 e + m^2 y) + \frac{\partial y}{\partial x} \tan(m^2 e + m^2 y) \frac{\partial z}{\partial x} \\ \qquad{}+ \frac{\partial y}{\partial x} z \cot(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \Bigr] \times \frac{K_i}{m} z \cot(m^2 b(x) + m^2 y) \\ \qquad{}- \frac{\partial y}{\partial x} z \frac{K_i}{m} \cot(m^2 e + m^2 y) . m^2 \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m} \cot(m^2 b(x) + m^2 y) \end{bmatrix*} \\[\jot] - %%%%%%%%%%%%% \begin{bmatrix*}[l] -\frac{K_i ^2}{m^2} \Bigl( \frac{\partial z }{\partial x} \cot(m^2 e + m^2 y) - z \tan(m^2 e + m^2 y) . m^2 \frac{\partial y}{\partial x} \Bigr) \times z (\tan(m^2 b(x) + m^2 y) \\ % there seems to be a surplus '(' char. on this line too \qquad{}+ \Bigl( \frac{K_i}{m} z \tan(m^2 e + m^2 y) . m^2 \frac{\partial b(t)} {\partial x} \Bigr) \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m} (\tan(m^2 b(x) + m^2 y) \Bigr) \\[2\jot] %% \frac{K_i}{m \tau} \Bigl( \tan(m^2 e + m^2 y) . m^2 \frac{\partial y}{\partial x} \Bigr) \Bigl( \frac{K_i}{m} z (\tan(m^2 b(x) + m^2 y) \Bigr) \\ \qquad{}- \frac{K_i}{m \tau} \Bigl( \tan(m^2 b(t) + m^2 y) . m^2 \frac{\partial b(t)}{\partial x} \Bigr) \Bigl( \frac{\partial y}{\partial x} z \frac{K_i}{m} \tan(m^2 b(x) + m^2 y) \Bigr) \\[2\jot] %% \frac{K_i}{m} \Bigl[ \frac{\partial^2 y}{\partial^2 x} z \cot(m^2 e + m^2 y) + \frac{\partial y}{\partial x} \cot(m^2 e + m^2 y) \frac{\partial z}{\partial x} \\ \qquad{}- \frac{\partial y}{\partial x} z \tan(m^2(e + y)) m^2 \frac{\partial y}{\partial x} \Bigr] \times \frac{K_i}{m} z \tan(m^2 b(x) + m^2 y) \\ \qquad{}- \frac{\partial y}{\partial x} z \frac{K_i}{m} \tan(m^2 e + m^2 y) . m^2 \frac{\partial b(t)}{\partial x} \times \frac{\partial y}{\partial x} z \frac{K_i}{m} \tan(m^2 b(x) + m^2 y) \end{bmatrix*} \end{multline} %%% alternative version \bigskip Put u=\begin{pmatrix} u_1 & u_2 & u_3 \end{pmatrix}', where \begin{align*} u_1 &= \frac{K_i ^2}{m^2} \biggl[ \begin{aligned}[t] &- \Bigl( \frac{\partial z }{\partial x} \tan(mm^2 e + mm^2 y) + z \cot(m^2 e + m^2 y) . m^2 \frac{\partial y}{\partial x} \Bigr) \times z (\cot(m^2 b(x) + m^2 y) \\ % is there a surplus '(' char. on this line? &+ \Bigl( z \cot(m^2 e + m^2 y) . m^2 \frac{\partial b(t)} {\partial x} \Bigr) \Bigl( \frac{\partial y}{\partial x} z (\cot(m^2 b(x) + m^2 y) \Bigr) \\ &+ \Bigl( \frac{\partial z }{\partial x} \cot(m^2 e + m^2 y) - z \tan(m^2 e + m^2 y) . m^2 \frac{\partial y}{\partial x} \Bigr) \times z (\tan(m^2 b(x) + m^2 y) \\ % is there a surplus '(' char. on this line? &- \Bigl( z \tan(m^2 e + m^2 y) . m^2 \frac{\partial b(t)} {\partial x} \Bigr) \Bigl( \frac{\partial y}{\partial x} z (\tan(m^2 b(x) + m^2 y) \Bigr) \biggr] \end{aligned} \\[2\jot] u_2 &= \frac{K_i}{m \tau} \biggl[ {}\cdots{} \biggr] \\[2\jot] u_3 &= \frac{K_i}{m} \biggl[ {}\cdots{} \biggr] \end{align*} \end{document}  • Thank you @Mico for the detailed response. – Tee Commented Jun 25, 2022 at 21:12 • My Figures do not stay in my desired location without the float package. Please, how do I solve that problem? @Mico %\usepackage{float} % please try to make do without '[H]' position specifier – Tee Commented Jun 29, 2022 at 14:50 • @Tee - The serious problem with the H positioning specifier is that if a float is too large to fit on the current page, the result is a serious large blocks of whitespace at the bottom of that page. If you believe you can't trust LaTeX's own placement argument, then use ht ("either here or at the top of the next page"), but don't use H, please. – Mico Commented Jun 29, 2022 at 15:12 • Thank you @Mico – Tee Commented Jul 8, 2022 at 6:08 Here is a way to have a more readable matrix and a simpler code with the cellspace and mathtools packages, using systematically \dfrac. Furthermore, the esdiff package simplifies the typing of partial derivatives and ensures the result is in \displaystyle. \documentclass{article} \usepackage{mathtools} \usepackage{esdiff} \usepackage[math]{cellspace} \setlength{\cellspacetoplimit}{2ex} \setlength{\cellspacebottomlimit}{2ex} \begin{document} \[ \begin{bmatrix*}[r] - \dfrac{K_i ^2}{m^2} \biggl( \diffp{z}{x} \tan(mm^2 e + mm^2 y) + z \cot(m^2 e + m^2 y) . m^2 \diffp{y}{x} \biggr) \\ {}\times z (\cot(m^2 b(x) + m^2 y) +\cdots \\ \biggl( \dfrac{K_i}{m} z \cot(m^2 e + m^2 y) \cdot m^2 \diffp{b(t)}{x} \biggr) \biggl( \diffp{y}{x} z \dfrac{K_i}{m} (\cot(m^2 b(x) + m^2 y) \biggr)\\ %% - \dfrac{K_i}{m \tau} \left( \cot(m^2 e + m^2 y) \cdot m^2 \diffp{y}{x} \right) \left( \dfrac{K_i}{m} z (\cot(m^2 b(x) + m^2 y) \right)\cdots \\ + \dfrac{K_i}{m \tau} \left( \cot(m^2 b(t) + m^2 y) . m^2 \diffp{b(t)}{x} \right) \left( \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 b(x) + m^2 y) \right) \\ %%%x} z \tan(m^2 e + m^2 y) + \diffp{y}{x} \tan(m^2 e + m^2 y) \diffp{z}{x} \cdots \\ + \diffp{y}{x} z \cot(m^2(e + y)) m^2 \diffp{y}{x} \biggr) \times \dfrac{K_i}{m} z \cot(m^2 b(x) + m^2 y) \c \dfrac{K_i}{m} \biggl( \diffp[2]{y}{dots \\ - \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 e + m^2 y) . m^2 \diffp{b(t)}{x} \times \diffp{y}{x} z \dfrac{K_i}{m} \cot(m^2 b(x) + m^2 y) \end{bmatrix*}