
Ask HN: What software should I use to write a textbook? - laurieg
I will be delivering it as a PDF and thinking about printing a version in the future.  What are the best software solutions for this?
======
lifepillar
If you have time to invest, go for a TeX variant (LaTeX or ConTeXt). That
gives full control over any typesetting detail.

I’d recommend ConTeXt [0] over LaTeX. A minimal document is as simple as

    
    
        \starttext
        Start writing here…
        \stoptext
    

and you can go a _long_ way from there, including making ebooks. Much better
than LaTeX for layout control, language support, graphics integration, table
generation, etc… It’s also intimately integrated with Lua for your scripting
needs.

The documentation is possibly its weak point: it’s rich and comprehensive,
although somewhat sparse and at times heavily technical. But it’s worth the
effort, IMHO.

You may get inspired by the TeX showcase [1] (not only ConTeXt, but also LaTeX
and plain TeX).

[0]
[http://wiki.contextgarden.net/Main_Page](http://wiki.contextgarden.net/Main_Page)
[1] [https://www.tug.org/texshowcase/](https://www.tug.org/texshowcase/)

~~~
TylerE
For a book I'd recomment ConTeXt. It's rougher around the edges but it's
geared more towards "rich" presentation with sidebars, imaages, maybe even
some color vs LaTeX which at it's core is optimized for things like journal
articles with relatively little formatting.

If I was going to compare them to commerical software, ConTexT is closer to
InDesign and LaTeX is closer to Word.

~~~
adiM
I'll simply quote a thread by William Adams on the context mailing list
(copied from here
[http://wiki.contextgarden.net/Comparison_between_ConTeXt_and...](http://wiki.contextgarden.net/Comparison_between_ConTeXt_and_other_typesetting_programs),
the link to the mailing list does not work)

With a graphical tool, one is limited to the automation which the developers
are willing to build into the tool and sentenced to handling manually
everything else, every time that there's a change, e.g., if you have a keyword
block on your opening article pages aligned against the outside gutter and the
layout program can't place it automatically and contextually, then every time
the article changes from opening to a left to a right or vice-versa one has to
make that change manually.

I wrote up a longer comparison once upon a time --- Scribus isn't that much
different from InDesign and Quark, so the criticism holds:

While I'm no TeX wizard, I prefer it because it allows one to off-load some of
the tedium and repetitiveness to the computer, as opposed to repeatedly
solving variations of the same problems by hand time after time after time.

So,

* using Quark is like being chained to a an oar which is covered w/ splinters and mostly broken at the other end and which will randomly break due to being poorly carved (Quark has crashed on me 183 times this year) leaving one adrift or run aground, or sometimes returning the vessel to its starting point (a few of those crashes have resulted in unrecoverable document corruption --- my autobackup folder may contain 2 or 3 GBs of files for a given iteration of a particular project each month) --- the oar can be smoothed somewhat and reinforced (by purchasing or finding XTensions, using XTags &c.) and periodically one is required to purchase a new oar (sometimes just after the previous one has been customized adequately). For some tasks, one can impress any graphic designer as a galley slave to ease the effort for others, but while charts are available, there are no automagic navigation options and every journey must be manually piloted.

* using InDesign is pretty much the same except the oar is smoother and stronger (it's crashed 29 times on me thus far this year), there aren't as many customization options and it's not quite as easy to find a candidate for impressment (though soon it'll be as easy as for Quark). Charts are available, but again, piloting is strictly manual.

* using Plain TeX one has to craft the vessel's oar oneself (as well as the rest of the vessel unless one is typesetting a clone of The TeXbook), but it's as sturdy and as nice a one as one's skills allow and can even be an engine which moves the vessel in and of itself --- it can be difficult or impossible to find people suitable to help w/ either carving the oar or using it though, but once a given journey is worked out, the oar becomes magical and rows for itself except for when one runs into an unplanned for obstacle (the navigation charts are old ones and not often up-dated, with a lot of “terra incognita”), allowing one an auto-pilot option for certain journeys, dependent upon one's skill. using ePlain, an oar is provided, can be customized, and can be enchanted and the charts are okay, but have a lot of “terra incognita” on them.

* using LaTeX, an oar is provided and there're lots of nifty customizations and improvements already available, and one can impress additional oars from CTAN, however on a semi-random basis, adding one oar will break other oars, sometimes leaving one adrift or run aground. One can enchant a set of oars to accomplish a given journey, easing the piloting requirement, and the navigation charts are decent and obstacles are fairly well-known.

* using ConTeXt, a very nice oar is provided, which has lots of customization options, but the navigational charts aren't easily read by a traditionally trained navigator at first, although they are fairly compleat and most journey can be carefully worked out, but once one is, it is quite automatic and there's a good auto-pilot option.

~~~
Kagerjay
I am comfortable with making anything in Adobe Indesign.

If you are going to make things in Indesign, it should be as a last step
process, after the full draft has been made. Otherwise you will slow down your
writing by a lot.

Quark is rather outdated IMO, little has changed over the years. It has
terrible UI and native keybind controls

I would use some flavor of markdown + some notetaking tool that supports it. A
good example would be gitbooks.io, there's other ones out there too.

Latex & Variants is what has always been used for textbooks. Can't go wrong
with it

------
bArray
My process is to use markdown [1] (very little style related formatting) and
then convert to a desired format using pandoc [2]. Building multiple books
that look the same, later revisions, etc - becomes really easy.

One of the benefits is that you can convert a chapter to a webpage and gauge
interest in the book itself.

[1]
[https://daringfireball.net/projects/markdown/](https://daringfireball.net/projects/markdown/)

[2] [http://pandoc.org/](http://pandoc.org/)

~~~
mark_l_watson
+1 for this. I do this at work for documentation. Markdown presents well on
github and using Pandoc with Makefiles so I don’t have to remember the options
for generating PDFs, Word format, etc.

------
segmondy
Begin with plain ASCII text. It's very easy to get distracted by the
formatting and looks. Content is what's important. So begin with a basic
editor like notepad/vi/emacs. Perhaps at best markdown. Get it done, then
edited, then you can typeset with something like Latex/Word.

~~~
deninho
Just that. Maybe Word in the first place, for the spell checking. But, other
than that, just use it as a plain text editor.

I also find it useful to create a new file for each chapter.

~~~
kwhitefoot
You don't need Word for spell checking. For instance, Emacs can use ISpell,
ASpell, etc.

~~~
deninho
Good to know. I'll check if Sublime Text supports spell checking as well :)

------
aeontech
Check out Pollen: [http://docs.racket-lang.org/pollen/](http://docs.racket-
lang.org/pollen/)

The author of the package, Matthew Butterick, wrote several books with it,
such as

\- Practical Typography:
[https://practicaltypography.com/](https://practicaltypography.com/)

\- Beautiful Racket:
[https://beautifulracket.com/](https://beautifulracket.com/)

Looking at the results, I can't help but be impressed. If I was writing a
book, I would start here.

I think you can get it to output LaTeX which you can then use to generate your
final PDF and ePub, if you like.

Previous HN discussion here with some other real-world users chiming in with
their experiences:
[https://news.ycombinator.com/item?id=15335010](https://news.ycombinator.com/item?id=15335010)

------
corysama
"What is Best" always depends on what you need. For writing a book, the final
answer is probably LaTeX. That's assuming what you need is not highly simple.
(However, the advice to work in plain text before you typeset is really solid)

However... for something simple, I'll point to [https://casual-
effects.com/markdeep/](https://casual-effects.com/markdeep/) I've found that
Visual Studio Code +
[https://marketplace.visualstudio.com/items?itemName=Flixs.vs...](https://marketplace.visualstudio.com/items?itemName=Flixs.vs-
code-http-server-and-html-preview) make for a lovely editing experience.
Basically, you write plain text, hit ctrl-s and see formatted HTML in a side
panel. The homepage explains how to generate PDFs.

Here's some notes about fancy typesetting from someone who wrote a book using
Markdeep: [https://imaginary-
institute.com/resources/MarkdeepToInDesign...](https://imaginary-
institute.com/resources/MarkdeepToInDesign/MD-ID-notes.md.html)

~~~
fsloth
As a sidenote that "someone" is Andrew Glassner [0] :) - i.e. the editor of
the venerable Graphics Gems series and much else. The books you refer to are
here

[https://www.glassner.com/portfolio/deep-learning-from-
basics...](https://www.glassner.com/portfolio/deep-learning-from-basics-to-
practice/)

As another examples Google's Filament PBR renderer has beautiful documentation
written in Markdeep as well:
[https://google.github.io/filament/Filament.md.html](https://google.github.io/filament/Filament.md.html)

[0]:
[https://en.m.wikipedia.org/wiki/Andrew_Glassner](https://en.m.wikipedia.org/wiki/Andrew_Glassner)

------
evgen
Too many commenters are thinking about the last steps (layout and pre-print)
when the hard parts are everything up to that point. Go purchase a copy of
Scrivener and if on Linux then maybe learn org mode really well or else run
Scrivener in a VM.

------
Artemix
The LaTeX document format is pretty well fit for the use case (it's kinda been
made in that sense).

If it's "too complex", you may be interested in reStructuredText, a stricter
and more complete alternative to Markdown, that auto-converts well into LaTeX.

------
mherrmann
It doesn't matter. Stop wasting time on thinking about the right tool and
start writing. Way more projects fail because they are never finished (or even
properly started) than because of wrong software.

~~~
8bitsrule
Really. Writing text beats fighting with (whatever) tech.

Once the writing is done, you have something you know makes the formatting
fight worth waging. That way, the half-hour you'll spend finding a bloody
compromise for some problem won't be cutting into your writing.

------
bebna
Your favorite coding editor (intellij, vim, emacs, notepad++,...), markdown
and pandoc.

Markdown lets you focus on content and structure, pandoc creates a PDF of it
by using latex, which you can later use to define how the text shall be
printed (twosided? Us legal/a4/a5? Title, author,... ) and gives you latex
formatted text, which is always correct & professional.

Pandoc also allows tables and images in markdown.

------
jstrebel
Please do not use LaTeX. If your textbook is supposed to have special layout
needs, you will have a hard time with LaTeX. Tables are a real nuisance in
LaTeX as well - normally you have your data in some other tool like Excel or
some Jupyter notebook or CSV. Turning the data into a nicely looking and well-
placed LaTeX table is not straightforward. Sure, there are specialized LaTeX
extension packages for a lot of functionalities, but you will need time to get
familiar with them. I would just start with MS Office or LibreOffice - both
offer sufficient functionality and if you need more specialized tools, then
those tools usually have an import function for DOCX /ODT files.

~~~
xevb3k
Personally I find it pretty painful creating large documents in Word. Creating
documents in Latex helps me focus on the text/structure without worrying about
figure/table placement (I can still have them in the markup, but and fix all
the formatting issues after I’ve written the text).

I think it depends on author mentality somewhat. Word works well for some,
Latex for others.

It might also be worth considering Markdown or plain HTML. Particularly if an
ePub/kindle version is a possibility.

------
kyberias
Use a word processor to write a book. Think about that other stuff after your
book is written. You don't need to think about it yet. You need to write that
book.

~~~
muzani
Yeah, I think one of the risks here is spending so much time picking the right
tool that you lose interest in writing the book. Latex is great for writing
papers, formatting, references, but arguably not great for churning out
thoughts. Sometimes a pencil and paper will do.

------
cimmanom
I would start by writing it in whatever software you find most conducive to
long writing and editing sessions (be that MS Word, Dark Room, Scrivener, or a
programmer’s text editor).

Then convert it to the format you want to use for formatting and layout.

------
mickeyp
I spent a lot of time on this before I settled on Pandoc and reStructuredText.
However, if you have a publisher, they may dictate the medium.

I wrote about my experience writing a book on Emacs in Emacs here, and the
tooling I used [1]

[1] [https://www.masteringemacs.org/article/how-to-write-a-
book-i...](https://www.masteringemacs.org/article/how-to-write-a-book-in-
emacs)

------
Tepix
Have you had a look at Apple iBooks author? [https://www.apple.com/ibooks-
author/](https://www.apple.com/ibooks-author/)

~~~
watersb
Pages now saves ePub, might be a better tool for most of the job.

------
gpresot
Use whatever tool allows you to sit down and write content sooner. If you
don't know Latex, don't waste time learning it (unless the book has a lot of
formulas in it). So if you already know how to use Word, (or similar word
processors like the Libreoffice one) use that. They are perfectly fine for
large text base stuff. If you have plenty of images it will get heavy, but I
think there might be a way to link to external files?). Rendering in PDF from
MS Word works very well. If you need to share it with somebody for review and
comments, most people would be able to open it and read it and comment
directly on it. And the WYSIWIG aspect of it should not be underestimated. The
amount of personalization of fonts, spaces, etc, is way larger than other
options.

------
ivan_ah
I highly recommend
[https://github.com/softcover/softcover](https://github.com/softcover/softcover)
see dogfooded demo
[http://manual.softcover.io/book](http://manual.softcover.io/book)

You can write the text either as Markdown or LaTeX, and softcover will build
PDF, HTML, ePUB, mobi versions of the book for you.

It's the only ePub generation strategy that I know of that doesn't butcher the
math.

------
danso
I agree with what others have said, that there is no best system/framework
because it depends on the use-case. But I haven't seen Sphinx (which I'm
currently attempting to use) here, so I'll mention it. It's often used for
web-based docs but has built-in PDF output via pandoc. The Hitchhiker's Guide
to Python is one example of a book produced with it:

[https://docs.python-guide.org/](https://docs.python-guide.org/)

------
beyondCritics
Looks like you should use pandoc (or asciidoc) from within your favorite text
editor (e.g Visual Studio Code, Atom, ...) Using raw LaTeX is wasted effort
IMHO, only commit to it, if you really need it. If you want to sell later as
E-Book, i recommended to get the technical details right now. This might give
you an edge over authors who are only able to deliver a converted pdf.

------
ttoinou
Maybe Atlas ? [https://atlas.oreilly.com/](https://atlas.oreilly.com/)

------
wodenokoto
RMarkdown can make for some great textbooks. Take a look at the online version
of R for Data Science, to see what can be accomplished:

[http://r4ds.had.co.nz](http://r4ds.had.co.nz)

[https://github.com/hadley/r4ds](https://github.com/hadley/r4ds)

------
bwl
Asciidoctor is worth a look, in line with plain text / markdown but offers a
bit more in terms of textbook specifics.

[https://asciidoctor.org/](https://asciidoctor.org/)

------
ddebernardy
Use your preferred variation of plaintext - markdown, reStructuredText, etc. -
in as plain an editor as you can come up with. (There are plenty of
minimalist/distraction free plaintext editors out there if you'd rather not
use your favorite code editor.)

The hardest part in long form copy is getting the content written. Anything
visual on top is just distraction that will get in your way and slow you down.

Once you've the copy, use Pandoc or equivalent, and _then_ typeset and format
using a more sophisticated medium as needed.

------
beezle
To some degree what you use is dependent upon what type of content it is. Is
it purely text? Text and some images/graphics? Tables? Equations?

A good starting point for primarily text or text+pics is whatever editor you
like to use everyday. Once your content is final (or nearly so) you can export
as ascii and then add latex (or variant) formatting.

If it is heavily equation oriented, there are a number of wysiwyg type latex
editors that may be helpful or just bite the bullet and start as a latex text
document.

------
oldmancoyote
None of the suggestions address the writing process and what might facilitate
that process. I was so frustrated with existing word processors in that regard
that I wrote my own. It's built on my personal work flow augmented with spell
checking and find/replace. I did add layout features as an afterthought but
rarely use them. I'd market it, but marketing "side projects" is an
insurmountable hassle.

------
dmitripopov
Am I allowed to advertise my own work? :) I added some features to Helpinator
that make it more convenient to write textbooks, especially on programming.
For example, you can add self-check quizzes, step-by-step guides, easily
manage code snippets, etc. And you can export to 10+ formats, including PDF.
Or export to Github-flavored markdown to submit it to Github.

------
blue1
I've written, typeset and published a book about a game (a variant of contract
bridge) [1] using this toolchain: emacs org mode > Pandoc > Adobe Indesign
(via ICML). Worked beautifully.

[1]
[https://www.santeonisto.com/swingbridge](https://www.santeonisto.com/swingbridge)

------
mark_l_watson
I used Latex for several books and liked it. I once wrote a single book, but
in Java and Common Lisp editions, and Latex worked really well for that.

Then I switched to Leanpub.com and never looked back. With Leanpub markdown
you can still use Latex for formulas.

I love to write and Leanpub takes almost all of the hassle/overhead out of the
process.

------
kvakkefly
I suggest Doconce
([https://github.com/hplgit/doconce](https://github.com/hplgit/doconce)) which
is a language that compiles to latex, html and other formats. It is easy to
make a version specialized for tablet etc. It is used quite heavily at my
university.

------
pvaldes
If you want ridiculously high power for doing anything you want with a book in
any language, TeX and friends will grant you god's level.

[https://en.wikipedia.org/wiki/TeX](https://en.wikipedia.org/wiki/TeX)

------
rwieruch
You should give Leanpub [0] a shot which is a platform for self-publishers.
You not only get full-control over the process, but you can also use various
input sources and formats (GitHub/Bitbucket, Dropbox, PDF, ...) and output
formats (PDF, EPUB, MOBI).

I write all my books with Markdown and Git/GitHub [1] and release them
eventually on Leanpub [2]. Even if you don't want to release the book on their
platform, you can take away the output files and publish them somewhere else
(e.g. own platform, Amazon).

\- [0] [https://leanpub.com](https://leanpub.com)

\- [1] [https://github.com/the-road-to-learn-react/the-road-to-
learn...](https://github.com/the-road-to-learn-react/the-road-to-learn-
react/tree/master/manuscript)

\- [2] [https://leanpub.com/the-road-to-learn-react](https://leanpub.com/the-
road-to-learn-react)

------
blt
Depends on the topic. If there's a lot of math, you might as well go straight
to LaTeX.

------
nekopa
I used Scribus to develop a language teaching course book for kids. It's kind
of like Adobe's InDesign, but open source. A bit of a learning curve, but once
you get the hang of it I find its quite easy to use.

------
znpy
Many tools have been described in this thread.

I'd say, go with the simples you can find (maybe even LibreOffice Writer).

Worry about layout and imagination later.

Make sure the tool you use doesn't get in the way of actually writing the
book.

------
jwilbs
Bookdown is super easy. Some oreilly books (eg R for Data Science) used it.

------
rambojazz
"The best" is something that does not exist, you have to know what your
requirements are. Having said that, I would suggest ASCIIDOC,
reStructuredText, or the good old LibreOffice.

------
abakus
Ms word.

------
singingfish
I wrote a perl book using pod (the perl doc format). The process was baroque:
pod to latex,latex to rtf. Which then gave me an msword interchange format -
important for the publisher.

I also wrote a PhD thesis. I started with various msword compatible formats
(for process reasons). I curated the documents into markdown and was hoping to
use markdown/citeproc to produce a thesis via either msword or latex. However
that was going to be a pain in the bum, so I finished it up with
latex/hyperref/bibtex.

So, tl;dr I think if your book is not citation or maths heavy and you are in
control of the process I would recommend markdown to latex via pandoc. If it’s
citation heavy,then I’d probably recommend cutting out the pandoc middleman
and going straight to latex/bibtex. If it’s maths heavy then markdown to latex
might work. If it’s someone else’s process, I recommend jury rigging something
that will get them an MVP.

------
qengho
Emacs, org-mode.

------
se7entime
plaintext / .txt / .md

------
mseidl
vim!

------
Oberbaumbrucke
Vim

------
ILikeConemowk
Sadly, it's latex.

 _Yikes_

