Live data from Hacker News

Laying Out a Print Book with CSS

iangmcdowell.com

111–120 of 121 posts

Re: Laying Out a Print Book with CSS

#111
post #103

Earlier quoted context omitted.

I'll answer the question: a handful at most 7 ebooks ordered as of 10:15 PST, and 10 subscribers for the free novella. I have no idea how many people read the post, I assume lots? I'm hosting on Github pages and haven't added any tracking. It seems like anecdotally a front-page post gets ~20k views, so some tiny fraction of a percent of readers went on to purchase. Honestly, this small number of sales is still far mo…

>Similarly, the members of this poorly targeted audience that did buy the book are unlikely to be typical readers in the genre. I would assume they were typical readers in the genre, which obviously some percentage of readers from HN would have to be. A post of mine on criticism https://news.ycombinator.com/item?id=32392070 went to front page for a bit and got 4.7K hits according to medium. I would think if Amazon ha…

It's possible the only people who bought were technothriller enthusiasts, but I think it's likely that at least some of them are not.

Traffic spikes are actually a common occurrence in book sales. My understanding is that some of the most effective marketing is through paid newsletter inclusion – sites like BookBub/Freebooksy/Fussy Librarian. These newsletters absolutely drive big spikes in traffic, and the conversion rate is going to correlate well with how well the book will sell overall. It's possible Amazon does something with the referrer to try to segment these kinds of traffic, but impossible to know from the outside.

If you just want to move copies, you should look at the Facebook group 20BooksTo50k. It has lots of informative posts by self-published authors doing six figures in annual sales. I can distill it down for you though. The people finding "quit your job" levels of success generally:

- write to market

- in a consistent genre

- for several years

- and publish five or more books per year, mostly in a series.

Some people reach that level of success faster, though they tend to be in the largest genres (mainly romance), or publishing at truly breakneck speed (a book or more per month).

Personally, I write things that don't slot quite cleanly into a genre, and I have a tendency to genre hop. I know it's sub-optimal, but I'm pretty sure I'd just burn out trying to do it the other way.

I'm also not yet at the point where I can write work I'm proud of at that velocity; the last book I wrote took me two months to get a first draft, and it's probably going to take another two months to get it to a "finished" state. So I'm on a "three books a year" pace, and it already feels exhausting/I may need to slow down.

Re: Laying Out a Print Book with CSS

#112
post #96

Earlier quoted context omitted.

> meaning you need to render the html and css in some form before passing it to weasyprint I'm not sure I understand this part. WeasyPrint is a rendering engine; it takes an HTML file as input and outputs a PDF. I can't speak to resource usage, since this was very ad-hoc. For my needs, it was very simple to set up, and worked on the first try. I was testing with about five pages of content, and on my M1 MBP it render…

With "render" I meant you need to first create the html and css before handing it over to weasyprint. You can't use browser-based chart libraries unless you convert their output to svg or other image formats first. With a headless browser you can use for example react to generate the document, you can just insert any chart library and so on. And regarding resource usage I had scenarios of "pdf as a service" in mind,…

Ah, gotcha. I was focused on my use case of static text.

If your charting library runs server-side and outputs HTML/CSS, then it'd work fine, but most of that stuff requires javascript, and yeah, WeasyPrint doesn't have an interpreter. Once you're already paying the overhead of a browser, you're probably better off using a JS polyfill than piping through another tool, unless paged.js is an insane resource hog (which seems unlikely).

Re: Laying Out a Print Book with CSS

#113
post #6

If the objective was not spend on design software, why not use latex?

In my opinion, markdown, LaTeX, HTML, ... is all a cognitive overhead distracting you form writing your content. That is why I started to work on MonsterWriter [1]

[1] https://www.monsterwriter.app/

Re: Laying Out a Print Book with CSS

#114
post #42

Earlier quoted context omitted.

> Proper typesetting is about achieving a consistent appearance starting from ligatures and kerning, then word spacing and hyphenation, up to entire paragraphs and pages. I looked into CSS hyphenation because I was curious about controlling hyphenation in ebooks. CSS hyphenation appears to be based around the principle that you manually insert HTML entities representing potential hyphen locations into every word, whi…

It’s crazy, and that’s why hyphenation doesn’t really work that way. Both TeX and web browsers use Liang’s algorithm to split words. [1] It uses so-called patterns, which are short substrings of words in which numbers indicate how to divide the word. For example, the pattern “s1h” indicates that in the word “fishing”, a divider can be inserted between “s” and “h”. Patterns compete and can override each other, and the…

It seems very clear that Amazon's default approach is to insert hyphens based on a whitelist of correct hyphenation points.

And that is what the algorithm you refer to does! Your links [1] and [2] speak specifically in terms of the patterns being a form of data compression that is applied to lighten the storage requirements of a big list of correct hyphenation points. The hyphenation algorithm is just that you check the word you want to hyphenate against the Master List Of All Words and learn where hyphenation is allowed. The patterns are a form of data preprocessing that makes that algorithm more efficient (here, in terms of space requirements) without changing the output.

So what we need is a way to extend the set of precomputed rules whenever we want to use a word that wasn't in the original dictionary. As noted, TeX provides this with the \hyphenation{} command. Why is this not available in CSS?

Suppose I want to write an ebook that doesn't make mistakes on the level of "fis-hing" and "f-orest". [Another example I'm not making up; the Kindle app is convinced that "Ts-inghua" is correct hyphenation.] How do I include the hyphenation information in my document?

Re: Laying Out a Print Book with CSS

#115
post #12
post #6

If the objective was not spend on design software, why not use latex?

Wouldn't surprise me if it was easier for the author to hack this together in CSS since he already knows it quite well compared to learning LaTeX. I love LaTeX, but the learning curve is more like a cliff.

> Wouldn't surprise me if it was easier for the author to hack this together in CSS since he already knows it quite well compared to learning LaTeX. I love LaTeX, but the learning curve is more like a cliff.

Yeah, agree, but a work of fiction doesn't usually have tables, figures, references, equations, etc which can be painful in LaTeX.

It does have kerning, ligatures, orphan/widow management, runs/ladder management, page numbering, chapter numbering, margins (larger closer to the spine), rules, struts, etc that all come for free without the author having to know any of that stuff.

IOW, for a work of fiction, the learning curve for LaTeX is likely limited to setting the font, setting the size, setting the output type (book, article, etc) and using bold, emphasis, underline and possible verbatim.

The learning curve for LaTeX is a cliff if you're writing a thesis, it's simply markup if you're not.

Re: Laying Out a Print Book with CSS

#116
post #6

If the objective was not spend on design software, why not use latex?

In my opinion, markdown, LaTeX, HTML, ... is all a cognitive overhead distracting you form writing your content. That is why I started to work on MonsterWriter [1] [1] https://www.monsterwriter.app/

Weird, I had the same thought two weeks ago - I just wanna tell a story, and everything else is simply a distraction. I thought "Why not a simple webapp that presents nothing but a textarea/contenteditable" :-)

Anyway, I am happier creating native (desktop) applications than webapps, except that I don't think that there is a market anymore for them. How well is your native desktop app doing? Is there a large enough market for applications that need to be installed locally only? How do you market these?

Re: Laying Out a Print Book with CSS

#117
post #107
post #102

Earlier quoted context omitted.

Author here: I'd like to think it's a little bit of both, but mostly "here's a silly hack." I tried to separate the marketing from the content as cleanly and honestly as possible. I'll give you a peek inside my head, and you can decide if you trust me to be telling the truth. I did this silly hack because I wanted to hold a copy of my book. I knew it was crazy when I was doing it, and that there were simpler/better w…

I'm not condemning your actions, just pointing out naivety. Some of those most influenced by marketing are those who think they are above it all.

Yeah. I've been on the net long enough to develop a sixth sense for when a post or article is just a lead in to a book. Either the OP did a good job hiding that intention if it was there or if no such intention was there, all the better.

My evaluation was based on my own subjective feeling so it could be wrong but I still don't feel any different even after reading the counters to my initial post.

Re: Laying Out a Print Book with CSS

#118
post #98

As a former freelance book compositor, I can say there are typically many more details that go into laying out a book. To take this layout up a notch, I would want to create a baseline grid (set the line heights and paragraph margins to align text of different sizes). I would also want to control widows and orphans, which is built into CSS.

Good point. My goal was definitely just getting to an output that satisfied me as a reader, but there are certainly people out there with more refined aesthetic sensibilities that are going to spot the places I fell down. The part that seemed hardest to get just right with CSS was text justification. I can specify inter-word justification, but there are cases where getting the spacing just right is impossible without…

I also suspect you'll find a simple CSS solution to establishing a baseline grid! Good luck!

Re: Laying Out a Print Book with CSS

#119

Fun fact: EPUBs, the global standard for digital books, is based on just HTML, CSS, and JS https://www.w3.org/publishing/epub3/epub-contentdocs.html

Yes, and they get a bye because they are constantly re-flowed --- no one would gladly accept that in print.

Re: Laying Out a Print Book with CSS

#120

Why not Scribus? It's FOSS, mature, and actively used for book layouts by others. It comes up in searches for "free InDesign alternative" and "foss book layout" (it's mentioned in every search result that I viewed [not many]). I mean, perhaps it didn't fit the story that showed the blog post to be used to trail the book, but I'd have thought it would be mentioned.

Do you have experience with it yourself? I haven't tried it for several years, but it was not at all usable last time I did. For a project like this, I think it's a good choice to go with something more declarative over a WYSIWYG tool. Latex would have been a very good choice, but only if you already happen to know it or have an interest in learning.

1.5 onwards I think has been entirely usable; before that I found it bizarrely unstable.
Post reply on HN