Writing a book in LaTeX in 2023
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
- A bigger deal, actually: Barnes & Noble requires PDF/A for your print copy
- I did finally get this working:
- Note that Amazon doesn't seem to accept PDF with a minorversion > 5
- footmisc is ok, but what i really want is what this guy describes, which does not seem to be possible.
- bigfoot looks like a better option than footmisc, using para and \footnote+
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.
this also means side-by-side dual language editions are more or less impossible, as are annotated editions defined on a page-by-page basis. you pretty much need to use endnotes rather than footnotes (though navigating to and from endnotes is admittedly a much better experience on a device than in a printed book).
and there are some problems with tex4ebook:
- unicode-math doesn't compile
- simply removing it gets you "! Undefined control sequence. ^->\active@prefix ^\@undefined"
- \defaultfontfeatures isn't recognized
- using tabular, it'll choke on e.g. \midrule, printing endless "Misplaced alignment tab character &"
previously: "LaTeX joy of man's desiring" 2023-09-24