This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Open Source

Designing a book with LyX

By Corinne McKay and Daniel J. Urist on August 24, 2006 (8:00:00 AM)

Share    Print    Comments   

Self-publishing is becoming easier and cheaper, thanks in part to improved printing technologies and desktop publishing tools. If you've ever considered writing a book, you may have looked at the layout capabilities of OpenOffice.org Writer, AbiWord, KWrite, or other word processing programs. While these tools can produce adequate results for many types of documents, it's also worth considering LyX, an open source (GPL) desktop publishing application that, with a bit of work, can create a really professional-looking book that is indistinguishable from a book produced by a mainstream publishing house.

When we began looking for an application to design Corinne's book How to Succeed as a Freelance Translator (Lulu Press, 2006), we road-tested a few pieces of software, including the word processors referenced above. The problem? Although features such as Writer's PDF export are easy to use and produce clean, easy-to-read documents, there was something subtly missing from the design; something that didn't quite look "like a book." It's not that Writer can't be made to produce a high-quality book layout, but the conventions of book design are extremely subtle and tricky to master, at least for those of us who are not professional book designers or typographers. So, we turned to LyX. Our system is Debian Linux, but LyX is packaged and included in the repositories for most of the popular Linux distributions, so installation is a breeze. LyX is distributed under the GPL, and runs on Unix/Linux, Mac, and Windows operating systems.

LyX is "the first WYSIWYM (What You See Is What You Mean) document processor." When you start up LyX, the user interface has a look and feel similar to that of a word processor with a stripped down set of toolbars. It includes all the basic word processing functions, such as cut and paste, search and replace, undo, and spell checking. The idea behind LyX is that the user selects a document class, such as Article, Report, Book, Letter, or Slides, and LyX provides the structure. For example, a Book document allows you to identify any given piece of text as a Chapter, Section, Subsection, or Subsubsection, etc., and formats the document automatically according to the defined styles for the category, referred to as the paragraph environment, that the user selects. In effect, LyX enforces consistency throughout the document, without requiring (but while allowing) you to define the style to be used for each paragraph environment. This is especially useful in a book-length document, where consistency can be the difference between a book that looks like a book, and a book that looks like a bound word processing document.

Here's an example from LyX's own Web site: "Let's say you tell LyX that a certain line is a Section title. LaTeX adds the Section to your table of contents, places the Section name into your page header, gives it a special "bold" appearance on the page, assigns it a number or label, and tells other parts of your document what page it's on, for references and citations." LyX also enforces typographic rules by its behavior; for example, pressing the space bar over and over doesn't result in a series of blank spaces in the text, since LyX automatically inserts the correct number of spaces between different pieces of text.

LyX works its real magic when you select a PDF preview of the print-ready document from the View menu. After a small delay, the on-screen document is transformed into a PDF that looks, well, exactly like a book!

The workhorse behind the magic of LyX is Donald Knuth's legendary typesetting system, TeX, and the LaTeX document preparation system built on top of TeX. LaTeX provides the structured document classes and functions, such as indexing, page numbering, cross-references, and bibliographies; the underlying TeX typesetting engine incorporates intelligent algorithms for tasks such as hyphenation, paragraph breaking, and line breaking, which are largely responsible for the "like a book" look of documents produced by LyX.

Creating a book in LyX

There are several document classes available for LyX that are suitable for typesetting a book, including the default Book class, the KOMA-script Book class (scrbook), and the Memoir class. The default Book class is fairly minimal in terms of features. Most notably it lacks paragraph environments for standard front matter and end matter sections, such as Acknowledgments, Publishers, Dedication, etc., with no built-in fine controls for these features. However, you can insert LaTeX code directly into a LyX document to create these sections. Such code is referred to as ERT (for Evil Red Text).

KOMA-Script, a mature (in active development since 1994) set of replacement classes for the standard LaTeX classes, provides the scrbook class, which is an excellent option for LyX users, and the one we chose for our project. KOMA-Script's original purpose was to provide alternative LaTeX classes for German documents, but it is now used by authors in a variety of languages.

KOMA-Script's scrbook class offers a comprehensive set of paragraph environments. For example, the Uppertitleback and Lowertitleback environments allow you to format the upper and lower sections of text that appear on the back side of the book's title page, which are normally the copyright and cataloging-in-publication data (the book's ISBN number and Library of Congress cataloging information) and any disclaimers, sales information, author contact information, and so on. If you fail to specify a paragraph environment for a section, scrbook provides useful generic sections. For example, we wanted How to Succeed as a Freelance Translator to include a Colophon, emphasizing the fact that the book was written and designed using free and open source software exclusively. To accomplish this, we used the Addsec* paragraph environment to add a generic section (the * indicates that the section will not appear in the table of contents).

A notable feature of scrbook is that it produces books laid out using European typographic conventions. That means the book's lower margin is twice the height of the upper margin, and the inner margin on each page is half the width of the outer margin. While this produces a classic and elegant finished layout, our publisher (Lulu Press; Global Distribution) required equal top and bottom margins and equal side margins, which required us to change scrbook's default settings. You can do this within the scrbook package by using LaTeX commands, but LyX makes it easy to bypass scrbook's layout engine and change the margins using the Document -> Settings -> Page Margins menu.

The KOMA-Script manual, weighing in at 227 pages and available in English and German, is not only a comprehensive guide to the KOMA-Script package, but an excellent overview of typographical conventions and principles. Its dedication "To All Friends of Typography!" speaks for itself; this manual is a must-read for the novice book designer. The sections on typography are worth reading even if you do not intend to use KOMA-Script.

The Memoir class offers another book layout option, with 307 pages of beautifully typeset manual to go with it. The Memoir User Guide, written by the Memoir class's developer Peter Wilson, contains a thorough introduction to typography (another worthwhile resource for the novice book designer), including a section on designing electronic books. The Memoir class is now production-grade, and is in active development. In terms of functionality, Memoir appears to be comparable with scrbook, although it relies more on external LaTeX packages; for example, scrbook includes its own header package, whereas Memoir must use a separate header package such as fancyhdr.

In addition to its primary function of typesetting, LyX provides a number of helpful features for the self-publisher. For instance, it generates a Table of Contents automatically. In researching the market for nonfiction books, we learned that having an index greatly adds to the saleability of a nonfiction book; in fact, many libraries are reluctant to purchase nonfiction books that do not have indexes. Since hiring a professional indexer was out of our budget, we turned to LyX's indexing feature, which proved itself more than equal to the task. When you position the cursor at the end of the word that you want to index and select Insert -> Index Entry, a dialog box will pop up, with the word automatically inserted in the Keyword field. You can either keep the pre-inserted word or edit it. The edit can take the form of a minor change, such as case, or you can change the word to an entirely different one; for example, you could associate the word "interview" with the index entry "job search." You can also create a nested index entry by typing an exclamation point after the parent term, then typing a sub-term directly after it. For example, "travel!Asia" would result in the parent index entry "travel" and the sub-term "Asia." You can insert as many index tags after a word as you want. True to its typographic genius, LyX (actually LaTeX) is smart enough to notice when you insert index tags for the same term on consecutive pages, and will create an appropriate index entry -- for example, "travel, 47--50."

LyX also has excellent support for tables. In fact, using tables in LyX is similar to using tables in HTML. To insert a table, select Insert -> Table, and the efficiently designed Insert Table dialog box will pop up and allow you to select the number of rows and columns that you want in the table. Then, by right-clicking in the table, you can bring up the Table Settings dialog box, where you can adjust the table's size, orientation, borders, and so on. To change the font of the text in your table, highlight the portion of the table containing the text to be changed and select Edit -> Text Style. We used tables for a Glossary (there is also a LaTeX package for compiling a glossary) and various worksheets, such as Billable Hours and Hourly Rate charts.

LyX's features could be the basis of an article in themselves, but it's worth noting that the software includes a math editor; support for most European languages and right-to-left languages, including documents that contain more than one language; support for footnotes and margin notes; comprehensive bibliography support; and figure support with rotation, scaling, and captions. There are many more features that are relevant to other document classes, such as academic journal articles.

Customization in LyX

One of the differences between LyX and a traditional word processor is LyX's approach to formatting. Most word processing programs allow regions of text to be tagged with a style. In LyX, every piece of text belongs to a paragraph environment that has a predefined style. For example, someone using OpenOffice.org Writer can choose to use the style options offered by the software, such as Heading 1 or Text body. However, most word processor users do not employ styles, but instead do most of their formatting manually by using different fonts and effects. In LyX, it is not impossible to do manual formatting, but the program is set up to discourage this behavior by limiting manual formatting options.

You can perform some basic customization from the Document -> Settings dialog box. For example, you can change the default font for the document, the page size and margins, and the bullet styles. For finer control, you need to edit the LaTeX Preamble, which is also found in the Documents -> Settings dialog box. In the Preamble, you can add LaTeX commands to change the default behavior of the document class, including the settings for different paragraph environments, as well as include and configure additional LaTeX packages to add functionality.

While LaTeX code can be daunting, LaTeX's maturity, excellent documentation, widespread use, and great support through mailing lists and newsgroups means that a solution to most customization questions can be found with a quick Web search. But you may not need help; it is certainly possible to use a book class such as KOMA-Script or Memoir without altering any of the paragraph environments (we did this).

One thing we did want to change was the default header formatting. This involved loading and configuring the fancyhdr package in the Preamble. Fancyhdr gives very fine control of the header and footer formatting, including font and page numbering style. It allows you to do just about anything you've ever seen in a book header (small caps, a line under the header text, etc.).

Another extremely useful package is microtype, which provides subtle expansion of fonts in order to make lines of type fit better into the allotted space. This gives TeX more options for breaking lines, resulting in a more eye-pleasing end product and less manual fine-tuning of the finished text. Microtype works only with the View -> PDF(pdflatex) command option. Both of microtype and fancyhdr were included with the default Debian LaTeX installation, and there are many more useful packages available at CTAN.

Finishing touches

When you're done composing all of your text in LyX, you'll want to do a little cleanup on your document before sending it to press. Because TeX is a typesetting engine, it may occasionally fail to find a good place to break a line, resulting in a warning message and a line that extends into the margin. When this happens, your options are to rewrite the line so that TeX can find a good place to break it; manually force a break by using Insert -> Special Formatting -> Line Break; or allow TeX to insert extra spacing between words by using the command sloppypar. Aesthetically, the third option is considered the method of last resort, but you can use it by inserting an ERT code box with Insert -> TeX code, typing \begin{sloppypar} at the beginning of the paragraph, and inserting another code box containing \end{sloppypar} at the end.

In the same vein, TeX prefers not to leave blank space at the bottom of a page where a section ends. To avoid this, the software will insert extra spacing between paragraphs in order to stretch the text vertically to fill the page. We preferred to leave the blank space at the bottom, which we easily accomplished by using Insert -> Special Formatting -> Page Break below the section that did not fill the page.

Some publishers, including Lulu Press' Global Distribution option, require electronic files submitted in PDF format to be created with Adobe Distiller. This wasn't an option for us, but fortunately we could also upload the book in PostScript format. To do this, we created a PDF of the book using View -> PDF(pdflatex), which brings up a PDF version of the book in Adobe Reader. We then saved a copy of the PDF from Adobe Reader and converted that file to PostScript format using the command:

pdftops -level3 -paperw 432 -paperh 648 Book.pdf Book.ps

where Book.pdf is the PDF saved from Adobe Reader. In this command, the paper dimensions are given in points; the points in the example command correspond to a 6x9-inch book.

Conclusion

LyX is an excellent tool for authors at all levels of typographic knowledge and interest. If you're a first-time author who simply wants a great-looking book, LyX's default settings allow you to enter text as easily as with a word processor, and out pops a book that does not look self-published. For the typographically motivated (those who are self-publishing because they lament the decline in editorial and design standards at major publishing houses), LyX offers an almost infinite array of options to satisfy even the pickiest book designer's requirements. Above all, the LaTeX system encourages consistency, which, in a book-length document, is critical to a professional-looking end product. This is precisely where traditional word processors fall short, and is in itself a good reason to investigate LyX.

Corinne McKay is a freelance French to English translator and translation industry writer. Daniel J. Urist is a recovering Unix systems administrator. They, their daughter, and their one-eyed cat are based in Boulder, Colo.

Share    Print    Comments   

Comments

on Designing a book with LyX

Note: Comments are owned by the poster. We are not responsible for their content.

...or you could just use LaTeX

Posted by: Anonymous Coward on August 24, 2006 04:56 PM
I find the conveniences LyX offers are mostly for the things that are very easy to understand in raw LaTeX (click a few buttons to insert a section, instead of typing "\section"). Where LaTeX gets tricky is exactly where LyX can't help, and you have to resort to ERC anyway: e.g. your fancyhdr example.

Don't get me wrong: I think LyX is a very well designed piece of software, and is far better than other word processors, especially for long texts. But I find writing raw LaTeX in a text editor helps me concentrate more on the content and less on the formatting than using a WYSIWYM/G word processor, and encourages me to use the full power of LaTeX (like inserting index entries as I'm typing the text, instead of putting them in later).

Different people have different tastes, of course, but if you're thinking of trying out LyX, consider giving good ol' raw LaTeX a go too. You might be surprised by how difficult it isn't...

#

:...or you could just markup at the end.

Posted by: Anonymous Coward on August 24, 2006 08:10 PM
"Don't get me wrong<colon>:</colon> I think <noun>LyX</noun> is a <praise>very well designed piece of software</praise>, and is <fanboy>far better than other word processors</fanboy><comma>,</comma> especially for long texts. <sentence><capitalization>B</capitalization>ut I find writing raw LaTeX in a text editor helps me concentrate more on the content and less on the formatting than using a <acronym>WYSIWYM/G</acronym> word processor, and <verb>encourages</verb> me to use the <word>full</word> power of LaTeX (like inserting index entries as I'm <action>typing</action> the text, instead of putting them in later).</sentence>"

Hehe. Just poking fun at your "But I find writing raw LaTeX in a text editor helps me concentrate more on the content and less on the formatting than using a WYSIWYM/G word processor". Yes, Latex is a bit higher level than I've depicted, but it still can be a distraction when one is suppose to concentrate on the subject rather than "<section></section>".

#

Re::...or you could just markup at the end.

Posted by: Anonymous Coward on August 25, 2006 04:53 PM
:-D

You've demonstrated why I far prefer LaTeX's sytax over XML.

#

Re:...or you could just use LaTeX

Posted by: Anonymous Coward on August 25, 2006 01:10 AM
Yes, LaTeX is very nice, but then one day you get lazy and want to use more macros to speed up typing, then you switch to something evil. Emacs.

Then one day you are rescued from the darkside and start using LyX<nobr> <wbr></nobr>:-) Started with plain LaTeX, and moved to LyX when the first versions were out. I still use it, 10 years later, or what it can be.

I find the editing far superior of anything I've ever worked with, and let me just say that I've used all the good tools applixware, vim, ms word, etc. The input speed of formulas is incredible.

But as a LyX user, you still benefit a lot from knowing some LaTeX.
Use the tool you like best.

LyX and LaTeX will someday rule the world.

#

Checkout this excellent alternative: TeXmacs.

Posted by: Anonymous Coward on August 24, 2006 05:41 PM
Checkout this excellent alternative to Lyx:

<a href="http://www.texmacs.org/" title="texmacs.org">http://www.texmacs.org/</a texmacs.org>

GNU TeXmacs is a free wysiwyw (what you see is what you want) editing platform with special features for scientists. The software aims to provide a unified and user friendly framework for editing structured documents with different types of content (text, graphics, mathematics, interactive content, etc.).

Jade @ <a href="http://linux.coconia.net/" title="coconia.net">http://linux.coconia.net/</a coconia.net>

#

Does it show equations, figures, and tables?

Posted by: Anonymous Coward on August 26, 2006 05:15 AM
I don't think texmacs shows some sort of rendering for figures, tables, and equations, but I could be wrong.
LyX makes some attempt to render these on the fly...

#

Of course it does.

Posted by: Anonymous Coward on August 26, 2006 07:44 AM
Of course it does. It is based on TeX, as the name suggests.

#

Re:Checkout this excellent alternative: TeXmacs.

Posted by: Anonymous Coward on August 30, 2006 06:36 AM
Great; thanks for the excellent link; much better than Lyx!

#

KWord, not KWrite

Posted by: Anonymous Coward on August 24, 2006 05:47 PM
<a href="http://www.koffice.org/" title="koffice.org">KOffice</a koffice.org>'s word processor is called <a href="http://www.koffice.org/kword" title="koffice.org">KWord</a koffice.org>, not <a href="http://kate.kde.org/" title="kde.org">KWrite</a kde.org>, which is a text editor.

#

Looks good but is it good for unusual/complex DTP?

Posted by: Ian Christie on August 25, 2006 01:11 AM
LyX looks good, but is it beneficial in a straight typesetting situation, such as newspaper or magazine layout where the person doing the layout isn't involved in writing the content?

Basically I'm looking at multiple columns, drop text, pictures that the text needs to flow around and continuation of an article on a latter page.

I know Scribus is a great DTP program for Linux, but right now, I'm stuck in windows due to a situation out of my control.

Anyway, I am downloading the Windows version to give it a try. Looks really good.

#

Re:Looks good but is it good for unusual/complex D

Posted by: Anonymous Coward on August 25, 2006 05:45 AM
If you Lyx does not fit to your task, note that there is a version of Scribus for Windows.

#

Re:Looks good but is it good for unusual/complex D

Posted by: Anonymous Coward on August 25, 2006 07:30 PM
LyX is fine for situations where one does the layout and another the content. The layout guy then creates a custom layout (multiple columns etc.) and the content writers just use that. If layout editing is needed in the end, the document is simply passed from content writer to layout tweaker.

#

Re:Looks good but is it good for unusual/complex D

Posted by: Anonymous Coward on August 25, 2006 10:04 PM
I know you can do multiple colomns, drop text, flowing text and the rest is probably easy. LaTeX has been developed for years now, so there ate heaps of extra packages that add functionality. If you like the LyX output, you should learn propper LaTeX. It is easier to use, especialy for complex tasks. A good IDE for windows is Led <a href="http://www.latexeditor.org/" title="latexeditor.org">http://www.latexeditor.org/</a latexeditor.org>

#

Lout as an alternative to Tex

Posted by: Anonymous Coward on August 25, 2006 10:42 PM
Lout ( <a href="http://lout.sourceforge.net/" title="sourceforge.net">http://lout.sourceforge.net/</a sourceforge.net> ) is a good alternative to Tex and LaTex. It has clear syntax, and its style files are more easily modified. It is very functional and stable right now, but is also still under development so new features can be added. I have used it for numerous applications (PhD thesis, papers, figures, posters) and I have been very happy with it.

#

Re:Lout as an alternative to Tex

Posted by: Anonymous Coward on October 06, 2006 09:34 AM
The PDF and PS documentation on the lout website are dead links and the last release is from 2004.

Doesn't sound that actively maintained.

#

Re(1):Lout as an alternative to Tex

Posted by: Anonymous [ip: 82.76.12.174] on October 18, 2007 01:16 PM
That's because that website is no longer maintained. Here is the new one with all the latest updates: http://www.qtrac.eu/lout.html

I agree that Lout is a great alternative to TEX. The ONLY thing I don't like about it is the fact that it has to be run more than once on complex documents so that it can resolve cross-references. Beside this one thing, I like it A LOT more than TEX!

#

Image editor

Posted by: Anonymous Coward on August 26, 2006 05:17 AM
You need a good eps file generation tool to make figures in LyX or latex. I like tgif, but more are at: <a href="http://www.maa.org/editorial/mathgames/mathgames_08_01_05.html" title="maa.org">http://www.maa.org/editorial/mathgames/mathgames_<nobr>0<wbr></nobr> 8_01_05.html</a maa.org>

#

The first WYSIWYM

Posted by: Anonymous Coward on August 26, 2006 07:44 AM
Re: "LyX is 'the first WYSIWYM (What You See Is What You Mean) document processor.'"

Funny, I thought the first was Ventura Desktop Publisher.

#

Re:The first WYSIWYM

Posted by: steve_tiano on August 30, 2006 09:07 AM
I'm not trying to start an argument--hell, I'm new here. But I'm trying to understand why anyone wouldn't use professional tools like Quark or InDesign. (Hell, I think, Ventura will still run on some PCs.) Are there real publishers--aside from tiny, idiosyncratic presses that would accept Lyx, or even LaTex, files? I mean, can you get work from, say, Simon & Schuster, or Harcourt using these "document processors"? Don't places like that require real, full-bodied page layout programs.

#

Re(1):The first WYSIWYM

Posted by: Anonymous [ip: 88.105.252.75] on January 24, 2008 03:53 AM
Use Lyx to do a PDF output. Real publishers often want the thing printed out for them anyway. And if your writing's worth a damn to them, they don't care if it's printed on napkins, as long as they can read it. No real publisher accepts unsolicited work via disc or e-mail, and few would take solicited work that way.

#

Checkout this excellent alternative: TeXmacs.

Posted by: Anonymous Coward on August 24, 2006 05:40 PM
Checkout this excellent alternative to Lyx:

<a href="http://www.texmacs.org/" title="texmacs.org">http://www.texmacs.org/</a texmacs.org>

GNU TeXmacs is a free wysiwyw (what you see is what you want) editing platform with special features for scientists. The software aims to provide a unified and user friendly framework for editing structured documents with different types of content (text, graphics, mathematics, interactive content, etc.).

Jade @ <a href="http://linux.coconia.net/" title="coconia.net">http://linux.coconia.net/</a coconia.net>

#

Re:Checkout this excellent alternative: TeXmacs.

Posted by: Administrator on August 26, 2006 11:03 PM
This is a great LyX article. I think I will stick to LyX as TeXmacs will just not run on guile 1.8...

Unless someone has a patch for it, which I had not much luck finding.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya