Math & ScienceHow to split a formula, automatically?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
gvanas
Posts: 7
Joined: Thu Jul 16, 2009 11:39 am

How to split a formula, automatically?

Post by gvanas »

Hi,

I was wondering if LaTeX could split long formulas automatically, based on invisible splitting points (or hints), in a way similar to hyphenation.

For example, assume you have a large equation that is likely to fit on one line but must be split into two parts if two columns are used. Or maybe someone else (e.g., the editor of a journal) can potentially change the font of your article after you submit it and make the formula suddenly too wide.

MathML specifies hints to help the renderer decide where to split a long formula appropriately. The same long formula can thus appear consistently on various combinations of page/screen widths and font sizes.

So, is there a way to have LaTeX automatically handle long formula (maybe with the help of a special package or external utility)? Has someone else been looking for the same thing before?

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

How to split a formula, automatically?

Post by php1ic »

The split environment defined by the amsmath package does what you want.

Code: Select all

\begin{equation}
\begin{split}
f(x) = a_5x^5 + a_4x^4 +a_3x^3\\
+ a_2x^2 + a_1x +a_0
\end{split}
\end{equation}
Although you do have to define the break point manually, and it sounds like you want latex to do it automatically.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: How to split a formula, automatically?

Post by frabjous »

I've definitely looked for something like this, but I haven't found it either.

I guess it shows one of the differences between MathML and TeX. Since for the former is designed largely for dynamic displays like webpages, where the user may resize at will, and TeX is designed for print, where resizing won't take place after the fact, so you are encouraged (forced?) to hand-control exactly how you want it to look.

Times are changing though. One day we all might be reading on hand-held devices where the user may want to change font size/margins, etc., him/herself (such as we already have with the Kindle, Nook and Sony Reader, etc.), and if these are going to be used for technical material, hopefully (La)TeX will evolve along with the technology.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to split a formula, automatically?

Post by gmedina »

Hi gvanas,

perhaps the breqn package could be of interest for you.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
gvanas
Posts: 7
Joined: Thu Jul 16, 2009 11:39 am

How to split a formula, automatically?

Post by gvanas »

Thanks to all for the quick responses. Some comments:
perhaps the breqn package could be of interest for you
Yes, indeed, thanks! I wasn't aware of that package and it seems to be in line with what I am looking for. It definitely looks worth trying it out.
I guess it shows one of the differences between MathML and TeX. Since for the former is designed largely for dynamic displays like webpages, where the user may resize at will, and TeX is designed for print, where resizing won't take place after the fact, so you are encouraged (forced?) to hand-control exactly how you want it to look.

Times are changing though. One day we all might be reading on hand-held devices where the user may want to change font size/margins, etc., him/herself (such as we already have with the Kindle, Nook and Sony Reader, etc.), and if these are going to be used for technical material, hopefully (La)TeX will evolve along with the technology.
Yes. As time goes, more and more publications will be available both online on the web and in PDF for printing. Therefore more interchanges will be needed between (La)TeX and MathML.
Post Reply