9 ms·
I self-published a paperback and eBook using LaTeX and Pandoc
- gorgoiler 6y agoCongratulations, a huge achievement and an inspiration for me (especially the subject matter.) One of the major advantages of LaTeX is that it will fill lines automatically, hyphenating where necessary. Another important part of type design is flowing paragraphs so that the final line contains enough type. One does not want a paragraph to end with a single “me” by itself on the final line, and ideally you want a substantial amount of type there. Are these parameterised in LaTeX? Did you turn hyphenation off?
- sidpatil 6y ago> Another important part of type design is flowing paragraphs so that the final line contains enough type. One does not want a paragraph to end with a single “me” by itself on the final line, and ideally you want a substantial amount of type there. These are known as widows and orphans. https://en.m.wikipedia.org/wiki/Widows_and_orphans https://en.m.wikipedia.org/wiki/Widows_and_orphans
- tripa 6y agoThese are not known as widows and orphans. Widows and orphans are a single line split to a separate page than the rest of the paragraph. Parent is describing a single word split to be alone on its line.
- johnday 6y agoA word alone on its line is also often referred to as orphaned.
- sdoering 6y agoCorrect. I remember my late father telling me about these with the technical terms used by type setters in times when type was set manually (the occupation he learned in his youth): > Cobbler's boy and whore's child (in German Schusterjunge und Hurenkind) [1] I never forgot these two terms. [1]: https://de.zxc.wiki/wiki/Hurenkind_und_Schusterjunge https://de.zxc.wiki/wiki/Hurenkind_und_Schusterjunge
- DemocracyFTW 6y agoThese things are vastly overrated, badly named (at least for the German words), and poorly understood. It's become sort of a cult I feel. The truth is that when you go through traditional books (specifically those printed before the advent of even phototypesetting) you'll often find lone first and last paragraph lines last or first thing on a page. It's treated like a taboo by some these days but in typesetting you're always dealing with constraints and compromises. What you ideally want is every page with the same number of lines, all the lines having the same offsets (grid), each line filled with the same amount of type when you squint, last lines being not too empty and not too full, and no lone first or last lines. Now, when you do your galley proofs and then just cut the paper every n-th line, chances are there will be some orphans and some widows. It follows from geometrical consideration that one of the mentioned constraints then has to be loosened or given up in order to not have orphaned first and last lines. People nowadays scream when you suggest to just leave it that way but really, you have to have some lines with narrower or wider word spacing, or some pages with more or fewer lines, or some paragraphs with a less-than-ideal choice of hyphenation in order to stretch or squeeze the content so it fits in. As an example, maybe you have just the letters 'me.' on a paragraph last line, which is bad by itself, and that word appears first thing on a new page. That's double bad and easy to fix, maybe just typeset one of the lines above that a little tighter to make the 'me.' find space on the preceding line. Problem fixed, but the price for that is now your last-of-paragraph line is overly full and it is also the last line on the page, which is... double bad, again, like what you started out with. In this case, maybe increasing spacing in the entire paragraph works out better, giving you an orphaned line all by itself on a new page, but at least it contains another word or two.
- sdoering 6y agoWhen my father learned typesetting it was absolutely frowned upon to do this. Surely one finds low quality type setting at every point in time. But that still doesn't invalidate the fact that it is a sign of poor quality. The offensive naming is a historical thing. I wouldn't call them that today, but can accept the fact that in times not so long gone by this was quite normal. It is like slave/master in IT terms. A historical technical term that should be replaced nowadays.
- qart 6y agoI don't see how hyphenation could be left "on" when publishing ebooks. Nearly all the platforms I've used allow the user to control font face and font size. Hyphenation would malfunction under such circumstances.
- bryanrasmussen 6y agosoft hyphens can be put in https://en.wikipedia.org/wiki/Soft_hyphen https://en.wikipedia.org/wiki/Soft_hyphen to allow the client to hyphenate as appropriate.
- qart 6y agoTIL. Thanks. But this would require soft hyphens in every multi-syllabic word of the epub, right?
- bryanrasmussen 6y agoyes, so as a general rule for any publishing scenario where hyphenation is important you have an automated solution, for example for a small company / single person you might set up something using https://github.com/bramstein/hypher https://github.com/bramstein/hypher or find a similar tool. Also this tends to be sort of overkill for what most people want so - as with most tech - gotta evaluate if it's worth the time and effort.
- baby 6y agoThat’s not how it works. You can control these things when you want to produce a pdf or a document for print, but you can’t control them for formats like epub (as font size, screen size can be changed)
- qart 6y agoHence, my comment. The author published to epub.
- 6y ago
- chrissnell 6y agoNice work, Dan. I don't see many obvious LaTeX books and wonder why more self-publishers don't do it. The learning curve, I guess? I follow your IG and your trip looked like a lot of fun. I dream of the day when my boys will be off at college and I can do something similar. For now, two-week dirt trips every year. Chris (@desertdefender on the Gram)
- nickt 6y agoHi Dan, Thanks for sharing, it’s a great insight into getting a book done, especially a proper overland one. Nice to see Chris here too, I wonder how many of us are at the intersection of geekery and overlandery?
- max_ 6y agoHow does LaTeX compare to software applications like Scrivener
- tim-- 6y agoLaTeX is more of a typesetting application, where Scrivener provides much more tooling around story telling. Scrivener provides you with tools like corkboard and outliner, which lets you have a place to store ideas and todo lists for what you are working on. You can rearange a chapter in your book by clicking and dragging it to the new location. The formatting is similar to Word or OpenOffice, in that, what you see is what you get. LaTeX on the other hand (or more specifically, TeX) is a set of macros that will generate formatting for you. Usually, the output is a DVI file, but can also be a PostScript or PDF file. LaTeX is all plain text. It only handles document processing, turning the LaTeX document into an outputted formatted document. Edit: You can still include images etc. Pandoc allows you to convert between LaTeX and many other formats. What you can do with LaTeX is almost limited only by your imagination: https://www.latex-project.org/publications/2020-egreg-TUB-tb127gregorio-math.pdf https://www.latex-project.org/publications/2020-egreg-TUB-tb...
- singingfish 6y agoLaTeX is horrible and dated, but if you need to produce a thesis, or a thesis-like document it can't be beaten. When I used LaTex for my (sociology of computing) PhD it made it look I'd put far more effort into the document formatting than I actually had.
- globular-toast 6y agoThe best looking documents from MS Word are the ones where the author hasn't put any effort into formatting except using the built in styles for headings and paragraphs etc. The only difference is LaTeX makes it obvious that this is the way whereas Word makes it easy to do the wrong thing and use ad hoc formatting.
- iorrus 6y agoAgree, pandoc makes the best word files IMO. It doesn’t allow you to make too many style formatting changes so write in markdown and use pandoc to create the word file using simple headers, standard formatting. Seems hard to replicate this approach in word in my experience without good discipline
- ggambetta 6y agoCongratulations on the publication, such a fantastic achievement! Can imagine how happy and proud you must be feeling right now :) I'm curious about the choice of LaTeX. According to the article, it was about controlling the layout. I did something similar [0] a few years ago, but my "stack" was Markdown + Pandoc; converting Markdown directly to an epub with Pandoc was more than enough, but for the paperback version I converted the Pandoc to a LibreOffice document with a custom template; this let me do all the fine-tuning for the styles, paragraph flow, etc. I wonder if you tried this and decided LaTeX was better, or if you went for LaTeX due to your previous familiarity with it. I have the feeling that for my novel it would have been overkill; did you get most of the value by having precise control of the layout of the images? (btw, the "Power Move One – Conditionals" anchor seems to be broken) [0] https://gabrielgambetta.com/tgs-open-source.html https://gabrielgambetta.com/tgs-open-source.html
- enriquto 6y ago> I wonder if you tried this and decided LaTeX was better, or if you went for LaTeX due to your previous familiarity with it. I have the feeling that for my novel it would have been overkill Don't know about the author, but having written a few lecture notes to be converted to pdf and html, I have found that writing the source document in LaTeX is much more convenient than markdown, especially for math-heavy text. The LaTeX->pdf conversion is natural, and then you can convert easily to html+mathjax using a simple script.
- teruakohatu 6y agoA variety of markdown formats, for example R Markdown, support latex math syntax. The markdown document ends up being compiled to latex anyway, so markdown in this scenario is just a easy way to write latex with less hassle.
- jamessb 6y agoYes - pandoc supports latex math if the `tex_math_dollars` extension is enabled: https://pandoc.org/MANUAL.html#math https://pandoc.org/MANUAL.html#math
- sgt 6y agoGreat stuff Dan. So what is your next project? You've been around the world twice now. Is there anything left to see? (More of a rhetorical question:)
- baby 6y agoQuestion: can you sell an epub on your own website, as well as amazon? Or does amazon get full exclusivity because you’re publishing through their platform?
- bryanrasmussen 6y agothere are different deals you can have through Amazon, so you can have a deal where you sell exclusively through Amazon or one where you don't https://www.thebookdesigner.com/2018/05/selling-out-going-wide-or-going-exclusive-to-amazon/ https://www.thebookdesigner.com/2018/05/selling-out-going-wi...
- asicsp 6y agoCongrats on self-publishing your books and thanks for the details on the book generation. If you didn't already know, I would also suggest to check out Gumroad/Leanpub for selling ebook versions. >No comments about my sed magic please The commands are fine. Had a doubt if you are using GNU sed or some other flavor since you mention MacOS a few paras earlier. If you are not using GNU implementation, `-i -e` will likely create backup files with `-e` as extension. See [0] for details. For the Perl command, `-0` option will use ASCII NUL as the record separator. To slurp entire file, pass a value 400 or greater, `-0777` is idiomatically used. If your input doesn't have NUL characters, which is likely the case here, this distinction doesn't play a role. [0] https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux https://stackoverflow.com/questions/5694228/sed-in-place-fla...
- PascalPrecht 6y agoOh that's so cool! Didn't know that publishing on Amazon was so straight forward! I've done a similar thing wrote about it here: https://pascalprecht.github.io/posts/writing-an-ebook https://pascalprecht.github.io/posts/writing-an-ebook Instead of using Latex, I went with markdown as the source to generate PDFs, Mobi and Epub from that. Thanks for sharing your experience!
- wombat23 6y agoHaving your own book in your hands feels awesome. I've done the same, but not with KDP. Unfortunately, I can't publish it as I had to give up my rights to it (screw you OUP/publishing requirements!). On the technical side, it wasn't so straightforward to me to get a good result. In my case, I had to iterate a few times and order a new copy with adjustments to margins, etc. until it looked right. One issue I didn't manage to solve back then was that the inner margin needs to slightly increase towards the end of the book. That's because the binding is eating up visual space since you can't open the book flat without destroying it. Professional publishing tools do this automatically, but Latex doesn't have an option for it. At least that's how I remember the issue. But maybe things have changed?
- nanna 6y agoI've not come across this myself, but pretty sure if you asked on tex.stackexchange.com someone would knock up a macro to do it for you, if one didn't already exist.
- Prcmaker 6y agoI had alternating margin issue sorted out for my thesis, and remember it being easy once I figured it out. Can't for the life ofme remember what it was right now though.
- valarauko 6y agoI think you're describing the book layout, which has a broader inner margin by default. So pages destined for the left side have a wider right margin, and vice versa. The parent is describing a situation where the inner margin has to get progressively wider as page numbers increase, which I'd personally never heard of. It does sound like something a macro could handle.
- wombat23 6y agoYes, that's what I meant. Perhaps it's related to the way the printing company produced the books, so this might not be an issue with other companies. My memory is a bit fuzzy about the details, maybe it was about the inner margins of left-hand side and right-hand side changing. Maybe someone else recognises what I mean? :) Since Latex is very powerful, I'm sure there is a way to code that behaviour in. But I had spent too many hours already on that project and I was happy with the result anyway, so I stopped investigating.
- kleiba 6y agoIt would have been interesting to learn if Dan spent any time/effort advertising the book, and perhaps if it was financially worthwhile. Congratulations on doing what lots of folks only dream about!
- xvilka 6y agoI wish that would have been possible with mdBook too. Sadly, it can't even generate PDF or ePub[1][2]. Compared to gitbooks from which we switched to mdBook it's a significant downgrade. [1] https://github.com/rust-lang/mdBook/issues/815 https://github.com/rust-lang/mdBook/issues/815 [2] https://github.com/rust-lang/mdBook/issues/88 https://github.com/rust-lang/mdBook/issues/88
- strzibny 6y agoI started with gitbook for deploymentfromscratch.com but run into various issues and now adopted a similar approach to OP by using Pandoc with Markdown and some Latex here and there (like some custom boxes). I really wish there is something more streamlined :(
- jtbayly 6y agoDid you try bookdown? https://github.com/rstudio/bookdown/ https://github.com/rstudio/bookdown/
- xvilka 6y agoYes, it's a viable alternative, maybe it makes sense to add a second GitHub Action for our book to build PDF and ePub.
- lights0123 6y agohttps://github.com/Michael-F-Bryan/mdbook-epub https://github.com/Michael-F-Bryan/mdbook-epub is experimental
- prionassembly 6y agoWhile I'm sure Dan's book is really good, I wish he had shared with us some tidbits of how he actually went from "I want to write about these things" to a publishable book. I understand why someone wouldn't want through the traditional route (my wife is in book publishing and I might self-publish within the decade), but there's a whole book preparation process (concept validation? early reviews? someone who could approximate the work of editorial preparation? proof-reading?). Most of the work in making a book is not in the typesetting.
- anthk 6y agoAlso, for something far lighter: https://schaffter.ca/mom/mom-01.html https://schaffter.ca/mom/mom-01.html
- xbar 6y agoYour bravery with LaTex inspires me to take my writings and self-publish. I'm afraid to read your books because your bravery may inspire me to road trip to Africa.
- tuomosipola 6y agoInteresting that there is a Createspace package! They seem to have taken the "inject weird PDF objects straight from LaTeX" route. The other route is the pdfx package, which I ended up using. I have been struggling with this and finally got my class to produce possibly PDF/X-4 compatible printable file and PDF/A-2b compatible PDF file for archival purposes. Maybe the next step is adding epub generation from the same LaTeX source.
- impostervt 6y agoI've published several book on Amazon KDP, and just want to mention you don't need Latex or markdown or anything complicated. Word works fine. You can pay someone on Fiverr to convert it into the formats you need for $10, or you can go with slightly more expensive services ($60ish) if you want someone to spend some time making it look nice. This is for straight narratives or non-fiction books. Things with more complex layouts will require more work.
- blackrock 6y agoDid you get a lot of sales?
- impostervt 6y agoAround 30-50 sales per day, spread out over 4 books.
- lbriner 6y agoI find these articles really interesting, within the reach of most developers. However, writing a book must take an incredible amount of time. I have started several but then got bored after a couple of chapters! I guess the trick is to write about something you have a special "qualification" to write so that you are not just writing something that will only sell 100 copies after taking a year of your life! Being James Patterson would probably be great but it takes time to get the success that then pays for you to sit and churn stuff out at the rate he does! I need to go back to work now...
- ultrasounder 6y agoNice job. Also very envious about your globetrotting. I am also in the process of writing my book(to be published as an open-source project) that supports a particular learning audience. I plan to use Bookdown after reading through several recommendations here on HN. I wish You the best with the process.