# How to write a book in LaTeX? [duplicate]

I wish to turn several of my blog article series into a PDF e-book but I have never used LaTeX before for creating books.

For example, I want to take my Awk One-Liners Explained article series, improve it and turn it into a book.

I'll probably start with this guide that I found - http://www.math.mun.ca/~edgar/thesis.html But that is just a small template. Any other tips, tricks and suggestions for doing it?

-

## marked as duplicate by Werner, Jubobs, zeroth, Masroor, ChrisSJun 24 '14 at 7:02

@Peteris Krumins for general tips about typography look at are-there-any-good-general-typesetting-books-references –  pmav99 Apr 28 '11 at 10:31
@Peteris: Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. –  doncherry Apr 28 '11 at 10:31
Are you going to rewrite your articles afresh or do you want to convert from whatever-format to LaTeX first? –  Loop Space Apr 28 '11 at 11:09
Thanks for the comments everyone. –  Peteris Krumins Apr 28 '11 at 11:14
Andrew, I am going to copy/paste the text into Latex file, I think. And then re-format it so it actually looked good. –  Peteris Krumins Apr 28 '11 at 11:14

I think that you should try using either scrbook or the memoir document class. They are designed for this kind of work. IMHO Memoir has better documentation so you'll propably find it easier to configure it the way you want it.

There is also memdesign, which used to be part of the documentation of memoir.

-
Thanks, I'll try memoir first! –  Peteris Krumins Apr 28 '11 at 11:15
Of course (as you hinted with “IMHO”) “better documentation” is highly subjective. I find the KOMA-Sript book to be a very good documentation. –  clemens Dec 21 '12 at 14:06
@cgnieder I said that I think that memoir has better documentation. I didn't claim that KOMA-Script's was bad. Also it has been a year and a half since the post. Perhaps things have changed since then. –  pmav99 Dec 22 '12 at 21:45
@pmav99 I did get that. I tried to say that I disagree. But then I am German and until only a few months ago the English documentation to KOMA-Script was bad if existent at all, unlike the German one which has been published as a book, so ... –  clemens Dec 22 '12 at 21:52

If you don't have TeX habbits yet, I'd recommend using Koma-Script's scrbook right away instead of the book class.

Also, you might want to have syntax highliting for your examples. I'd recommended using minted for that, as it is quite flexible and powerful.

-
@Raphnik + 1 for minted. An alternative is texments –  pmav99 Apr 28 '11 at 10:18
@pmav99: Ah nice, I didn't know there was another Pygments package. –  ℝaphink Apr 28 '11 at 10:20
listings is a native LaTeX package for code listings and syntax highlighting. It does not require Python or shell escaping. –  ipavlic Apr 28 '11 at 10:25
That is true, but texments is much easier to configure. –  pmav99 Apr 28 '11 at 10:29
and flexible... I've had to make syntax highlighting for non-standard languages, and writing Python modules for that is very easy. –  ℝaphink Apr 28 '11 at 10:33

Andrew, I am going to copy/paste the text into Latex file, I think. And then re-format it so it actually looked good. – Peteris Krumins

It would be absolutely heretical and the greatest of programming sins for a blog that focuses on programming to cut and paste content from a CMS into a LaTeX text file!

TeX is more than just a typesetting system. It's a full-fledged programming language and Turing complete. Although it might arguably at first glance appear insane to have a Turing complete programming language for a task like typesetting it makes sense the more you explore the needs of a typesetting system.

No other software implemented in the 1970s remains absolutely and unquestionably dominant in its domain other than TeX and the collection of macros known as LaTeX, which was developed in the eighties. The typesetting algorithms developed by Knuth and the glue-and-boxes model of text layout was a piece of absolute genius. One of the most masterful examples of capturing an extremely complex problem using an extremely simple model. It's beautiful and you are now using it in a somewhat different and handicapped way to display content within a browser. This is the part of TeX that is amazingly, gloriously, magnificently brilliant.

Welcome to our community, pick up a bit of skills in TeX/LaTeX programming and use whatever language you are comfortable with to pick up the content from your database and automatically generate the LaTeX content. For a person with your computer skills it shouldn't take more than two weekends.

Here is some code for inspiration:

\documentclass{article}
\long\def\aPieceOfCode{%
This is a Piece of code that I need to type out in a number of ways.
First pick the contents from the CMS and store it in macro. Then call them through your typesetter macros and hey it can even display maths \formula\ without the use of JavaScript!
}
\def\formula{$a=b^2+23$}
\def\displayMyCode#1{#1}

\begin{document}
\displayMyCode{\aPieceOfCode}
\end{document}

-
Ahh... but extracting the code out of some arbitrary markup and into your \def, now that is a tricky problem. Also, not a problem TeX is particularly good at solving---despite being turing complete. TeX is an amazing piece of work, but it has a very narrow focus. –  Sharpie Apr 29 '11 at 0:58
@Sharpie Depends. If you have been storing html code in the CMS then it is hard, but if you have been storing it as for example wiki markup then it is easier. –  Yiannis Lazarides Apr 29 '11 at 4:06