News for hackers. Stuff that matters.
Re:Laying Out a Print Book with CSS by cubefox on Tuesday March 21, 2023 @08:59AM (#35245515)
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 by thesuitonym on Tuesday March 21, 2023 @09:38AM (#35245901)
CSS definitely has some (a lot of?) benefits over LaTeX in terms of styling, but what I like about LaTeX is that, when you don't care about the specifics, it's insanely easy to get a good looking document. About half of this article is trying to finagle CSS into producing styling that LaTeX would produce automatically, by default.
Re:Laying Out a Print Book with CSS by cubefox on Tuesday March 21, 2023 @10:29AM (#35246697)
That's only the case if you have very simple documents though, like the novel in the blog post. And those aren't usually dynamic anyway. Any more complex layouts, charts, flexible boxes are a major problem for LaTeX. Even seemingly simple tables can be a pain.
Re:Laying Out a Print Book with CSS by Upvoter33 on Tuesday March 21, 2023 @09:24AM (#35245764)
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 by WillAdams on Tuesday March 21, 2023 @09:38AM (#35245910)
Moreover, one needs controls for:

- widows/orphans

- running paragraphs one or more line longer or shorter

- setting a page spread to be one (or possibly two) lines deeper or shallower

- adjusting the size/cropping of an image/figure/table so as to influence pagination

- adjusting the placement of an image/figure/table so as to influence pagination

In my decades of doing typesetting, I've had exactly _one_ chapter come out perfectly on import w/ no need to adjust _anything_ --- fastest 40 minutes of my life.

Re:Laying Out a Print Book with CSS by luckystarr on Tuesday March 21, 2023 @10:05AM (#35246264)
TeX not only handles hyphenation, but also decides on where in a certain word it should hyphenate to optimize the current paragraph as a whole, balancing the hyphenation position in the word (some positions are better than others) against the aesthetics of the paragraph.
Re:Laying Out a Print Book with CSS by smulloni on Tuesday March 21, 2023 @11:21AM (#35247501)
I've formatted ~100 non-scientific books with LaTeX, including poetry and experimental/avant-garde fiction that makes considerable layout demands. I have yet to run into a problem that could not be solved. It isn't always the best tool for the job — for layouts with lots of images that need to be precisely placed with text, something like Affinity Publisher or InDesign would be a shorter path to the right result — but it's an amazing and remarkably painless system. If you are producing "incredibly inelegant bloat code" with it, I'd hazard that something other than LaTeX itself is responsible.
Re:Laying Out a Print Book with CSS by starkparker on Tuesday March 21, 2023 @12:14PM (#35248283)
I mean, good for you and congrats, so you must be right. Something other than LaTeX must be responsible for so many non-academics and non-technical people bouncing so hard off of it for almost any other tool. It can't possibly be anything related to LaTeX because if you're so good at it, anyone can be.
Re:Laying Out a Print Book with CSS by ericwood on Tuesday March 21, 2023 @02:27PM (#35250354)
The table thing is so true. I was insistent on using LaTeX in school and on lab reports I actually ended up building a web-based tool that would convert xlsx files into LaTeX tables I could easily embed with my data. It was pretty janky but worked well enough to save me some time. I haven't much if anything to it since about 2011 and it still sees a decent amount of traffic which tells me there's still not great solutions to the problem!