[Tex/LaTex] Inline mathmode goes out the page margin in LyX

lyxmath-mode

I'm using LyX for my document writing. Some of my inline mathmode formulas go out the page margin (see attached fig). I wonder how can I force these formulas to stay inside the page margin. Thanks in advance for your help and time.

enter image description here

Edit Code

where $vec\left(\mathbf{Y}\right)=vec\left(\begin{bmatrix}\mathbf{y}^{\left(1\right)} & \ldots & \mathbf{y}^{\left(j\right)} & \ldots & \mathbf{y}^{\left(t\right)}\end{bmatrix}\right)\equiv\mathbf{y}^{*}$;
$\mathbf{I}\otimes\mathbf{X}\equiv\mathbf{X}^{*}$; $vec\left(\mathbf{B}\right)=vec\left(\begin{bmatrix}\boldsymbol{\beta}^{\left(1\right)} & \ldots & \boldsymbol{\beta}^{\left(j\right)} & \ldots & \boldsymbol{\beta}^{\left(t\right)}\end{bmatrix}\right)\equiv\mathrm{\bm{\beta}}^{*}$;
$\mathbf{I}\otimes\mathbf{Z}\equiv\mathbf{Z}^{*}$; $vec\left(\mathbf{U}\right)=vec\left(\begin{bmatrix}\mathbf{u}^{\left(1\right)} & \ldots & \mathbf{u}^{\left(j\right)} & \ldots & \mathbf{u}^{\left(t\right)}\end{bmatrix}\right)\equiv\mathbf{u}^{*}$;
and $vec\left(\mathbf{E}\right)=vec\left(\begin{bmatrix}\mathbf{e}^{\left(1\right)} & \ldots & \mathbf{e}^{\left(j\right)} & \ldots & \mathbf{e}^{\left(t\right)}\end{bmatrix}\right)\equiv\mathbf{e}^{*}$.
Thus the univariate linear mixed model involving all variables can
be obtained from multivariate linear mixed model

Best Answer

The ; and and are really part of the sentence structure, not the mathematics,so TeX can do a better job if you code this as a sentence with multiple inline fragments. Also it still is hard so I have used \sloppy to tell LaTeX to allow white space to stretch more than usual. It still looks pretty hard to read and I would definitely consider setting this as a display using an AMS alignment, but to get it inline:

enter image description here

\documentclass{article}

\renewcommand\vec[1]{\mathop{\mathrm{vec}}(#1)}

\begin{document}
\large

where $
\vec{\mathbf{Y}} = 
\vec{[\mathbf{y}^{1} \ldots \mathbf{y}^{j} \ldots \mathbf{y}^{t}]}
\cong
\mathbf{y}^*;
\mathbf{I}\otimes\mathbf{X}\cong\mathbf{X}^*;
\vec{\mathbf{B}} = 
\vec{[\beta^{1} \ldots \beta^{j} \ldots \beta^{t}]}
\cong
\beta^*;
\mathbf{I}\otimes\mathbf{Z}\cong\mathbf{Z}^*;
\vec{\mathbf{U}} = 
\vec{[\mathbf{u}^{1} \ldots \mathbf{u}^{j} \ldots \mathbf{u}^{t}]}
\cong
\mathbf{u}^*;
\mbox{ and }
\vec{\mathbf{E}} = 
\vec{[\mathbf{e}^{1} \ldots \mathbf{e}^{j} \ldots \mathbf{e}^{t}]}
\cong
\mathbf{e}^*;$
Thus the invariate linear mixed model involving all variables
can be obtained from multivariate linear mixed

\bigskip

{\sloppy where 
$\vec{\mathbf{Y}} = 
\vec{[\mathbf{y}^{1} \ldots \mathbf{y}^{j} \ldots \mathbf{y}^{t}]}
\cong
\mathbf{y}^*$;
$\mathbf{I}\otimes\mathbf{X}\cong\mathbf{X}^*;
\vec{\mathbf{B}} = 
\vec{[\beta^{1} \ldots \beta^{j} \ldots \beta^{t}]}
\cong
\beta^*$;
$\mathbf{I}\otimes\mathbf{Z}\cong\mathbf{Z}^*$;
$\vec{\mathbf{U}} = 
\vec{[\mathbf{u}^{1} \ldots \mathbf{u}^{j} \ldots \mathbf{u}^{t}]}
\cong
\mathbf{u}^*$;
 and 
$\vec{\mathbf{E}} = 
\vec{[\mathbf{e}^{1} \ldots \mathbf{e}^{j} \ldots \mathbf{e}^{t}]}
\cong
\mathbf{e}^*;$
Thus the invariate linear mixed model involving all variables
can be obtained from multivariate linear mixed\par}

\end{document}
Related Question