Live data from Hacker News

Laying Out a Print Book with CSS

iangmcdowell.com

61–70 of 121 posts

Re: Laying Out a Print Book with CSS

#61

I keep thinking that what I'd really like is a substitute of latex that is based on markdown and CSS. This is a hint of what would be possible, although of course it would take decades to get to the power of latex.

Pollen is a good intermediate for this if you like lisp.

Re: Laying Out a Print Book with CSS

#62
post #53

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.

Does CSS support baseline grids? Since pagination isn't really a thing in CSS in guessing not?

Not to my knowledge. Here's a write-up from 2012 that still seems to be accurate today. https://www.smashingmagazine.com/2012/12/css-baseline-the-go...

Re: Laying Out a Print Book with CSS

#63

I keep thinking that what I'd really like is a substitute of latex that is based on markdown and CSS. This is a hint of what would be possible, although of course it would take decades to get to the power of latex.

I’ve wondered about this, and can’t help but feel that what’s missing are good solid foundations from which webdev and general programming skills could build out everything we’d need to migrate from latex. I would bet the community would move pretty fast if the foundations were there, but I’m not sure there’s anyone with the requisite expertise and will and resources to build it.

Shame really, because IMO a web-aligned document writing tool chain would be awesome.

Re: Laying Out a Print Book with CSS

#64
The author is actually underselling CSS for rendering PDF layouts. Of course, if you just do a static book, you are probably better off with software like InDesign. But if you need PDFs with dynamic and complex content (e.g. info documents with graphs, tables, dynamic text) then HTML/CSS is actually pretty great.

As he mentions, unfortunately the CSS3 Paged Media spec is not very well-supported by major browsers, though other tools do implement it.

I actually started to love CSS much more when I had to use another code-based solution: LaTeX. LaTeX is great for equations and automatic bibliography, but not for much else. If you ever tried to merely style a minimally complex table in LaTeX, you know what I mean. You actually see in major research papers that people sometimes just give up and include a screenshot of their table. LaTeX has no inherent distinction between structure and design, like HTML+CSS, which generates incredibly inelegant bloat code, like writing and styling a website in pure HTML without any CSS. Moreover, there often is no consistent syntax in LaTeX, and most everything can only be achieved with some sort of hackish package someone put together years ago without proper documentation. HTML and CSS are a breeze in comparison. CSS features like Flexbox or Grid let you do complex dynamic layouts in a few minutes, which are so difficult in LaTeX that most users would just throw the towel.

Re: Laying Out a Print Book with CSS

#65

This article completely misses the point. Proper typesetting is about achieving a consistent appearance starting from ligatures and kerning, then word spacing and hyphenation, up to entire paragraphs and pages. Each character has to be typeset considering what character came before, how many words are in the same line and other lines in the same paragraph. The choice of font is also questionable, but not the main iss…

> This example from the article says it all: https://iangmcdowell.com/blog/book_breaks.png

What does it say? I read lots of book and... it looks like every other book. What am I missing?

Re: Laying Out a Print Book with CSS

#66

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

That is meant for e-books and not printable books.

Yup. It would be interesting to explore using Fixed Layout EPUBs to print physical books.

Re: Laying Out a Print Book with CSS

#67
post #24

For those interested in this topic, you might want to checked paged.js https://pagedjs.org/documentation/ It's an polyfil for the unimplemented CSS paged specification, which is exactly that is needed for laying out pages. https://www.w3.org/TR/css-page-3/

If I wanted to write a book, how does this translate to the publisher's standards when it comes time to hand in the design? Do publishers accept css files? How does that whole publishing pipeline work with this css framework?

Re: Laying Out a Print Book with CSS

#68
post #42

Earlier quoted context omitted.

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…

> The splitting algorithm in CSS is worse than the one in TeX, because it has to work in real time and because (good) splitting patterns are often missing. Surely that's only the case for real-time renderers like web browsers. If you're creating a layout engine for printed media that uses CSS as the way for authors/setters to specify style, couldn't it implement a better, slower splitting algorithm? Using an internal…

You could probably write some JS to reimplement the better algorithm and insert the ­ hyphenation hints

Re: Laying Out a Print Book with CSS

#69
post #64

The author is actually underselling CSS for rendering PDF layouts. Of course, if you just do a static book, you are probably better off with software like InDesign. But if you need PDFs with dynamic and complex content (e.g. info documents with graphs, tables, dynamic text) then HTML/CSS is actually pretty great. As he mentions, unfortunately the CSS3 Paged Media spec is not very well-supported by major browsers, tho…

The problem with this: LaTeX (or actually TeX) typesetting is way better. It is hard to get all the spacing, kerning, hyphenation, etc., right so that the text looks good. There is no way a CSS-based solution comes close.

Re: Laying Out a Print Book with CSS

#70
> Affinity Publisher

Didn't know Serif had made a third product. Be wary of them - Designer and Photo are both buggy minefields and their support forum is full of snobby jerks. Crashes have been reported and present for years, with little or no response from Serif. Their developers all seem either disgruntled or burnt out. Some of the employer review sites confirm this.

They're cheap but you certainly get what you pay for. Save often, back up often. I say this as an avid Designer user.

Post reply on HN