# Inline mathmode goes out the page margin in LyX

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.

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

-
it looks like this particular expression is pretty long; I know this doesn't answer your question, but have you considered displaying it instead, perhaps using align? –  cmhughes May 9 '12 at 18:22
Inline math can only be broken at relation signs. So you have to rewrite your sentences or what @cmhughes and I recommend: Use align. –  Marco Daniel May 9 '12 at 18:40
As @MarcoDaniel says, TeX has a hard time with this paragraph, where only a few feasible break points are present: in the second line only three and the unbreakable parts are very long. So a display seems the best solution: your readers will be grateful. It would be better to write \mathit{vec} rather than vec or maybe \mathrm{vec} if it's an operator; better yet, \operatorname{vec} (with the amsmath package). –  egreg May 9 '12 at 21:20
@egreg: Thanks for your nice suggestions. Would you mind to give an example of \operatorname{vec} (with the amsmath package). I'm using LyX. Thanks –  MYaseen208 May 9 '12 at 21:24
@MYaseen208 Look in the site for operatorname: there is plenty of examples. –  egreg May 9 '12 at 21:26

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:

\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}

-
Thanks a lot @David for your answer. I also add the LaTex code that I'm using. –  MYaseen208 May 9 '12 at 21:12
Great. This works like a charm. Much appreciated. –  MYaseen208 May 9 '12 at 21:17
Note you should not just use vec for vec as TeX will set that as the product v e c You should use specific markup for operators like \log or here vec. –  David Carlisle May 9 '12 at 21:20