I am about to write a couple of books using LaTeX. I am fairly used to producing small LaTeX articles using Sweave and R, but I have never written a book using LaTeX and I am not conversant with the LaTeX practices standard for writing books.

Also, though I have a few ideas about how to structure such a big document, not having written a book in LaTeX myself, I don't know what works and what doesn't in the long run.

The books I am writing are:

  • A book with a lot of charts and code (in R), and a few tables. I'll be using Sweave with this.
  • A book with a lot of text and a few images. I'll be quoting passages and quite a few poems. An entire section/chapter could consist of poetry.

Here are my questions (answers with examples/references will be appreciated):

  1. What techniques/best-practices should I follow in writing the books using LaTeX? What are the packages that are typically helpful?
  2. What are the packages in LaTeX that I could/should use for typesetting poetry?
  3. Sweave is nice enough for including R code, but I would like something that looks more professional. I have seen and used listings, and though I still don't have a set of options which looks fancy enough, I am guessing listings will do with enough tweaking. Am I missing out on anything? Should I be using listings with any other package? Do you have nice listings templates to share?
  4. Any nice templates for writing books? Or helpful online resources specific to writing books with LaTeX?

3 Answers 3


For a general introduction to book design using LaTeX, do check out A Few Notes on Book Design by Peter Wilson. Obviously, there is no single "correct" answer as to how a book ought to be designed. If you have considerable freedom in selecting a design, as seems to be implied by your question, you could start by simply taking a close look at the layouts of some books -- whether or not they are in the same field as the book you intend to publish -- and decide whivh parts of the overall design of these books you like (or dislike).

Among the criteria should be

  • size and proportions of page -- and of text block within a page?
  • are there (wide) margins containing supplemental notes, callouts, etc.?
  • use of running headers?
  • layout of sectioning headers (chapters, sections, subsections, etc)
  • font and font sizes?
  • use of color (including "bold", i.e., more black than normal text font)?
  • use of boxes and other visually-appealing techniques?
  • quality of paper (shiny or matte; smooth or rough to touch)?
  • if the book will be available in electronic format: any hyper-linking of materials?

And so on... Have fun!


Since you mentioned R, I would recommend you to use the knitr package instead of Sweave. You can go to the package website to know more about it: http://yihui.name/knitr It is much more flexible and customizable than Sweave. For example, you only need to call render_listings() in order to switch to the listings package (e.g. http://yihui.name/knitr/demo/listings/). Recently I also started thinking on writing a book: https://github.com/yihui/knitr-book The basic sketch is there, and I'm writing with markdown instead of LaTeX since the former is much easier to write; I can convert markdown files to LaTeX later with pandoc if I want. I have finished the knitr book using knitr and LyX.

  • Hey, I have started using knitr. Thanks for a job well done.
    – Soumendra
    Commented Apr 8, 2013 at 19:37
  • @Soumendra good -- now I have finished a book based on knitr :)
    – Yihui Xie
    Commented Apr 8, 2013 at 23:18
  • Almost an year down the line, I have made a complete switch to knitr, and I don't know how I could ever live without it.
    – Soumendra
    Commented Mar 5, 2014 at 12:56

I apologize in advance for this being not much of an answer--but as N.N. mentioned in his comment, you'll get much better responses if you ask each of your questions separately.

  1. and 4. I'm also a beginner at LaTeX, but I've been using the memoir class to write a book, and it's been incredibly helpful. It has built-in support for chapter headings, page headers and footers, indices, etc.

  2. You might find this article helpful.

Not the answer you're looking for? Browse other questions tagged .