1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
8 \newcommand{\brmul}{\discretionary{\mbox{$\,\cdot$}}{}{}}
16 \paperfontsize default
23 \use_numerical_citations 0
24 \paperorientation portrait
27 \paragraph_separation indent
29 \quotes_language english
33 \paperpagestyle default
37 How to deal with underfull and overfull boxes
46 What are we talking about?
49 Like all wordprocessing software, LaTeX, and therefore LyX, will encounter
50 from time to time a situation where it is unable to divide text into lines
51 or divide the paper into pages in an aesthetic manner.
52 Unlike some other wordprocessors, LaTeX will complain about it, by printing
68 A third difference between LaTeX and some other word processors which is
69 perhaps less notable, but important nonetheless, is the fact that LaTeX
70 breaks lines in a more-than-average intelligent manner.
71 Specifically, if LaTeX encounters a problem in a certain line, it can rearrange
72 all lines leading up to it.
73 As a result, it is less likely that LaTeX will have problems breaking any
74 line after the second line of a given paragraph.
77 , its reaction to the first problem is not to create a line with enormous
78 white gaps but to create a line that sticks out of the margin.
81 Unfortunately, LyX doesn't have a very convenient mechanism to find the
82 places in the document where LaTeX thought there were problems of this
84 Thus you must use either of the following methods: choose
89 iew\SpecialChar \menuseparator
97 and search for the error messages, or, usually easier, choose
102 ile\SpecialChar \menuseparator
107 xport\SpecialChar \menuseparator
114 and use a terminal to run LaTeX directly, i.e.\SpecialChar ~
120 LaTeX will spew out mysterious error messages, among them the infamous
132 Always remember that these problems are
136 sensitive to font, font size, and page size.
137 Therefore if this is not the final version of the document, if at all possible,
139 The time to handle them is when your work has taken on its final form.
140 And don't worry about this too much.
141 It shouldn't take you more than a few minutes work per 10 pages to fix
142 even a complicated document.
145 Before using all the sophisticated techniques discussed here always remember
146 it might be easier to just change the formulation of the text a little.
147 Hey, don't give me that look! Cosi Fanni Tutti.
154 \begin_inset Quotes eld
158 \begin_inset Quotes erd
161 is an object that LaTeX tries to fill horizontally, typically a line.
163 \begin_inset Quotes eld
167 \begin_inset Quotes erd
170 when LaTeX cannot push all the things it wants to into the line.
171 The reason is typically a long word or a formula at the end which, if pushed
172 to the next line would make the line too spacey.
173 So LaTeX calls for help.
174 Here is where you step in.
177 Before you start, check if the complaint is for real.
178 LaTeX will sometimes complain about hardly noticeable problems.
179 If you cannot spot the problem immediately, one solution is as follows:
201 ayout\SpecialChar \menuseparator
218 Note that this will have other effects.
219 For example, all pictures will be replaced by empty rectangles in the output.
222 In most document classes (in particular the standard and AMS classes) this
223 will cause a small black box to be printed to the right of the problematic
225 If you cannot see the problem --- good for you.
226 Ignore it and move on to the next error.
227 Otherwise proceed reading.
240 The second easiest solution (after ignoring the problem) is being sloppy
247 The paragraph with the footnote mark, for example, if set like that.
248 Notice the extra wide space in this line! This is due to sloppily pushing
258 This is done by the LaTeX commands
271 To enter them, change to TeX mode (a.k.a Evil Red Text) --- use
276 nsert\SpecialChar \menuseparator
289 in the beginning of the paragraph and
296 Your lines will contain too much space, but at least they won't stick out
298 If you don't want to do that on a paragraph by paragraph basis, just put
305 in your preamble (use
310 ayout\SpecialChar \menuseparator
322 ayout\SpecialChar \menuseparator
333 section) or where you want the sloppy mode to start (use TeX mode).
346 , the default behavior.
347 Both commands take effect from the beginning of the paragraph (or part
348 thereof, if you have a display formula) where they are found.
361 If the problem is a long word which LaTeX cannot, or would not, hyphenate,
362 the simplest solution is to add a hyphenation mark where you think the
363 word should be broken.
369 nsert\SpecialChar \menuseparator
374 pecial Character\SpecialChar \menuseparator
375 Hyphenation\SpecialChar ~
383 If you want the word to be broken but do not want a hyphen to appear (for
384 example, you are breaking a URL
390 If you enter a URL, the easiest method is
395 nsert\SpecialChar \menuseparator
402 which in most LaTeX installations also takes care of breaking lines for
404 Note though that the LaTeX system in
408 is an exception and won't break URLs across lines, so if you plan to submit
409 your paper there, plan ahead.
412 ) you need to add the TeX command
428 nsert\SpecialChar \menuseparator
433 pecial Character\SpecialChar \menuseparator
440 ! This will force LaTeX to break in that point.
441 Usually, however, you would want to use
448 \begin_inset Formula $n$
455 , which only recommends to LaTeX to break the line there rather than forces
458 \begin_inset Formula $n$
461 is the level of recommendation, from 0 to 4, with
467 being the weakest (and usually what you want) and
473 the strongest, and equivalent to just
480 Using this method instead of simply
486 will mean that you'll have less work the
490 time you change font.
494 More about this can be found in
496 http://dont.really.go.there/this/
526 to/demonstrate/how/this/works
534 Formulas inside you text pose more of a problem as LaTeX is typically shy
535 of breaking formulas, and many authors consider breaking formulas across
553 Naturally, using the techniques there will only aggravate overfull hbox
558 The first option you should consider is probably to make the formula into
564 nsert\SpecialChar \menuseparator
569 \SpecialChar \menuseparator
578 If you want to keep the formula inline, you can try the
585 Notice that to create evil red text in math mode you don't need to select
586 it from a menu, it is activated automatically by the
592 sign and terminated by the
600 will not appear in red but don't worry about it.
601 In many cases it works inside formulas.
602 The main case where it doesn't is inside grouped parenthesis, by which
603 I mean parenthesis entered using the parenthesis button in the math panel
611 \SpecialChar \menuseparator
619 \SpecialChar \menuseparator
629 LaTeX will simply ignore
635 commands inside a grouped parenthesis.
639 I love long formulas in the middle of my text, like
640 \begin_inset Formula $\int1/(t\log t\log\log t\linebreak\log\log\log t)\, dt=\log\log\log\log x$
645 \begin_inset Formula $\log\left(\sin x+\cos x+\linebreak\tan x\right)$
648 the grouped parenthesis always makes my formulas stick to the right.
651 The solution is to replace them with regular parenthesis.
652 You would probably want to enlarge them, though.
653 To do that, just write
659 before each parenthesis.
666 is not big enough, just try
688 \begin_inset LatexCommand \ref{tbl:bigBigg}
693 \begin_inset Float table
702 <lyxtabular version="3" rows="5" columns="2">
704 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
705 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
721 \begin_inset Formula $([\{|\}])\langle\lfloor\lceil/\uparrow\Uparrow\Downarrow\downarrow\backslash\rceil\rfloor\rangle$
729 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
741 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
747 \begin_inset Formula $\big(\big[\big\{\big|\,\big\}\big]\big)\big\langle\big\lfloor\big\lceil\big/\big\uparrow\big\Uparrow\big\Downarrow\big\downarrow\big\backslash\big\rceil\big\rfloor\big\rangle$
755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
767 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
773 \begin_inset Formula $\Big(\Big[\Big\{\Big|\Big\}\Big]\Big)\Big\langle\Big\lfloor\Big\lceil\Big/\Big\uparrow\Big\Uparrow\Big\Downarrow\Big\downarrow\Big\backslash\Big\rceil\Big\rfloor\Big\rangle$
781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
793 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
799 \begin_inset Formula $\bigg(\bigg[\bigg\{\bigg|\bigg\}\bigg]\bigg)\bigg\langle\bigg\lfloor\bigg\lceil\bigg/\bigg\uparrow\bigg\Uparrow\bigg\Downarrow\bigg\downarrow\bigg\backslash\bigg\rceil\bigg\rfloor\bigg\rangle$
806 <row topline="true" bottomline="true">
807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
825 \begin_inset Formula $\Bigg(\Bigg[\Bigg\{\Bigg|\Bigg\}\Bigg]\Bigg)\Bigg\langle\Bigg\lfloor\Bigg\lceil\Bigg/\Bigg\uparrow\Bigg\Uparrow\Bigg\Downarrow\Bigg\downarrow\Bigg\backslash\Bigg\rceil\Bigg\rfloor\Bigg\rangle$
840 \begin_inset LatexCommand \label{tbl:bigBigg}
844 parenthesis and friends in various sizes.
851 \begin_inset LatexCommand \ref{tbl:bigBigg}
855 , one should be careful to distinguish between the symbols
856 \begin_inset Formula $\langle$
860 \begin_inset Formula $\rangle$
863 use for scalar product and bra-ket notation and the simple bigger/smaller
865 \begin_inset Formula $<>$
869 Not only are they different in appearance, TeX will also space them differently.
870 There is no GUI for entering the symbols
871 \begin_inset Formula $\langle$
875 \begin_inset Formula $\rangle$
878 , nor for the symbols
879 \begin_inset Formula $\lfloor$
883 \begin_inset Formula $\lceil$
887 \begin_inset Formula $\backslash$
891 \begin_inset Formula $\rceil$
895 \begin_inset Formula $\rfloor$
898 --- from the math panel you can only insert the grouped version, not the
900 \begin_inset Quotes eld
904 \begin_inset Quotes erd
908 I simply enter them using their TeX shortcuts and LyX understands and transform
909 s them to the appropriate characters automatically.
910 The shortcuts are, respectively,
964 If you use inverted parenthesis, as for example in the old-fashioned style
966 \begin_inset Formula $\left]0,1\right[$
969 , you need to tell LaTeX which is left and which is right in order for it
970 to get the spacing right.
971 You do that by replacing the various
996 will do the spacing correctly
1000 if you insert them as grouped parenthesis.
1001 If you have line-breaking problems with these constructs, and you converted
1002 them into non-grouped parenthesis, you will have to tweak the spacing yourself.
1003 This is explained in the
1007 , as of this writing in section 5.1.8,
1018 \begin_inset Formula $I=\bigl]0,1\bigr[$
1021 looks much better than
1022 \begin_inset Formula $I=\bigr]0,1\bigl[$
1027 \begin_inset Formula $=$
1031 \begin_inset Formula $]$
1034 are cramped together in the second example, which has the right and left
1051 construct for notations such as
1052 \begin_inset Formula $\mathbb{P}\bigl(X\bigm|Y\bigr)$
1058 There are corresponding constructs specific for
1059 \begin_inset Formula $|$
1062 signs --- the commands
1075 I cannot in honesty vouch for or against them.
1076 Check the documentation for the
1080 package which should come with your TeX distribution --- try e.g.
1083 /usr/share/texmf/doc/latex/amsmath/amsldoc.dvi
1085 --- where these things are thoroughly explained.
1091 Display formulas can also be too long, quite easily so in fact, and will
1097 There isn't much to do about it except transform them into multi-line equations.
1098 Multi-line equations are covered quite fully in the
1102 (as of writing this, in section 5.4).
1105 As in the case of inline equations, you might need to break parenthesis
1106 across lines and run into various problems.
1107 The simplest solution is to use the
1108 \begin_inset Quotes eld
1112 \begin_inset Quotes erd
1115 square at the bottom right corner of the parenthesis panel (remember to
1123 box if you are using LyX Qt), for example
1124 \begin_inset Formula \begin{eqnarray*}
1125 f(n) & = & \pi\left(\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+\dotsb\right.\\
1126 & & \left.\dotsb+\frac{n-2}{n-1}+\frac{n-1}{n}\right)\end{eqnarray*}
1130 But what if there were no fractions on the bottom line? The parenthesis
1131 would come out too small.
1132 Obviously, one could solve this using the
1152 But there is another solution, using the
1159 Let us demonstrate with an example
1160 \begin_inset Formula \begin{align*}
1161 & \left(\sum_{i=1}^{\infty}\textrm{The parenthesis on this line are large due to the }\sum\textrm{ sign,}\right.\\
1162 & \left.\textrm{so lets add here a vphantom command with the same construct}\vphantom{\sum_{i=1}^{\infty}}\right).\end{align*}
1166 For those reading the printed version, the lower line has a
1173 \begin_inset Formula ${\displaystyle \sum_{i=1}^{\infty}}$
1180 which doesn't appear at all, but makes the parenthesis large.
1181 You can put anything you want inside the
1185 signs --- whatever you put does not show but its height is considered when
1186 the line height is calculated.
1189 There is nothing stopping you from using the
1195 trick on inline formulas, but it really more suitable for using in large,
1196 complicated display formulas.
1202 There are a number of issues you might want to know about if you have hyphenatio
1204 First of all, hyphenation is language sensitive.
1205 Really! You can change the default language of the document via the
1215 ayout\SpecialChar \menuseparator
1222 popup, or you can change a particular piece of text via the
1227 ayout\SpecialChar \menuseparator
1235 A typical LaTeX installation will support hyphenation in English, French,
1236 German, Spanish, Russian and a few others.
1239 The second thing you have to know is that there is a package to help with
1240 hyphenation problems:
1245 The most popular uses of
1249 are to turn hyphenation off completely, or to allow hyphenation of text
1260 By default, any text in typewriter font is never hyphenated.
1261 URLs are only a specific case.
1264 and it has some advanced tools in addition.
1265 More likely than not, it is a part of your LaTeX distribution.
1266 Read the documentation, it could be in, for example,
1268 /usr/share/texmf/doc/latex/styles/hyphenat.dvi
1273 Finally, there are special cases where you want special effects when the
1274 line is broken --- not just any old hyphen.
1275 For these unusual cases, you need the
1282 Since this is a bit off topic, I've put the full description in an appendix.
1287 \begin_inset LatexCommand \label{ssec:agrevate}
1291 More on breaking inline formulas
1294 LaTeX (and TeX) will break inline formulas around equality-like signs, e.g.\SpecialChar ~
1296 \begin_inset Formula $=$
1300 \begin_inset Formula $\approx$
1304 \begin_inset Formula $\leq$
1307 etc., and less willingly around binary operators like
1308 \begin_inset Formula $+$
1312 \begin_inset Formula $\cdot$
1316 \begin_inset Formula $\wedge$
1320 To make LaTeX less or more likely to break formulas in that way, do the
1321 following: in the latex preamble add the following commands:
1327 \begin_inset Formula $n$
1336 \begin_inset Formula $m$
1343 \begin_inset Formula $n$
1347 \begin_inset Formula $m$
1350 are two numbers that tell LaTeX how bad is it to break formulas around
1351 equality-like signs and binary operators respectively.
1352 The default values (for both TeX and LaTeX) are 500 and 700.
1353 The value 10000 is used as
1354 \begin_inset Formula $\infty$
1357 so if you set either to 10000 TeX will never break your formulas in that
1364 These are quite rare, but can happen, e.g.\SpecialChar ~
1365 when you use forced linebreaks.
1369 Wow, why is this line like that?
1379 Oh, because I asked so explicitly.
1383 Similarly, the use of
1397 A vbox is something that LaTeX tries to fill vertically, typically a page.
1398 For some unknown reason, when LaTeX cannot fill the page because the last
1399 object is too large, it will not do as it does for lines and go over the
1400 margins, but it will prefer to put the offending object on the next page.
1401 Hence the error will usually be
1405 and the visible symptom will be pages which are too short, have too much
1406 space between the text and the footnotes or that have too much space between
1407 paragraphs, formulas etc.
1410 The range of solutions to underfull vboxes is more restricted.
1411 Most notably it is to tell LaTeX where to break pages yourself.
1412 This is covered in the
1417 \begin_inset Quotes eld
1421 \begin_inset Quotes erd
1424 (as of the time of writing, this is subsection 6.4.4).
1425 Unfortunately, in many cases the offending object is a multi-line formula,
1426 and you cannot enter a pagebreak inside a formula using the
1431 ayout\SpecialChar \menuseparator
1439 A simple solution might be to break the formula into two formulas, possibly
1440 forcing a pagebreak between them, but actually there's a better way so
1444 It is possible to allow page breaks inside formulas, globally or on a formula-by
1446 To understand how, we first need to differentiate between LaTeX formula
1447 environment and AMS formula environments.
1448 The (regular) LaTeX formula environment are what you get when you hit
1452 inside a formula, or by choosing
1457 nsert\SpecialChar \menuseparator
1462 \SpecialChar \menuseparator
1467 qnarry\SpecialChar ~
1471 The AMS formula environment are supported in LyX using
1476 nsert\SpecialChar \menuseparator
1481 \SpecialChar \menuseparator
1486 Generally speaking the AMS environments are more flexible, provide nicer
1487 spacing and more options (see the AMS documentation already mentioned).
1488 The only real issue with using them are potential incompatibilities between
1489 the AMS package and the document class you might be using, which might
1490 be more common than you think, especially if you got the documentclass
1491 files from some European journal.
1492 All the documentclasses supported by LyX, however, are fully compatible
1493 with the AMS package, so you should worry about that only if you plan to
1494 export your document as LaTeX and do all the configuration work manually
1498 For the LaTeX formula environments you have only one option, to allow page
1499 breaks globally and completely.
1500 This is done by putting the command
1506 in your LaTeX preamble.
1507 For the AMS math environment you have the following options:
1523 \begin_inset Formula $n$
1530 in a specific formula in a specific position where you allow the page to
1533 \begin_inset Formula $n$
1546 You can allow page breaks in all AMS equation environments globally.
1554 \begin_inset Formula $n$
1561 in your preamble where the parameter of permissiveness
1562 \begin_inset Formula $n$
1565 is between 1 (not 0!) and 4.
1570 allowdisplaybreaks[4]
1578 and will affect the LaTeX math environments too.
1581 See some examples in appendix
1582 \begin_inset LatexCommand \ref{sec:Page-break-examples}
1592 If you have any comments about this document I would love to hear them.
1593 I am especially interested in new LaTeX tips and tricks! There always seem
1597 gadykozma@hotmail.com
1602 This document is in the public domain.
1603 Please do with it as you please.
1606 The discretionary command
1609 The discretionary command takes three arguments, i.e.\SpecialChar ~
1610 its general format is
1636 The third argument is the text to put in the usual case, namely the line
1637 is not broken there.
1638 The first and second are for breaking lines, and appear in the end of the
1639 first line and the beginning of the second.
1640 Thus the usual hyphenation point is equivalent to
1644 discretionary{-}{}{}
1652 command is equivalent to
1656 discretionary{k-}{k}{ck}
1659 That's right, in German, sometimes when you break a ck across lines you
1660 want the broken text to be k-k.
1666 I don't know the first thing about German, so all this should be taken with
1673 Here is a particularly freaky example.
1674 In the preamble, define the following:
1694 Next, add a formula like that
1695 \begin_inset Formula $f(x)=x\log x\brmul\log\log x$
1698 (if you are reading the printed version, there is a
1705 \begin_inset Formula $\log x$
1709 \begin_inset Formula $\log\log x$
1712 ) and play around with the surrounding text to force it to break between
1714 \begin_inset Formula $\log x$
1718 \begin_inset Formula $\log\log x$
1725 When using, inside the line, long formulas like
1726 \begin_inset Formula $f(x)=x\log x\brmul\log\log x$
1729 , strange things could happen.
1732 VoilĂ ! A multiplication sign (
1739 \begin_inset Quotes eld
1743 \begin_inset Formula $\cdot$
1747 \begin_inset Quotes erd
1762 gives the standard space before the multiplication sign.
1773 signs? Weird LaTeX working mode issues.
1774 Don't ask me, I only fiddle until it works.
1777 ) appears in the middle of the formula.
1782 \begin_inset LatexCommand \label{sec:Page-break-examples}
1790 \begin_inset Formula \begin{align*}
1791 \textrm{Gauss number} & =1+2+3+4+5+6+7+8+9+10\\
1792 & +11+12+13+14+15+16+17+18+19+20\\
1793 & +21+22+23+24+25+26+27+28+29+30\\
1794 & \textrm{this line contains a }\mathtt{{displaybreak[3]}}\textrm{ command}\displaybreak[3]\\
1795 & \textrm{as you can see, in such a bad position it is not enough to force}\\
1796 & \textrm{a break.}\\
1797 & \textrm{this line contains a }\mathtt{{displaybreak}}\textrm{ command}\displaybreak\\
1798 & \textrm{as you can see, this command is absolute.}\\
1799 & +31+32+33+34+35+36+37+38+39+40\\
1800 & +\dotsb+100=5050\end{align*}