Check out my first novel, midnight's simulacra!

Writing a book in LaTeX in 2023

From dankwiki

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
    • A bigger deal, actually: Barnes & Noble requires PDF/A for your print copy
    • I did finally get this working:
[schwarzgerat](130) $ pdfinfo midnight-hb.pdf 
Title:           midnight's simulacra
Author:          nick black
Creator:         LaTeX with hyperref
Producer:        LuaTeX
CreationDate:    Mon Dec 18 13:55:45 2023 EST
ModDate:         Mon Dec 18 13:55:45 2023 EST
Custom Metadata: yes
Metadata Stream: yes
Tagged:          no
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           451
Encrypted:       no
Page size:       441 x 666 pts
Page rot:        0
File size:       81038789 bytes
Optimized:       no
PDF version:     1.5
PDF subtype:    PDF/A-3u:2012
    Title:         ISO 19005 - Electronic document file format for long-term preservation (PDF/A)
    Abbreviation:  PDF/A-3
    Subtitle:      Part 3: Use of ISO 32000-1 with support for embedded files
    Standard:      ISO 19005-3
    Conformance:   Level U, Unicode support
[schwarzgerat](0) $
    • 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