When I compile my document in LaTeX, some formulas in the document in math mode, between $ $, go into the right margin area beyond all the text. Is there a way to fix this aesthetic problem?
|
|
||||
|
|
migrated from stackoverflow.com Sep 18 '11 at 17:09
|
LaTeX can break lines within inline formulas, however it does it only at certain places. You could insert If you would like to allow line breaks within inline math formulas at certain symbols, such as commas for example, here's a solution: Allowing line break at ',' in inline math mode. Generally, when I notice a line breaking problem with inline math because it's long, I would consider making a displayed formula of it, using |
|||||
|
|
As you've noticed (to your chagrin!), TeX (and LaTeX) won't break an inline math expression just anywhere. Favored breakpoints are equal signs and binary relation signs (such as pluses and minuses). You'll have to look at your code and decide if you could (i) break up some longer formulas into smaller parts and/or (ii) set them in display-math format on a separate line. The latter method may be especially beneficial if the formulas in question are quite long, say, longer than about one third of the line length. To place a formula on a separate line, you have several options. The oldest method, noted by Knuth in the TeXbook, is to enclose the formula in question in double-dollar ( The reason I like option (b) is that it very clearly draws attention to itself, making it much less likely (at least for me!) that the formula in question ends up in display mode by accident. In addition, should you decide you want to change the equation from an unnumbered to a numbered form, it's trivially easy to just remove the asterisks from the |
|||||||||||||
|
|
If you are fine with equations being on lines of their own and you want to automate line breaking in a semi-sane way, then check out the breqn package. It provides for example the dmath environment which is fairly clever when it comes to automatically splitting an equation across lines. For example:
will be split across lines with nice indenting from the second line onwards. Beware that the breqn package tends to break other packages, so read the documentation. |
|||
|
|
|
You have three options, two thereof have been mentioned already:
|
|||
|
|
