Having 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?
I'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.
I 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.
I 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.
Yes, 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.
Congratulations 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)
> 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.
For a technical book I fully agree, my other book [0] is written in LaTeX. But this doesn't seem to be the case for OP, and definitely wasn't the case for my novel, so I'm curious :)
I self-published a 300 page book through Ingram in 2012. It is pretty niche and only sells about 200 physical and 50 or so Kindle copies a year. The whole thing was done in LaTex with a Tufte book package; there are a few tables and images but the vast majority is text.
Have had many unsolicited comments from those who have handled/thumbed through it about the high quality of the book (look/layout/feel) - most are surprised that it was not done by a 'big' publishing house. Frankly, my own opinion is that the quality is at least equal, probalby higher, than what is being churned out today by big names today. Part of that is the format/layout as a result of using LaTex, the rest is the physical material characteristics from using an excellent printer. None of that speaks to the actual content, of course :)
I did eventually make a kindle version, unfortunately I do not recall the tool chain used.
Highly recommend Lightning Source (Ingram) for your printing/distribution needs if you are serious about your publication.
I've published 20+ books, mostly fiction, using LaTeX (specifically XeLaTeX), as there are a host of fine-tuning tools available through packages, basic settings that can be played with, and the built-in spacing that just looks...better. XeLaTeX also allows using pretty much any font you like, along with easy typographic control down to letterforms. I also like the ability to play with book/page/margin sizes that can be tested with a couple small changes to the source document & a recompile. I'm not sure I would recommend learning LaTeX just to do this, but if you're familiar with it, the rewards are there.
Microtype package works best with XeLaTeX, it allows finer control over the spacing/kerning and cleaning up the tex that cause some weird errors during compilation
A 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.
I can imagine that your way of doing things becomes very complicated once you want to do edits and now have two types of files to keep in sync all the time (md and office).
The point of OP is that you keep one type of file. Also doing mass edits or source control with office must be a nightmare.
I can’t even imagine how hard it must be to get details right as well. As horrible as latex is, it still gives you much more control.
In my case the canonical text is the markdown file. The LibreOffice file is then generated using Pandoc from the markdown file + a document template for the page and paragraph styles. So there's no manual sync to be done, just edits on the markdown file and running a script.
> Congratulations on the publication, such a fantastic achievement!
Eh? With all the great tools and self-publishing options available these days, publishing a book is not a fantastic achievement. In fact, anyone can do it. Writing a book is no achievement either, especially if it is not of great quality. It simply takes a bit of time.
Congratulations, 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?
> 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 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.
Correct. 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]
These 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.
When 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.
I 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.
The CSS `hyphens` property allows the browser (or ereader) to automatically hyphenate, and is usually set to off by default. It works fairly well in a browser context, and currently has limited support in ebook context. Kepubs on Kobo for example support it, but the result isn't as good as directly inserting soft hyphens into the text.
yes, 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 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.
That’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)
I 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.
I 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 :(
I'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.
While 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.
Congrats 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.
I 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...
Interesting 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.
Nice 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.
Nice 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.
LaTeX 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.
I know it's a lot of setup, but how exactly is it horrible? I can imagine writing something in MS Word or Google Docs being horrible as the document grows. At least with LaTeX you can use a text editor, even vim if you want.
Everything needs to be Googled, all the time. Want to include an image? Google it. Install a package. Google more for arguments. Want to center the image? Google. Want to insert a table? Google. Oh a line in the table is too long, how to wrap it? Google. Decide between 3-4 options all having different shortcomings. Install new package. Which requires different arguments than the other command. Google. Insert an accented letter? Google. Insert a Chinese character? Google, package, google.
Everything is a pain to do, and I just described the happy path. If you try to do something a little tricky you easily run into incompatible packages wreaking with each other. Word has its shortcomings for sure, but for writing a short paper it’s a magnitude or two more easier and faster (except when a coworker uploaded it in Google Docs with deleted the styles...)
To be fair I've used lots and lots of Unicode (here: "characters not contained in US-ASCII") in XeLaTeX but have also had the need for some symbolic / numeric codepoints. I can tell you the syntax to do so is horrible. And yes I'd have to google that syntax before I could do it again.
It’s just extremely complicated and the ecosystem has badly aged (yeah you need makefile and docker if you want to do it right, and nobody uses docker)
First time I heard docker as a prerequisite to TeX usage. Cross-platform comprehensive LaTeX distributions have been there since at least the mid-90s.
And the ecosystem actually is quite good these days. You always had pretty good editor support in the "nerdy" ones, but these days there are also friendlier frontends like Lyx, Texpad, Texstudio or the collaborative web-based Overleaf.
The backend isn't that bad, either. The days of specialized output and font formats are gone, using any system TTF/OTF and producing PDF is easy enough with pdfTeX, luaTeX adds lua-based scripting to that and ConTeXt does all that plus better access to layout primitives and typographical features. And I'm sure the Rust Rewrite Liberation Front is active in TeX, too.
The worst thing in the TeX world, ironically, is documentation. There's a lot of stuff out there that didn't keep up with all the new features and possibilities.
It’s not a prerequisite, the proof is that no one seems to use docker to build latex. That’s what I meant: it’s an ugly mess and you’ll spend hours trying to compile things like you’re dealing with autotools and a C codebase, and people don’t even use docker.
I wouldn’t say the ecosystem is good. Every time you want to add a new extension you’ll be in a world of pain. I prefer customizing emacs at this point.
Depends on what you're trying to do. To publish an article or book - no it's not very complicated. There's a vast package ecosystem and knowing where to turn can be daunting, but there is great community documentation out there such as by Overleaf[1] and the community on stack exchange is lively and lovely.
Building your own functionality can be complicated, however partly this comes down to LaTeX being a very different programming paradigm to the conventional C-like languages.
> the ecosystem has badly aged
Care to substantiate?
> you need makefile and docker if you want to do it right, and nobody uses docker
Simply untrue. If you have a setup that warrants more than a conventional setup there are native-LaTeX build tools like arara which are simple to use.[2]
Once you've got your document working the way you want it it's lovely. It's the journey that's bumpy. This is the same complaint PhD students have been making for at least thirty years.
Yes, initially it is far more effort into the document you want to create. But once you start to be familiar with the marcos and packages, then it become easier to do the document formatting. Honestly, I am still learning how to use LaTeX and I found it to be superior to Word because LaTeX allows me to edit it at the source (allowing finer control over the document) than relying on Word's WYSIWYG or any word processor to provide a virtual page until it is printed. The issue with WYSIWYG processor, there are chances that formatting will move around or clipped out the pages. That become more work to figure out how to get to fit in a single page, despite that WYSIWYG shows it is in the single page (the printed document show two pages). It is more hell to work with the table in Word than in LaTeX as Word have a weird table padding (really really hard to control this than in LaTeX) that lead the document to look a bit off.
I started learning few weeks ago and now working on two additional documents because I start to understand of how to use it and it become quicker from there. But again every person have a different approach with learning LaTeX.
The 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.
Agree, 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
Indeed, I've used pandoc to deliver above average looking documents easily on the occasions it's been required. On the rare occasions I've had to use Word directly I didn't struggle to stick to the theme, though. What did you find difficult?
I’ve just never really used word by sticking to a theme, and tend to end up using custom formatting quite a bit e.g. I use heading 2 where I shouldn’t and should be using heading 1, use paragraphs in the wrong place etc.
Use some custom formatting in a paragraph when I should be using a preset default etc
Question: 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?
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?