Check out my first novel, midnight's simulacra!

Writing a book in LaTeX in 2023

From dankwiki
Revision as of 08:45, 30 November 2023 by Dank (talk | contribs)

dankblog! 2023-11-29, 0622 EDT, at the danktower

as noted in my last post, i've been writing a somewhat experimental novel the past few months using LaTeX, in particular the LuaTeX implementation (i started off using XeTeX, but the all-important microtype package doesn't fully support XeTeX). print publication is a month from now, and i'm ready for it. LaTeX was an excellent choice; despite having no assistance from a publisher/layout expert, my corpus looks as good as any book I've seen, and better than most. i've been able to take advantage of things like chemfig and CircuiTikZ, packages almost as powerful as they are opaque and mystifying. i can do conditionals based off parameters passed on the command line by my Makefile, allowing different definitions and behavior depending on whether i'm preparing a hardback, paperback, or ebook.

there have been some annoying issues, though:

  • XeTeX is slow compared to pdflatex (not a serious option imho). LuaTeX is slow compared to anything.
    • I have my chapters broken up into different files, but I don't like working with single-chapter PDFs
  • I haven't yet been able to get the pdfx package working in LuaTeX
    • Not a huge deal, as it turns out, due to PDFs being essentially unmarketable, see below
  • redelmac is ok, but what i really want is what this guy describes, which does not seem to be possible.

there's one fundamental and much more serious problem, though:

ebook retailers/readers do not want paged documents.

the vast majority of retailers do not accept a PDF in 2023. you pretty much need to get them an EPUB3 if you want to vend digitally. an EPUB3 is a wrapper around HTML, CSS, and resources. it wants to reflow, and to allow the user to control font size and even what fonts are used. so all your work on pagination and lines is getting flushed away (probably) as the device takes over rendering. exactly what all HTML and CSS and MathML the local device supports is of course unknowable.

there is what's called a fixed-layout EPUB3, where you provide images of each page. this is grotesque, and even if you wanted to do it, most people won't let you sell these. amazon won't distribute them to kindles, etc.

so if you want to sell an ebook, you're going to need to accept that the user can effectively destroy your layout in terms of image placement etc.

previously: "LaTeX joy of man's desiring" 2023-09-24