Math & ScienceEmbdedded formula running off page

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
elo96
Posts: 2
Joined: Tue Mar 16, 2010 6:40 pm

Embdedded formula running off page

Post by elo96 »

Hello,

I've inserted an embedded formula into a latex document as below:

Code: Select all

Say we have a dataset of $n$ observations in the form of a $p$-dimensional feature
vector: $x_i=\left( x_{i1}, x_{i2}, x_{i3}, \ldots , x_{ip} \right)$
However, rather than start the equation on the next line, the equation is running off the page. Is there a setting that I could change to get the equation to behave in the same way that a long word would?
I'm using the amsmath package.

Cheers,
Matt

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Embdedded formula running off page

Post by phi »

Hello,

first of all, don't use \left(...\right) in inline formulas, they prevent line breaking and can be extended arbitrarily, which is sometimes ok or even desired in displayed equations, but looks horrible in inline ones. Then you should place words like "-dimensional" outside of math mode. Additionally you can insert valid breakpoints with \allowbreak (breaks after binary and relational operators are permitted by default):

Code: Select all

\documentclass{minimal}

\begin{document}

\parbox{15mm}{% requires lots of line breaks
  Say we have a dataset of $n$ observations in the form of a
  $p$-dimensional feature vector: $x_i= ( x_{i1},
    x_{i2}, \allowbreak x_{i3}, \ldots, x_{ip} )$
}

\end{document}
You might consider converting complex inline formulas like the definition of the feature vector to displayed equations.
elo96
Posts: 2
Joined: Tue Mar 16, 2010 6:40 pm

Re: Embdedded formula running off page

Post by elo96 »

Thanks for that. I think that the neatest way to do what I'm trying to do is simply to use display equation. Thanks also for the other tips.

Cheers,
Matt
Post Reply