I would like to automate e-book build from remote repositories. A command-line tool would be useful in this case. Is there any software for Ubuntu?

  • Sure, you could use LaTeX latex. I would use an editor like TexStudio, or TexWorks, but if you want to use the command line, go for it/
    – j0h
    Jul 12, 2016 at 1:04
  • Is LaTeX suitable to output .mobi, .aw3, .epub, etc files? Jul 12, 2016 at 1:06
  • 1
    Could be relevant: tex.stackexchange.com/questions/1551/use-latex-to-produce-epub.
    – edwinksl
    Jul 12, 2016 at 1:08
  • 1
    @ThiagoRiderAugusto You are right that conversion from PDF to ebook is just awful. But, epub is largely just a compressed form of HTML. So, converting from HTML, or other similar formats, to an ebook works well.
    – John1024
    Jul 12, 2016 at 1:42
  • 1
    I use Sigil. It's not a command line tool, but an editor: github.com/Sigil-Ebook/Sigil Jul 12, 2016 at 7:15

2 Answers 2


A wide variety of documents can be converted to ebook (epub, mobi, ...) using ebook-convert which is part of the calibre package.

For example, as long as input is a supported format, an epub can be created with the command:

ebook-convert  input output.epub

Or, if you use kindles:

ebook-convert  input output.mobi

Some input formats include: LIT, MOBI, AZW, EPUB, AZW3, FB2, DOCX, HTML, PRC, ODT, RTF, PDB, TXT, PDF.

If the input file is a PDF, then one may want to add an option:

ebook-convert --enable-heuristics  input.pdf output.epub

Calibre may be available from your package manager but it often helps to install the latest version which is available here.

Authoring a book

As an alternative to calibre, OpenOffice/LibreOffice offers an extension, Writer2ePub, to claims to be able to create "well formatted, easy readable ePub" files with a single click.

The Writer2ePub extension can be downloaded from here.

  • I don't want to convert, I need a command-line software which can build the e-book from its source. Jul 12, 2016 at 1:15
  • 3
    That markup language is a subset of HTML. Calibre works well with HTML.
    – John1024
    Jul 12, 2016 at 1:28
  • 1
    @ThiagoRiderAugusto By the way, that is a nice tutorial. It begins with html (part 1) and ends with zipping the files up into an epub (part 3). How close are your sources to the final format?
    – John1024
    Jul 12, 2016 at 1:55
  • 1
    OK. You will likely want to add some markup to indicate chapter headings and image locations and such. If you are a perfectionist, that jedisaber tutorial is ideal: it allows you to have total control over the output. If you want some convenience, you may be satisfied with using a word processor or html editor of your choice and then trust in calibre or pandoc to handle the rest. After the conversion, you can edit the ebook with calibre to do some fine tuning.
    – John1024
    Jul 12, 2016 at 2:16
  • 1
    Have you used OpenOffice/LibreOffice? Calibre and Pandoc claim to be able to convert their files to epub. Also, there is a Writer2ePub extension that claims to enable OpenOffice/LibreOffice to create epub directly.
    – John1024
    Jul 12, 2016 at 2:25

The software pandoc ( http://pandoc.org/ ) might come in handy for your needs. It can be installed in Ubuntu by opening a terminal (Alt-Ctrl-T) and typing sudo apt install pandoc.

Pandoc can convert between a variety of different formats, including txt, html, xhtml, doc, docx, odt, epub, fb2, docbook, OPML, LaTeX, pdf, markdown, asciidoc, MediaWiki, Dokuwiki, org-mode, and a variety of others.

It does not appear to support conversion to/from mobi or aw3, but could certainly build an epub file from a variety of different sources. Then if you like the epub file it produces, you could use @John1024 's answer to convert to mobi or kindle format.

By starting with a source file that supports formatting, such as markdown, html, asciidoc, or the like, you can get a nicely-formatted epub output. The pandoc README file gives a nice overview of the command-line options that are available (including options for table of contents, fonts, link styles, margins, etc).

  • 2
    Pandoc does show an example on its site of how to build an EPUB of moderate complexity using it. Jul 12, 2016 at 3:17
  • @StephenMichaelKellat is referring to the how to make an epub with pandoc example.
    – nilon
    May 31, 2020 at 22:10

You must log in to answer this question.

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