Bonobo Conspiracy's Quick Guide to the LaTeX \linebreak command

16 July 2009
Tags for this page: 200907 howto latex
[Site traffic Strip-O-Meter]

Click to censor the Strip-O-Meter.

Okay, one more time. This is Donald E. Knuth:

[Donald E. Knuth]

You are not smarter than this man.

This is Leslie Lamport:

[Leslie Lamport]

You're not smarter than him either.

So leave the \linebreak command alone, dammit!

Any questions?

Comments

Luk from 98.232.16.17 at Fri, 17 Jul 2009 06:54:18 +0000:
Could you explain this?

Matt from 67.158.68.132 at Fri, 17 Jul 2009 12:42:50 +0000:
Knuth and Lamport are credited as the creators of TeX and LaTeX respectively. (Both systems are now too big to *really* be the work of single individuals - it's a similar situation to Torvalds and Linux.) They're also each famous for multiple other achievements in computer science. TeX and LaTeX are used to typeset scientific documents.

One common issue in typesetting is how to break paragraphs into lines. It's complicated because, for instance, you're allowed to hyphenate words if one won't fit well on a line, but that's not as good as keeping words whole, and you can stretch or shrink spaces but you don't want to do that too much, and so on. TeX/LaTeX implements a sophisticated algorithm for determining how to do line breaks.

It still isn't perfect. Sometimes it fails and you end up with words that it can't break sticking out into the right margin. At that point, there are several different things you can do. You can insert hints (for instance with the \- optional-hyphen command) that tell the system about places it wouldn't otherwise recognize but where it could insert a line break if necessary. You can rewrite your text to make it break more naturally. You can tell the system to bend the rules and make breaking decisions it would normally consider unacceptably unbalanced. Or you can use \linebreak, which FORCES a line break to occur at a given point whether it looks good or not. That last is almost always the wrong thing to do; for one thing, even if you put the \linebreak in a place that looks good right when you do it, it makes your text very fragile. If you do any rewriting later, or change the margins, you end up with a line break being forced in a place where it doesn't look good and TeX can't compensate because you overrode it. Inserting non-binding hints is much better - then the system can use them if necessary, but won't be forced to use them when they're inapplicable.

Volker from 78.50.244.205 at Sun, 16 Aug 2009 18:31:03 +0000:
I don't know about Lamport, I regard LaTeX as a bit of a foul-up... but TeX's line breaking is by Knuth, so he's the guy who matters here.

Forced line breaks are a bad idea except (perhaps) as a last resort. Use penalties instead to influence line breaking in a controlled way. They are the only way to write macros that work generally, as opposed to one-time kludges. To learn about them, buy Knuth's TeXbook, or download Victor Eijkhout's TeX by topic (http://eijkhout.net/texbytopic/texbytopic.html), which is less fun to read but equally informative.

Add Comment

Your name (required):
Your email address or URL (optional):
Type "bonobo" for anti-spam purposes:

Do not enter a fake email address. If you don't want to provide one, just leave it blank. Comments with fake email addresses will be deleted.

This form is for posting public comments to be read by other people who visit this Web site. If you have a software support question, or other material directed to the page author instead of to the general public, please send email instead.

All the data you enter, and your IP address, will be saved and displayed. Don't enter secret information. HTML is not accepted; it will be displayed as plain text. Your comment will only be added if you enter valid data in all required fields; if it isn't, use the back button and try again.

I, and I alone, reserve the right to remove postings for any reason.

Copyright 2009 Matthew Skala
Updates to this site: [RSS syndication file]