Official website for Linux User & Developer
FOLLOW US ON:
Sep
28

Publish a book with LyX

by Michael Reed

If you need to create printed documentation, LyX might just be the answer to your prayers

Be it documentation, a vanity project or an advocacy strategy for your open source project, the printed book still has a lot of life left in it and print-on-demand (POD) has revolutionised indie book publishing in recent times. There exists great scope for content that suits the printed form, yet is created by authors who don’t expect to be on the bestseller list. Thanks to flexibility that it offers, POD is also a useful route for business documentation.

LyX is a structured documentation system that uses LaTeX, a typesetting system, as its back-end. This means that you enter the content and the system works out the best layout. As the user does not have direct control over layout, LyX isn’t optimised for free-form documents such as posters, but it comes into its own in the creation of longer, more complex projects such as a book. The LyX interface doesn’t qualify as WYSIWYG, but it does reflect elements such as emphasised text, and it does allow you to see images (called figures in LaTeX-speak) and tables within the document. Although it is a front-end to a markup system, you can typically complete a complicated project without ever encountering any LaTeX code, but you can dabble with it to add customised effects.

Most of all, LyX is a geek’s dream come true due to the way it integrates with standard Linux tools. We’ll take you through the process from starting a new document to creating the finished book.

Step by Step

Publish a book with LyX
Navigate your document and even move sections with the section browser

Step 1 Install LyX

LyX is installed by using the package manager or by building from source. It’s a fairly lightweight application, but the installation requires a complete LaTeX system, which is much larger. LyX itself runs well on resource- constrained devices such as netbooks.

Step 2 Choose document class

For a book project, one of the Book classes is a good starting point (selected in Document>Settings>Document Class). KOMA- script is a superset of the basic LaTeX Book class, and this tutorial will assume that you are using it.

Step 3

Adhere to the document structure Document structure is an area of LyX that works best if you don’t try to fight with it. Hit Return twice and nothing will happen the second time as LyX won’t allow you to impose your own structure. All documents make use of a hierarchy, and depending on document type, the top heading might be chapter or part. After this come levels such as section, subsection and paragraph. Handily, if you select a section header from the drop-down menu, the shortcut appears in the status area.

Step 4

Use the section browser LyX has a nested section browser in the
form of a sidebar that greatly eases navigation on a book-sized project. It is also switchable so that you can browse by figures, index marks and other elements. You can even move whole sections around the document.

Step 5 Add index marks

Market research tells us that having an index greatly increases the sales potential of a non-fiction book. Fortunately, LyX has an index feature and allows you to simply add an index marker, possibly a nested one, within body text. Add these as you go along.

Step 6 Add citations

Cite your sources by adding them inline. LyX supports a few citation styles such as (Wikipedia-style) numeric and author-year. It uses BibTeX databases but can’t edit them, so you’ll have to add one of the many external editors such as KBibTeX or JabRef (Java).

Step 7 Insert ERT (Evil Red Text)

You can complete most projects in LyX without seeing any LaTeX code, but there are examples floating around the internet to help you do just about anything you can imagine with text and layout. It also comes into its own for more mundane, but useful tasks such as starting a numbered list on a number other than 1. ERT can be inserted inline, added to the preamble to affect the entire document or, if you come up with something handy that you want to move between documents, implemented as a module.

Publish a book with LyX
Add images to your document

Step 8 Set up converters

Converters are used for including ‘foreign’ file formats within your document. These can be image files or documents. As long as there is a command-line tool for handling the file, you can adapt LyX to work with it. Useful if you’re compiling content from diverse sources.

Step 9 Set up image converters

If you have a command-line program or a script that can convert images, you can include them directly on the page. For example, to work directly with Dia files, add this string

“dia -e $$o -t eps $$i”

to the converter section.

Step 10 Add images

Handling images will probably be your first brush with insets, a LaTeX concept. Creating an image inset gives you the default setup of a single figure and a numbered caption. However, you can add sub-figures, each with its own optional caption. When not needed, images can be folded away within the editor. When the output document is generated, LaTeX will do the job of arranging things so that everything fits. Note that you can also add images directly into a document – for example, a symbol that sits within a sentence.

Step 11 Chapter precis

A precis is a small summary, and they appear as part of the contents section. When using the Koma class you have to resort to some LaTeX code by inserting ‘\cftchapterprecistoc{Enter summary text}’. Remember to spell-check this text separately.

Step 12 Add equations

If you’re of a mathematical bent, you’ll be pleased to hear that LyX has an extensive equation editor built in. Even if you’re not a specialist, just being able to add the odd properly formatted equation looks good. Like images, equations sit in insets.

Step 13 Add labels

Many elements such as section headings, figures and tables can have an associated label. This means that you can refer to them in the text and the output will contain a reference such as ‘see fig 2.5 on page 29’.

Publish a book with LyX
Import book covers from external applications

Step 14 Front matter

The front matter is the page of a book that gives details about the publisher of the book and any legal declarations, and LyX has text styles to help. There are no legal requirements for the format of the page, but conventions exist, so look it up online.

Step 15 Layout and format

Time to get the ruler out and start measuring some books. Once you’ve found a book size that you want, start considering styles for section headings and the header and footer of each page. These are controlled with a combination of the GUI and LaTeX hacking.

Step 16 Designing the cover

LyX doesn’t have any graphic design functions of its own, so you’ll have to rely on tools such as GIMP, Inkscape and LibreOffice Draw. The printing service that you have selected will supply detailed specifications for your cover image, the dimensions of which may vary with the number of pages in your book. Although PDF is designed to be a portable format, some features such as font selection and transparency may vary between platforms. For this reason, consider generating a 300dpi PNG or TIFF instead of using PDF.

Step 17 Add an ISBN

You don’t need an ISBN number to publish a book, but it’s often required by retail channels. The Nelson Agency allocates the numbers in a minimum block of ten for £121. The Python script bookland.py can generate a suitable barcode.

Step 18 Order proof copies

Before committing to a print run, make a proof copy. Although LyX and LaTeX are handling things, you can never be completely sure that the layout you’ve designed works until you have a copy in your hands. Some printing firms offer an initial proof copy as part of the overall deal, but a better approach might be to use a service that allows the printing of single books. Order a few to try out different designs. The cover is another area that needs to be viewed in the flesh.

Step 19 Investigate alternative output formats

LyX is particularly adept at outputting to other file formats. This means that you can create, for example, a structured website from your source document or an eBook edition. Search around and you’ll find LaTeX converters that can be used for most document types.

Step 20 Select a printing service

Printing services fall into two basic categories: casual printers like Lulu.com, that can handle a single print of a book, and companies that will only accept runs of 50 copies or more. The large-batch printers are usually substantially cheaper per book.

  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • Dave

      I’m new to DTP using LyX. Previously, I have used Word. LibreOffice, and a little Scribus to publish technical documentation. Word is feature rich, but seems to have problems with large documents. LibreOffice is good with large documents, but lacks needed features such as split screen to view two parts of the same document. Scribus is great for laying out a printed document, but really doesn’t seem to do e-pubs very well. So, it is time to look at another alternative — perhaps LyX.

      I have some questions about a project for either late this year or early next year. The project is some technical documentation — a User’s Guide and a Technical Reference. The requirements as they stand today are that they both need to be high quality publications such as the Bible series books, or the Unleashed series of books for example. In addition, there will need to be an electronic version that is re-sizable of different display sizes — large monitors to smart phones, which a PDF can’t do.

      The questions are:
      1. Can I use LyX to accomplish my objective — a really professional looking document? The document will have drawings, pictures (figures), tables, ToC, Index, etc. The will be a paper version and an epub version.

      2. If so, how much of a time investment do I need to make to become proficient with LyX?

      3. Are there some example of books that were done mostly to entirely with LyX?

      4. Anything else I should know about LyX before trying to use it for these projects?

      Thanks for the article and your time to respond!

      Dave,

    • http://jere.my Jeremy Malcolm

      Dave, have a look at a book that I just published yesterday, done entirely in LyX: it’s at http://A2Knetwork.org/broadband-book. I think it looks pretty professional, don’t you think? I used a customised class though, because none of the built-in book classes were suitable. It is based on the tufte-book class which already exists in LyX. Customising a document class is voodoo, so you wouldn’t embark upon that unless you were pretty comfortable with LaTeX – or you would outsource it to an expert.

    • Dave

      Jeremy,

      I looked at your book and it is very close to what I want to do. My biggest concern is that I need an expert to design a book class for me. Are there any tutorials on how to customize an existing class? Also, where can I find samples of the existing book class? Alternatively, I can just try a few, but I’m not sure how long that will take.

      Thanks,
      Dave

    • Pingback: LyX – the document processor at Written and Read

    • Chanath

      Kindle and other digital publishers like Word document, rather than Lyx one. I find it quite easy to write in Lyx, but how do I give what Kindle wants?

    • Pingback: A bug in Lyx illustrated « cartesian product

    • Pingback: Editando seu livro com o LyX | Dublado

    • http://wiseearthpublishers.com Linkesh

      I’ve used LaTeX to publish a book that was more than 1000 pages long. LaTeX was the only sane way to go.

      I’ve since used LyX to create technical reports, project documentation, etc. It’s very versatile, and can be made to do almost anything.

      Love it.

    • http://www.unmusic.co.uk/ Michael Reed

      @Dave

      It sounds as though LyX could be just what you need. My advice would be to take it for a spin and see how it fits in with your way of working. There isn’t much of a learning curve for basic documentation creation, as long as you remember to use the headings pulldown for section headings.

      Customising the template can be tough if you’ve not used TeX/LaTeX before, and I’d say that this is the weakest aspect of the LyX system. However, there is a lot of LaTeX expertise around and the LyX forum is always helpful. The main snag of LyX is that it’s so good for this type of work that it can be hard to go back to word processor afterwards!

      @Chanath

      Most publishers will accept PDF, so there shouldn’t be a problem with output formats. Postscript is another possibility.

    • http://www.unmusic.co.uk/ Michael Reed

      @Jeremy Malcolm

      That is an amazing looking layout. Impressive!

    • Pingback: Links 7/10/2012: Linux 3.7, GIMP 3 Discussed | Techrights

    • Melki

      Hey, thank you all for this forum. I just downloaded Lyx and used it for small projects, reports and technical procedures. It is a great tool to write without being bothered about formatting the pages, etc.

      The only little problem I do not know how to tackle is that I wanted to print directly to my printer those documents I wrote, but could not.
      Does this mean that I have to transform documents in PDFLatex only to be able to print, or have I missed something during installtion?

      Thank you for your help

    • ArtOneZero

      HI Jeremy, I have self published books with Lyx and want to make the next step to creating a custom document class for my imprint. Do you know where I could find an expert/experts who could do this job for me? I have looked far and wide and have yet to find one (even for good money!)
      Thanks, Mike