{"article":{"slug":"novellas-with-groff","title":"Novellas with groff","subtitle":null,"summary":"A developer who wrote two private novellas walks through the toolchain: typesetting with groff (basic formatting, footers and page numbers, headers, traps, inter-sentence spacing, German hyphenation) plus a Markdown-based workflow, and reflects on the writing process itself.","content_type":"tutorial","language":"en","canonical_url":"https://movq.de/blog/postings/2026-10-31/0/POSTING-en.html","author":{"name":"movq","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"movq.de","url":"https://movq.de/blog/","listing_slug":null,"listing":null},"topics":[{"name":"writing","slug":"writing","url":"https://listedarticles.com/topics/writing"},{"name":"linux","slug":"linux","url":"https://listedarticles.com/topics/linux"},{"name":"tutorials","slug":"tutorials","url":"https://listedarticles.com/topics/tutorials"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":4197,"reading_minutes":18,"published_at":"2026-10-31T00:00:00.000Z","added_at":"2026-11-01T17:09:12.138Z","updated_at":"2026-11-01T17:09:12.138Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/novellas-with-groff","markdown_url":"https://listedarticles.com/articles/novellas-with-groff.md","example":false,"citation":"movq, movq.de. \"Novellas with groff.\" 31 Oct 2026. https://movq.de/blog/postings/2026-10-31/0/POSTING-en.html (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://movq.de/blog/postings/2026-10-31/0/POSTING-en.html"},"body_markdown":"# Novellas with groff\n\n2026-10-31\n\nI recently finished my second \"novella\".\n\n[![pdfinfo-wc.png: Screenshot of the output of 'pdfinfo' and 'wc': About 50 pages / 15k words for the first document, 120 pages / 40k words for the second one.](https://movq.de/blog/postings/2026-10-31/0/t/pdfinfo-wc.png.jpg \"Screenshot of the output of 'pdfinfo' and 'wc': About 50 pages / 15k words for the first document, 120 pages / 40k words for the second one.\")](https://movq.de/blog/postings/2026-10-31/0/pdfinfo-wc.png)\n\nDon't even think about it: I won't publish this. Nor send it to you\nprivately, which is mostly the same as publishing it.\n\nThe first story is roughly 50\n[A5 pages](https://en.wikipedia.org/w/index.php?title=DIN_A5)\nlong (~15k words), the second one is about 120 pages (~40k words). (Both\nbarely fit the\n[definition of a \"novella\"](https://en.wikipedia.org/wiki/Novella),\napparently, with the first one being a bit too short and the second one\na tiny bit too long.)\n\nIt feels pretty absurd and surreal that I have done this at all. In\nschool, *anything* related to \"writing\" was pure horror for me -- unless\nit was related to maths, physics, or other \"technical\" stuff. But here\nwe are.\n\nHow long did it take? Well, the first one took over seven months. But\nthe second one, the longer one? Ten days.\n\nSome time last year, probably around July, I started reading some of the\nbooks that were lying around in my appartment for decades. And this was\nmuch more enjoyable than I thought. No idea why. It's not like I never\nread a book before, but it was always a somewhat boring thing to do and\nit took me ages -- unless it was something technical. I'm only referring\nto fiction and novels here. Like, one book per year, tops. Yet, I\nsomehow got hooked last year and now I've read about 30 novels since\nJuly 2025. Some faster (a couple of days), some slower (three months).\n\nIt wasn't that much of a stretch to try to do this myself.\n\nThis blog is still technical in nature, so I'll walk through the\nsoftware that I used.\n\n---\n\nTable of contents:\n\n- [groff](#groff)\n  - [Basic formatting](#basic-formatting)\n  - [Footers and page numbers](#footers-and-page-numbers)\n  - [Header](#header)\n  - [A closer look at traps](#a-closer-look-at-traps)\n  - [Inter-sentence spacing](#inter-sentence-spacing)\n  - [German hyphenation](#german-hyphenation)\n- [Markdown and other pre-processing](#markdown-and-other-pre-processing)\n- [Vim](#vim)\n  - [Goyo](#goyo)\n  - [Reflowing text](#reflowing-text)\n- [Git](#git)\n- [demo-book.tar.gz: Putting it all together](#demo-booktargz-putting-it-all-together)\n- [The writing process itself](#the-writing-process-itself)\n- [Where to go from here?](#where-to-go-from-here)\n\n---\n\n## groff\n\nBoth of my books (they're not really \"books\", but I'll keep referring to\nthem as such for the sake of simplicity) are typeset in\n[groff](https://www.gnu.org/software/groff/).\nYou know, the thing that usually renders manual pages in your terminal\non Linux. groff/troff is a full typesetting system, though, and it can\nbe used to\n[produce real books](https://www.troff.org/pubs.html), which I've\nalready mentioned a couple of times in\n[previous blog posts](https://movq.de/blog/postings/2025-08-30/0/POSTING-en.html).\n\n[![troff-books-1.webp: Photo of my copies of 'The C Programming Language', 'The UNIX Programming Environment', and 'UNIX Network Programming'.](https://movq.de/blog/postings/2026-10-31/0/t/troff-books-1.webp.jpg \"Photo of my copies of 'The C Programming Language', 'The UNIX Programming Environment', and 'UNIX Network Programming'.\")](https://movq.de/blog/postings/2026-10-31/0/troff-books-1.webp)\n[![troff-books-2.webp: A page of 'The C Programming Language'.](https://movq.de/blog/postings/2026-10-31/0/t/troff-books-2.webp.jpg \"A page of 'The C Programming Language'.\")](https://movq.de/blog/postings/2026-10-31/0/troff-books-2.webp)\n[![troff-books-3.webp: A page of 'UNIX Network Programming', showing some diagrams.](https://movq.de/blog/postings/2026-10-31/0/t/troff-books-3.webp.jpg \"A page of 'UNIX Network Programming', showing some diagrams.\")](https://movq.de/blog/postings/2026-10-31/0/troff-books-3.webp)\n\nIn my case, the appeal of groff is that it's relatively small and\n*fast*, but still able to produce high-quality output. Making that\n50-page document takes about *700 ms* on my 13.5 year old PC, and the\n120-page one takes *1.6 seconds*. This includes some pre-processing\nwhich we'll cover later. Given that most modern software these days\nfeels like walking in mud, this is refreshingly quick.\n\nBecause it's more fun that way, I made my own little macro package.\nThere really isn't a lot to it, though. It's tiny. Not a lot is needed\nfor a simple novel / novella -- no table of contents, no\ncross-references, no diagrams, no code blocks, no lists, ... Just nicely\nflowing text and *sometimes* a word gets emphasized.\n\nDisclaimer: You'll note some TODO items in the text below. groff is a\nfull-blown typesetting system and these things are complicated. I'm a\nlong way from having mastered every aspect of it.\n\n### Basic formatting\n\nThere are only three macros:\n\n```\n.\\\" Section header / chapter title\n.de SH\n.   sp 1v\n.   ps +5p\n.   ce\n\\f[HR]\\\\$1\\fP\n.   ps\n.   sp 4v\n..\n.\\\" Normal paragraph with hanging indent.\n.de PP\n.   br\n.   ti +2m\n..\n.\\\" \"Long\" paragraph, longer empty space.\n.de LP\n.   sp 2v\n..\n```\n\n(The name `SH` is a spill-over from manual pages. I've written quite a\nfew of those and this name somehow stuck. `CH` for \"chapter heading\" or\n`CT` for \"chapter title\" might have been better choices. Or, you know,\n`.CHAPTER`.)\n\nYou start defining a macro with `.de` -- anything until `..` is part of\nthat macro.\n\n- `.SH`: Go down one\n  [vee](https://www.gnu.org/software/groff/manual/groff.html.node/Measurements.html),\n  increase type size, request centering, print the macro's first\n  argument with the `HR` font (Helvetica), return to previous type\n  size, add another four vees of space.\n- `.PP`: Just break the current line, then request a temporary indent\n  for the next output line. This creates a hanging indent, which is\n  customary in German books.\n- `.LP`: Just some empty space between paragraphs. Used for things\n  like intra-chapter time jumps.\n\nYou can look up the individual commands in `man 7 groff`.\n\nAnd that would already be enough to produce a document that somewhat\nresembles a book.\n\nPut the snippet above in a file called `macros.groff`. I made one file\nper chapter. For example:\n[`chapter01.groff`](https://movq.de/blog/postings/2026-10-31/0/chapter01.groff).\nYou can then make a PDF using a command like this:\n\n```\ngroff -Tpdf -dpaper=a5 -P-pa5 macros.groff chapter01.groff >book.pdf\n```\n\nA5 is roughly the page size of a \"typical book\".\n\n### Footers and page numbers\n\nYou'll note that there are no page numbers by default. You could\nactually just decide to not have them if all you want is a digital PDF.\nThey're useful for printing, but you don't really need them in a file,\nif we're being honest.\n\nExcept: The thing gets confused about page breaks. Create the PDF using\nthe example above and you'll see:\n\n[![wrong-page-break.webp: PDF viewer screenshot: Last line of text outside of the page.](https://movq.de/blog/postings/2026-10-31/0/t/wrong-page-break.webp.jpg \"PDF viewer screenshot: Last line of text outside of the page.\")](https://movq.de/blog/postings/2026-10-31/0/wrong-page-break.webp)\n\nLooks like the baseline of the last line of output is just outside the\npage. Not sure what's going on here -- it's related to setting the page\nsize to A5. In other words, I probably missed *another* spot where this\nhas to be set. It'll be fixed implicitly by the following.\n\nThe whole page number thing consists of three parts: First, how large is\nthe footer (the area where the page numbers live)? I defined this in a\n[register](https://www.gnu.org/software/groff/manual/groff.html.node/Setting-Registers.html)\n(which is not really necessary but I find the \"code\" easier to read this\nway) -- the name is arbitary:\n\n```\n.nr _FooterSize 5v\n```\n\nWe than plant a\n[trap](https://www.gnu.org/software/groff/manual/groff.html.node/Page-Location-Traps.html)\nat the bottom of the page:\n\n```\n.wh -\\n[_FooterSize]u _FooterTrap\n```\n\n`\\n[_FooterSize]` \"gets\" the value of the register called `_FooterSize`.\nThere's a minus sign in front of it, it's negative and relative to the\nbottom of the page.\n[The documentation says](https://www.gnu.org/software/groff/manual/groff.html.node/Default-Units.html):\n\n> A general-purpose register (one created or updated with the nr\n> request) is implicitly dimensionless, or reckoned in basic units if\n> interpreted in a measurement context.\n\nI'm not 100% sure why I need to add the `u`. I haven't read every page\nof the manual, yet. Needless to say, it doesn't work without it.\n\nOkay, so the trap gets installed at 5v before the end of the page and\nit'll call the `_FooterTrap` macro. It looks like this:\n\n```\n.de _FooterTrap\n.\\\" Push current environment on stack and switch to `_FooterEnv`.\n.\\\" Parent env will keep partially collected lines.\n.   ev _FooterEnv\n.\\\" Copy settings from default environment.\n.   evc 0\n.\\\" Don't do this for pages 1 and 2, they're title pages in my actual\n.\\\" \"book\".\n.   if \\\\n[%]>2 \\{\\\n.\\\" Set vertical position, explained in the text below.\n.       sp |\\\\n[.p]u-2v\n.\\\" Print % register centered.\n.       ce\n\\fR\\\\n[%]\\fP\n\\}\n.\\\" Go back to previous environment.\n.   ev\n.\\\" Request page break.\n'   bp\n..\n```\n\nIt's much easier to read without the inline comments:\n\n```\n.de _FooterTrap\n.   ev _FooterEnv\n.   evc 0\n.   if \\\\n[%]>2 \\{\\\n.       sp |\\\\n[.p]u-2v\n.       ce\n\\fR\\\\n[%]\\fP\n\\}\n.   ev\n'   bp\n..\n```\n\nWhy is it `'bp` instead of `.bp`? We'll get to that.\n\nWhat I'm unsure about: I set the vertical position to `|\\\\n[.p]u-2v`.\nThat's relative to the *top* of the page, it's the page length minus two\nvee. I would have expected `|-2v-1v` (including the \"minus one vee\"\nmentioned in the docs) to also work, but that leads to an infinite loop\n(probably triggers the same trap again and again). Why?\n\n### Header\n\nFor symmetry, I also want some empty space at the top of the page:\n\n```\n.nr _HeaderSize 5v\n.de _HeaderTrap\n'   sp |\\\\n[_HeaderSize]u\n..\n.wh 0v _HeaderTrap\n```\n\nAnd another TODO for me: This isn't 100% symmetrical. The length of the\nheader is a bit larger than the footer. An issue with the page size\nagain?\n\n### A closer look at traps\n\nLet's have a closer look at traps. I'm not *100%* sure on this -- this is\nto the best of my understanding.\n\nActually, let's take a step back from the example above. Let's start\nwith this:\n\n```\nThis is a little excerpt from Mary Shelly's Frankenstein.\n\nThese visions faded when I perused, for the first time, those poets\nwhose effusions entranced my soul and lifted it to heaven. I also became\na poet and for one year lived in a paradise of my own creation; I\nimagined that I also might obtain a niche in the temple where the names\nof Homer and Shakespeare are consecrated. You are well acquainted with\nmy failure and how heavily I bore the disappointment. But just at that\ntime I inherited the fortune of my cousin, and my thoughts were turned\ninto the channel of their earlier bent.\n\nSix years have passed since I resolved on my present undertaking. I can,\neven now, remember the hour from which I dedicated myself to this great\nenterprise. I commenced by inuring my body to hardship. I accompanied\nthe whale-fishers on several expeditions to the North Sea; I voluntarily\nendured cold, famine, thirst, and want of sleep; I often worked harder\nthan the common sailors during the day and devoted my nights to the\nstudy of mathematics, the theory of medicine, and those branches of\nphysical science from which a naval adventurer might derive the greatest\npractical advantage. Twice I actually hired myself as an under-mate in a\nGreenland whaler, and acquitted myself to admiration. I must own I felt\na little proud when my captain offered me the second dignity in the\nvessel and entreated me to remain with the greatest earnestness, so\nvaluable did he consider my services.\n```\n\nSave it as `test.groff` and make a PDF:\n\n```\ngroff -Tpdf test.groff >book.pdf\n```\n\nLooks like this:\n\n[![traps-1.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-1.webp.jpg \"traps-1.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-1.webp)\n\nInstall a trap at 10v. It's empty so far and does nothing -- insert this\nat the very top of the file:\n\n```\n.de MyTrap\n..\n.wh 10v MyTrap\n.\\\"\n```\n\nThe PDF looks the same.\n\nNow what happens when we change the trap macro to this?\n\n```\n.de MyTrap\nFOO\n..\n```\n\nThis is the result:\n\n[![traps-2.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-2.webp.jpg \"traps-2.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-2.webp)\n\nWhen the output reached the word \"fishers\", it sprang the trap. \"FOO\"\ncomes after \"fishers\" in the PDF: \"fishers\" triggered the trap, then\n\"FOO\" got inserted. I think it's as simple as that, isn't it?\n\nSuppose we want to put \"FOO\" at the beginning of the line and we want\nnothing but that word on that line. \"fishers\" shall be put on the next\nline.\n\nIf I understand correctly, switching environments is key: The\nenvironment holds the currently collected line (among many other\nthings). Switch to a new one and we get a new buffer/line -- one that's\nempty so far. We can then flush/break this line to have it included in\nthe PDF, and then switch back to the previous environment:\n\n```\n.de MyTrap\n.   ev MyTrapEnv\nFOO\n.   br\n.   ev\n..\n```\n\nLooks like this:\n\n[![traps-3.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-3.webp.jpg \"traps-3.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-3.webp)\n\nSo far, so good. Now I want there to be an empty line before and after\n\"FOO\":\n\n```\n.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n..\n```\n\nIn the new environment, we issue `.sp`: It breaks and inserts space.\nNothing was collected so far, so the break doesn't print anything at\nthis point. Then we have `FOO` -- this isn't printed directly, it's just\ncollected. The next `.sp` breaks again (thus printing \"FOO\") and then\ninserts more space.\n\n[![traps-4.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-4.webp.jpg \"traps-4.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-4.webp)\n\nOkay. Now. Suppose that printing \"FOO\" with those two lines around it is\nall we want to do inside of the trap. We then want the normal text to\ncontinue at some absolute position on the page, say at 17v.\n\nSo, how about the following? We go back to the previous environment and\nthen issue an absolute location request:\n\n```\n.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n.   sp |17v\n..\n```\n\nOops:\n\n[![traps-5.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-5.webp.jpg \"traps-5.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-5.webp)\n\n`.sp |17v` broke the already collected line (the one with just \"fishers\"\nin it) and *then* inserted the space. We don't want that break. (Also\nnote that \"fishers\" is at the exact same position where we left off\ninside the trap.)\n\nThis can be avoided by using `'` instead of `.`:\n\n```\n'   The neutral apostrophe is the no-break control character, rec‐\n    ognized where the control character  is.   It  suppresses  the\n    (first) break implied by the bp, ce, cf, fi, fl, \"in\", nf, rj,\n    sp,  ti,  and trf requests.  The requested operation takes ef‐\n    fect at the next break.\n```\n\nSo let's do this:\n\n```\n.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n'   sp |17v\n..\n```\n\nResult:\n\n[![traps-6.webp](https://movq.de/blog/postings/2026-10-31/0/t/traps-6.webp.jpg \"traps-6.webp\")](https://movq.de/blog/postings/2026-10-31/0/traps-6.webp)\n\nThe example in\n[the documentation](https://www.gnu.org/software/groff/manual/groff.html.node/Page-Location-Traps.html)\ndoesn't change environments. But I find it much easier to understand\nwhat's going when changing them. (And I hope I got it right.)\n\nOne final remark: Environment carry settings. `.ev foo` starts a\ncompletely new environment (unless an environment with that name already\nexists), it doesn't clone the previous one. That's why my macro package\nalso does `.evc 0`.\n\nAs a little exercise, see what happens when you use `'sp |12v`, `'sp\n|11.5v`, `'sp |11v`, all the way down to `'sp |9v`.\n\n### Inter-sentence spacing\n\nOnly when writing this blog post, I found the following sentence in\n[the docs (Basics)](https://www.gnu.org/software/groff/manual/groff.html.node/Basics.html):\n\n> If you don't start a sentence on a new line, put two spaces after the\n> previous sentence. GNU troff then recognizes punctuation that ends a\n> sentence, and inserts inter-sentence space accordingly.\n\nI didn't do that, because this isn't customary in German. But now I see\nit. Sometimes, it looks like this in the PDF:\n\n```\nFoo. Bar.\n```\n\nAnd sometimes there's a little bit of extra space:\n\n```\nFoo.  Bar.\n```\n\nAs far as I know, this is usually not done in German books. I disabled\nit with this request, which keeps \"minimal inter-word spacing\" at the\ndefault value of 12 but sets \"supplemental inter-sentence spacing\" to 0:\n\n```\n.ss 12 0\n```\n\nThis isn't part of my macro package, but it comes first in the \"index\"\nfile (`book.groff`, see demo package below).\n\n### German hyphenation\n\nApparently, it's as simple as this:\n\n```\n.hla den\n.hpf hyphen.den\n```\n\n`den` is \"de(utsch) new\": This includes the \"new\" German rules from\n2006.\n\n## Markdown and other pre-processing\n\nI actually wrote both of my stories in plain groff, using the macros I\nexplained above.\n\n[Markdown](https://en.wikipedia.org/wiki/Markdown)\nhas the big advantage of being \"visually pleasing\": It mostly looks like\ntext that is intended to be read by a human being. groff isn't, really.\nI mean, it wasn't *horrible*, I wouldn't have written over 170 pages in\ngroff if this was *pain*. It's fine. I use groff in several other places\nas well. But Markdown is a tiny little bit better, and I assume that it\nallows me to focus more on the creative process.\n\nSo, afterwards, I converted the second story to \"Markdown\". Didn't\nbother to do that for the first one. I put that in quotation marks\nbecause there are only very few elements, it's not full Markdown:\n\n- `# Chapter title` at the top of the file.\n- Empty lines between paragraphs, `---` for \"long empty paragraphs\".\n- `*foo*` for emphasized text.\n\nAnd that's it. Makes the conversion really easy.\n\nI could have just use plain Markdown for this whole thing and created an\nHTML file. I already have the tooling for that -- that's what drives my\nblog. Maybe this could even produce a PDF file. But what would be\nmissing there, among other things, would be an engine to *properly\njustify text*. It hurts my eyes to see justified text in HTML, it just\nlooks like a complete disaster. The results that groff or TeX create are\nmuch, much better.\n\nWhile we're at it, we can also do some basic character replacements: I\nhave the German typographic quotation marks U+201E and U+201C directly\non my keyboard, but\n[Guillemets](https://en.wikipedia.org/wiki/Guillemet)\nare preferred in books.\n\nI first wanted to do all this in Python but then switched to a little\nPerl snippet, because it makes it easy to read the entire file and then\ndo multiline-regex stuff on it. It goes something like this:\n\n```\nperl -0pe '\n# Guillemets are preferred in books.\ns/... German typographic quotes, see demo package .../... Guillemets .../g;\n\n# Markdown \"h1\" into \".SH\".\ns/^# ([^\\n]+)\\n/.SH \"\\1\"\\n/smg;\n\n# Markdown \"hr\" into \".LP\".\ns/\\n---\\n/.LP/smg;\n\n# Markdown paragraphs into \".PP\".\ns/\\n\\n/\\n.PP\\n/smg;\n\n# Markdown emphasize into groff font selection:\ns/\\*([^*]+)\\*/\\\\fI\\1\\\\fP/smg;\n'\n```\n\nThe output is still groff for my little macro package. But I can now\nwrite it like this:\n\n```\n# Kapitel 42: Die Antwort\n\nDa war sie also. Die Antwort auf *alle* Fragen.\n\nUnd dann ging es weiter:\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum\nhendrerit blandit suscipit. Maecenas sed nisi nec ante mattis\nvulputate. Pellentesque maximus leo id purus vestibulum dictum.\nDonec tincidunt mollis viverra. Curabitur at ligula in turpis\npellentesque vehicula.\n\nDuis hendrerit commodo mauris, non posuere leo vulputate ut. Nulla\nfinibus urna eget vehicula auctor. Mauris in posuere nibh. Vivamus\nut metus vel nisi gravida molestie vitae et tellus. Integer mi odio,\nvestibulum eget laoreet vel, auctor nec ligula. Quisque eu placerat\nquam, eu tincidunt mauris. Nam vestibulum lectus non leo dignissim,\nnon sagittis dolor venenatis.\n```\n\nThis reads much nicer and there is syntax highlighting in Vim for it.\nWell, the `*emphasized*` parts, that is -- the rest doesn't matter:\n\n[![vim-md.png: Screenshot of Vim with standard Markdown highlighting: Emphasized text uses the terminal's 'standout' attribute.](https://movq.de/blog/postings/2026-10-31/0/t/vim-md.png.jpg \"Screenshot of Vim with standard Markdown highlighting: Emphasized text uses the terminal's 'standout' attribute.\")](https://movq.de/blog/postings/2026-10-31/0/vim-md.png)\n\nSpeaking of Vim ...\n\n## Vim\n\n### Goyo\n\nThere is one super important\n[Vim](https://vim-classic.org/)\nplugin for this:\n\n<https://github.com/junegunn/goyo.vim>\n\nIt hides almost all UI elements.\n\nOn top of that, I put the terminal window in fullscreen mode to hide my\ndesktop.\n\nAnd there you go. \"Distraction-free writing\" indeed. Maybe put on some\nmusic, but there's nothing else. No browser, no clock, no nothing. Just\na typewriter with an easy undo function.\n\n[![vim-photo.webp: Photo of Vim with Markdown highlighting and active Goyo, terminal in fullscreen mode.](https://movq.de/blog/postings/2026-10-31/0/t/vim-photo.webp.jpg \"Photo of Vim with Markdown highlighting and active Goyo, terminal in fullscreen mode.\")](https://movq.de/blog/postings/2026-10-31/0/vim-photo.webp)\n\nThe font is the 11x22 variant of\n[UW ttyp0](https://people.mpi-inf.mpg.de/~uwe/misc/uw-ttyp0/).\n\n### Reflowing text\n\nThere's a popular way to format text in plain-text files:\n\n```\nThis is one sentence.\nThis is another one.\nAnd so on and so on.\nOne sentence per line, that's it.\nSentences can be short.\nOr they can be pretty long, sometimes even exceeding the available width on your screen, thus requiring you to either scroll or have your editor soft-wrap it for you when displaying it.\n```\n\nAs we've learned above from\n[the groff docs](https://www.gnu.org/software/groff/manual/groff.html.node/Basics.html),\nthis actually carries meaning for groff (properly detect the ends of\nsentences). And it makes the diffs in VCS's less noisy.\n\nAnother popular way would be to put each paragraph on its own line.\nLike, there's only one \"physical\" newline character after the whole\nthing and it's your editor's job to properly display this:\n\n```\nThis is one sentence. This is another one. And so on and so on. One sentence per line, that's it. Sentences can be short. Or they can be pretty long, sometimes even exceeding the available width on your screen, thus requiring you to either scroll or have your editor soft-wrap it for you when displaying it.\n```\n\nI used the second version for a couple of years at the end of the\n1990ies and the early 2000s, but eventually switched to hard-wrapped\ntext. Like this:\n\n```\nThis is one sentence. This is another one. And so on and so on. One\nsentence per line, that's it. Sentences can be short. Or they can be\npretty long, sometimes even exceeding the available width on your\nscreen, thus requiring you to either scroll or have your editor\nsoft-wrap it for you when displaying it.\n```\n\nI just find this easier to read and easier to navigate in. And it\nreminds me of the \"good\" old DOS days, where I used\n[the `T` editor](https://ecsoft2.org/t-tiny-editor)\na lot and all my files looked like that (manually formatted, of course).\nIt does have drawbacks, yes. It's not great for collaboration with other\npeople, but that doesn't matter in my case.\n\nAnother drawback is that I have to reformat these paragraphs while\nediting. Luckily, Vim makes that easy:\n\n```\n\" In ~/.vimrc:\nset nojs\nmap Q gq}\n```\n\nI can then just put my cursor at the beginning of a paragraph:\n\n```\n[T]his is one sentence.\nThis is another one.\nAnd so on and so on.\nOne sentence per line, that's it.\nSentences can be short.\n```\n\nAnd hit `Q` to turn it into this:\n\n```\nThis is one sentence. This is another one. And so on and so on. One\nsentence per line, that's it. Sentences can be short.\n[_]\n```\n\nThe cursor will be positioned after that paragraph. To reflow the entire\ndocument, I can just keep `Q` pressed down until it hits the end.\n\n*-- edit: Or do `:set formatoptions+=a` to have paragraphs reformatted\nautomatically while editing it. I usually don't want that, I usually\nwant it to be an explicit operation. But for writing prose, this might\nbe pretty useful.*\n\nThe `nojs` option (funny name, huh?) was new to me, only found out about\nit just now. The full name is `nojoinspaces` and it prevents the very\nthing that I *should* be doing (but which is not customary in German):\nIt does *not* insert two spaces after a period. Without it, i.e., with\n`set js`, the result would look like this:\n\n```\nThis is one sentence.  This is another one.  And so on and so on.\nOne sentence per line, that's it.  Sentences can be short.\n```\n\nSome people like that, I don't.\n\n## Git\n\nAs with virtually everything I do, this is in Git.\n\nBut that's the end. I regularly commit the current state, but I hardly\ncare about anything else. No proper commit messages, nothing. It's just\na tool for making \"backups\" easier and to sync the data between my\nlaptop and desktop PC.\n\n## `demo-book.tar.gz`: Putting it all together\n\nAs I said, I won't publish the actual \"books\". But here's a demo of the\n\"scaffold\":\n\n[demo-book.tar.gz](https://movq.de/blog/postings/2026-10-31/0/demo-book.tar.gz)\n\n(I won't update this. This is just a snapshot of the current status.)\n\n## The writing process itself\n\nI won't say much about this. I'm a total noob.\n\nI changed course a couple of times. For both stories, I tried to draft\nthe whole thing before I began writing the actual text, but that didn't\nhelp much. The first story isn't that great anyway. It has an\ninteresting premise, but I wasn't really \"in the zone\". That's also why\nit took so long. The second story has a much more mundane basic idea to\nit and then I eventually realized how interesting it actually was. There\nare quite a few twists and turns in it, and I love that.\n\nIt was *way* harder than I thought to keep the facts straight,\nespecially with the course changes. Which character knows what, when,\nwhy? What are the motives? Is everything consistent and plausible?\nConstantly question everything -- does she *really* need to do that now\nor is there some other, much more likely way out? Does every sentence\nshe said 100 pages ago still make sense after the big reveal at the end?\nStuff like that. I'll have to get better at that. Probably use a little\n\"character inventory\" next time, like, a profile for each one.\n\nBuilding a world with its own set of rules and history and what not\nturns out to be very fascinating. As is building the characters.\n\nThe length of the stories make proof-reading ridiculously hard. Like,\nI'm not going to read 120 pages in a couple of minutes. I re-read the\nsecond story one last time yesterday and it took ... \\*checks notes\\* ...\nthree hours. Ouch.\n\n## Where to go from here?\n\nNow that I've re-read that 120-page thing again yesterday ... I actually\nlike it. I'm happy with the result. There's obviously a lot to learn:\nThis entire field is completely new to me. I have identified quite a few\nplaces where the storytelling isn't great -- the pace isn't right, things\nprogress too fast. (At the moment, I only notice this when reading the\nwhole thing in one go. Oof.) Sometimes the wording isn't great. Not\nenough detail. And so on. But the story itself is something that I'd\nenjoy reading myself.\n\nDigging deeper into groff is on my TODO list, also for obvious reasons.\n\nWhat I really loved about this whole thing is that I ended up completely\nin the tunnel. On one of those ten days that it took me to write the\n120-page thing, I wasn't even actually typing on a keyboard: We were\ntravelling across the country, lots of idle time, I didn't have a\nlaptop, but I basically \"wrote\" at least one chapter and then memorized\n(most of) it. Went back and forth, new ideas. Completely absorbed.\n\nI want more of that. :-)\n\nMaybe stuff will eventually get published (as in: I might put it on this\nwebsite), but not now. I do this for myself. I'm not even remotely\ninterested in my work getting torn apart by rude critics. Leave me\nalone. :-)\n\nAnd if you think about suggesting the use of LLMs: Congratulations, you\nhave *completely* missed the point. \"Setzen, 6.\"\n","body_html":"<h1 id=\"novellas-with-groff\">Novellas with groff</h1>\n<p>2026-10-31</p>\n<p>I recently finished my second &quot;novella&quot;.</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/pdfinfo-wc.png\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/pdfinfo-wc.png.jpg\" alt=\"pdfinfo-wc.png: Screenshot of the output of &#39;pdfinfo&#39; and &#39;wc&#39;: About 50 pages / 15k words for the first document, 120 pages / 40k words for the second one.\" title=\"Screenshot of the output of &#39;pdfinfo&#39; and &#39;wc&#39;: About 50 pages / 15k words for the first document, 120 pages / 40k words for the second one.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>Don&#39;t even think about it: I won&#39;t publish this. Nor send it to you\nprivately, which is mostly the same as publishing it.</p>\n<p>The first story is roughly 50\n<a href=\"https://en.wikipedia.org/w/index.php?title=DIN_A5\" rel=\"nofollow ugc noopener\">A5 pages</a>\nlong (~15k words), the second one is about 120 pages (~40k words). (Both\nbarely fit the\n<a href=\"https://en.wikipedia.org/wiki/Novella\" rel=\"nofollow ugc noopener\">definition of a &quot;novella&quot;</a>,\napparently, with the first one being a bit too short and the second one\na tiny bit too long.)</p>\n<p>It feels pretty absurd and surreal that I have done this at all. In\nschool, <em>anything</em> related to &quot;writing&quot; was pure horror for me -- unless\nit was related to maths, physics, or other &quot;technical&quot; stuff. But here\nwe are.</p>\n<p>How long did it take? Well, the first one took over seven months. But\nthe second one, the longer one? Ten days.</p>\n<p>Some time last year, probably around July, I started reading some of the\nbooks that were lying around in my appartment for decades. And this was\nmuch more enjoyable than I thought. No idea why. It&#39;s not like I never\nread a book before, but it was always a somewhat boring thing to do and\nit took me ages -- unless it was something technical. I&#39;m only referring\nto fiction and novels here. Like, one book per year, tops. Yet, I\nsomehow got hooked last year and now I&#39;ve read about 30 novels since\nJuly 2025. Some faster (a couple of days), some slower (three months).</p>\n<p>It wasn&#39;t that much of a stretch to try to do this myself.</p>\n<p>This blog is still technical in nature, so I&#39;ll walk through the\nsoftware that I used.</p>\n<hr />\n<p>Table of contents:</p>\n<ul><li><a href=\"#groff\">groff</a><ul><li><a href=\"#basic-formatting\">Basic formatting</a></li><li><a href=\"#footers-and-page-numbers\">Footers and page numbers</a></li><li><a href=\"#header\">Header</a></li><li><a href=\"#a-closer-look-at-traps\">A closer look at traps</a></li><li><a href=\"#inter-sentence-spacing\">Inter-sentence spacing</a></li><li><a href=\"#german-hyphenation\">German hyphenation</a></li></ul></li><li><a href=\"#markdown-and-other-pre-processing\">Markdown and other pre-processing</a></li><li><a href=\"#vim\">Vim</a><ul><li><a href=\"#goyo\">Goyo</a></li><li><a href=\"#reflowing-text\">Reflowing text</a></li></ul></li><li><a href=\"#git\">Git</a></li><li><a href=\"#demo-booktargz-putting-it-all-together\">demo-book.tar.gz: Putting it all together</a></li><li><a href=\"#the-writing-process-itself\">The writing process itself</a></li><li><a href=\"#where-to-go-from-here\">Where to go from here?</a></li></ul>\n<hr />\n<h2 id=\"groff\">groff</h2>\n<p>Both of my books (they&#39;re not really &quot;books&quot;, but I&#39;ll keep referring to\nthem as such for the sake of simplicity) are typeset in\n<a href=\"https://www.gnu.org/software/groff/\" rel=\"nofollow ugc noopener\">groff</a>.\nYou know, the thing that usually renders manual pages in your terminal\non Linux. groff/troff is a full typesetting system, though, and it can\nbe used to\n<a href=\"https://www.troff.org/pubs.html\" rel=\"nofollow ugc noopener\">produce real books</a>, which I&#39;ve\nalready mentioned a couple of times in\n<a href=\"https://movq.de/blog/postings/2025-08-30/0/POSTING-en.html\" rel=\"nofollow ugc noopener\">previous blog posts</a>.</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/troff-books-1.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/troff-books-1.webp.jpg\" alt=\"troff-books-1.webp: Photo of my copies of &#39;The C Programming Language&#39;, &#39;The UNIX Programming Environment&#39;, and &#39;UNIX Network Programming&#39;.\" title=\"Photo of my copies of &#39;The C Programming Language&#39;, &#39;The UNIX Programming Environment&#39;, and &#39;UNIX Network Programming&#39;.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a>\n<a href=\"https://movq.de/blog/postings/2026-10-31/0/troff-books-2.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/troff-books-2.webp.jpg\" alt=\"troff-books-2.webp: A page of &#39;The C Programming Language&#39;.\" title=\"A page of &#39;The C Programming Language&#39;.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a>\n<a href=\"https://movq.de/blog/postings/2026-10-31/0/troff-books-3.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/troff-books-3.webp.jpg\" alt=\"troff-books-3.webp: A page of &#39;UNIX Network Programming&#39;, showing some diagrams.\" title=\"A page of &#39;UNIX Network Programming&#39;, showing some diagrams.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>In my case, the appeal of groff is that it&#39;s relatively small and\n<em>fast</em>, but still able to produce high-quality output. Making that\n50-page document takes about <em>700 ms</em> on my 13.5 year old PC, and the\n120-page one takes <em>1.6 seconds</em>. This includes some pre-processing\nwhich we&#39;ll cover later. Given that most modern software these days\nfeels like walking in mud, this is refreshingly quick.</p>\n<p>Because it&#39;s more fun that way, I made my own little macro package.\nThere really isn&#39;t a lot to it, though. It&#39;s tiny. Not a lot is needed\nfor a simple novel / novella -- no table of contents, no\ncross-references, no diagrams, no code blocks, no lists, ... Just nicely\nflowing text and <em>sometimes</em> a word gets emphasized.</p>\n<p>Disclaimer: You&#39;ll note some TODO items in the text below. groff is a\nfull-blown typesetting system and these things are complicated. I&#39;m a\nlong way from having mastered every aspect of it.</p>\n<h3 id=\"basic-formatting\">Basic formatting</h3>\n<p>There are only three macros:</p>\n<pre><code>.\\&quot; Section header / chapter title\n.de SH\n.   sp 1v\n.   ps +5p\n.   ce\n\\f[HR]\\\\$1\\fP\n.   ps\n.   sp 4v\n..\n.\\&quot; Normal paragraph with hanging indent.\n.de PP\n.   br\n.   ti +2m\n..\n.\\&quot; &quot;Long&quot; paragraph, longer empty space.\n.de LP\n.   sp 2v\n..</code></pre>\n<p>(The name <code>SH</code> is a spill-over from manual pages. I&#39;ve written quite a\nfew of those and this name somehow stuck. <code>CH</code> for &quot;chapter heading&quot; or\n<code>CT</code> for &quot;chapter title&quot; might have been better choices. Or, you know,\n<code>.CHAPTER</code>.)</p>\n<p>You start defining a macro with <code>.de</code> -- anything until <code>..</code> is part of\nthat macro.</p>\n<ul><li><p><code>.SH</code>: Go down one</p><p><a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Measurements.html\" rel=\"nofollow ugc noopener\">vee</a>,\nincrease type size, request centering, print the macro&#39;s first\nargument with the <code>HR</code> font (Helvetica), return to previous type\nsize, add another four vees of space.</p></li><li><p><code>.PP</code>: Just break the current line, then request a temporary indent</p><p>for the next output line. This creates a hanging indent, which is\ncustomary in German books.</p></li><li><p><code>.LP</code>: Just some empty space between paragraphs. Used for things</p><p>like intra-chapter time jumps.</p></li></ul>\n<p>You can look up the individual commands in <code>man 7 groff</code>.</p>\n<p>And that would already be enough to produce a document that somewhat\nresembles a book.</p>\n<p>Put the snippet above in a file called <code>macros.groff</code>. I made one file\nper chapter. For example:\n<a href=\"https://movq.de/blog/postings/2026-10-31/0/chapter01.groff\" rel=\"nofollow ugc noopener\"><code>chapter01.groff</code></a>.\nYou can then make a PDF using a command like this:</p>\n<pre><code>groff -Tpdf -dpaper=a5 -P-pa5 macros.groff chapter01.groff &gt;book.pdf</code></pre>\n<p>A5 is roughly the page size of a &quot;typical book&quot;.</p>\n<h3 id=\"footers-and-page-numbers\">Footers and page numbers</h3>\n<p>You&#39;ll note that there are no page numbers by default. You could\nactually just decide to not have them if all you want is a digital PDF.\nThey&#39;re useful for printing, but you don&#39;t really need them in a file,\nif we&#39;re being honest.</p>\n<p>Except: The thing gets confused about page breaks. Create the PDF using\nthe example above and you&#39;ll see:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/wrong-page-break.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/wrong-page-break.webp.jpg\" alt=\"wrong-page-break.webp: PDF viewer screenshot: Last line of text outside of the page.\" title=\"PDF viewer screenshot: Last line of text outside of the page.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>Looks like the baseline of the last line of output is just outside the\npage. Not sure what&#39;s going on here -- it&#39;s related to setting the page\nsize to A5. In other words, I probably missed <em>another</em> spot where this\nhas to be set. It&#39;ll be fixed implicitly by the following.</p>\n<p>The whole page number thing consists of three parts: First, how large is\nthe footer (the area where the page numbers live)? I defined this in a\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Setting-Registers.html\" rel=\"nofollow ugc noopener\">register</a>\n(which is not really necessary but I find the &quot;code&quot; easier to read this\nway) -- the name is arbitary:</p>\n<pre><code>.nr _FooterSize 5v</code></pre>\n<p>We than plant a\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Page-Location-Traps.html\" rel=\"nofollow ugc noopener\">trap</a>\nat the bottom of the page:</p>\n<pre><code>.wh -\\n[_FooterSize]u _FooterTrap</code></pre>\n<p><code>\\n[_FooterSize]</code> &quot;gets&quot; the value of the register called <code>_FooterSize</code>.\nThere&#39;s a minus sign in front of it, it&#39;s negative and relative to the\nbottom of the page.\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Default-Units.html\" rel=\"nofollow ugc noopener\">The documentation says</a>:</p>\n<blockquote><p>A general-purpose register (one created or updated with the nr\nrequest) is implicitly dimensionless, or reckoned in basic units if\ninterpreted in a measurement context.</p></blockquote>\n<p>I&#39;m not 100% sure why I need to add the <code>u</code>. I haven&#39;t read every page\nof the manual, yet. Needless to say, it doesn&#39;t work without it.</p>\n<p>Okay, so the trap gets installed at 5v before the end of the page and\nit&#39;ll call the <code>_FooterTrap</code> macro. It looks like this:</p>\n<pre><code>.de _FooterTrap\n.\\&quot; Push current environment on stack and switch to `_FooterEnv`.\n.\\&quot; Parent env will keep partially collected lines.\n.   ev _FooterEnv\n.\\&quot; Copy settings from default environment.\n.   evc 0\n.\\&quot; Don&#39;t do this for pages 1 and 2, they&#39;re title pages in my actual\n.\\&quot; &quot;book&quot;.\n.   if \\\\n[%]&gt;2 \\{\\\n.\\&quot; Set vertical position, explained in the text below.\n.       sp |\\\\n[.p]u-2v\n.\\&quot; Print % register centered.\n.       ce\n\\fR\\\\n[%]\\fP\n\\}\n.\\&quot; Go back to previous environment.\n.   ev\n.\\&quot; Request page break.\n&#39;   bp\n..</code></pre>\n<p>It&#39;s much easier to read without the inline comments:</p>\n<pre><code>.de _FooterTrap\n.   ev _FooterEnv\n.   evc 0\n.   if \\\\n[%]&gt;2 \\{\\\n.       sp |\\\\n[.p]u-2v\n.       ce\n\\fR\\\\n[%]\\fP\n\\}\n.   ev\n&#39;   bp\n..</code></pre>\n<p>Why is it <code>&#39;bp</code> instead of <code>.bp</code>? We&#39;ll get to that.</p>\n<p>What I&#39;m unsure about: I set the vertical position to <code>|\\\\n[.p]u-2v</code>.\nThat&#39;s relative to the <em>top</em> of the page, it&#39;s the page length minus two\nvee. I would have expected <code>|-2v-1v</code> (including the &quot;minus one vee&quot;\nmentioned in the docs) to also work, but that leads to an infinite loop\n(probably triggers the same trap again and again). Why?</p>\n<h3 id=\"header\">Header</h3>\n<p>For symmetry, I also want some empty space at the top of the page:</p>\n<pre><code>.nr _HeaderSize 5v\n.de _HeaderTrap\n&#39;   sp |\\\\n[_HeaderSize]u\n..\n.wh 0v _HeaderTrap</code></pre>\n<p>And another TODO for me: This isn&#39;t 100% symmetrical. The length of the\nheader is a bit larger than the footer. An issue with the page size\nagain?</p>\n<h3 id=\"a-closer-look-at-traps\">A closer look at traps</h3>\n<p>Let&#39;s have a closer look at traps. I&#39;m not <em>100%</em> sure on this -- this is\nto the best of my understanding.</p>\n<p>Actually, let&#39;s take a step back from the example above. Let&#39;s start\nwith this:</p>\n<pre><code>This is a little excerpt from Mary Shelly&#39;s Frankenstein.\n\nThese visions faded when I perused, for the first time, those poets\nwhose effusions entranced my soul and lifted it to heaven. I also became\na poet and for one year lived in a paradise of my own creation; I\nimagined that I also might obtain a niche in the temple where the names\nof Homer and Shakespeare are consecrated. You are well acquainted with\nmy failure and how heavily I bore the disappointment. But just at that\ntime I inherited the fortune of my cousin, and my thoughts were turned\ninto the channel of their earlier bent.\n\nSix years have passed since I resolved on my present undertaking. I can,\neven now, remember the hour from which I dedicated myself to this great\nenterprise. I commenced by inuring my body to hardship. I accompanied\nthe whale-fishers on several expeditions to the North Sea; I voluntarily\nendured cold, famine, thirst, and want of sleep; I often worked harder\nthan the common sailors during the day and devoted my nights to the\nstudy of mathematics, the theory of medicine, and those branches of\nphysical science from which a naval adventurer might derive the greatest\npractical advantage. Twice I actually hired myself as an under-mate in a\nGreenland whaler, and acquitted myself to admiration. I must own I felt\na little proud when my captain offered me the second dignity in the\nvessel and entreated me to remain with the greatest earnestness, so\nvaluable did he consider my services.</code></pre>\n<p>Save it as <code>test.groff</code> and make a PDF:</p>\n<pre><code>groff -Tpdf test.groff &gt;book.pdf</code></pre>\n<p>Looks like this:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-1.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-1.webp.jpg\" alt=\"traps-1.webp\" title=\"traps-1.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>Install a trap at 10v. It&#39;s empty so far and does nothing -- insert this\nat the very top of the file:</p>\n<pre><code>.de MyTrap\n..\n.wh 10v MyTrap\n.\\&quot;</code></pre>\n<p>The PDF looks the same.</p>\n<p>Now what happens when we change the trap macro to this?</p>\n<pre><code>.de MyTrap\nFOO\n..</code></pre>\n<p>This is the result:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-2.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-2.webp.jpg\" alt=\"traps-2.webp\" title=\"traps-2.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>When the output reached the word &quot;fishers&quot;, it sprang the trap. &quot;FOO&quot;\ncomes after &quot;fishers&quot; in the PDF: &quot;fishers&quot; triggered the trap, then\n&quot;FOO&quot; got inserted. I think it&#39;s as simple as that, isn&#39;t it?</p>\n<p>Suppose we want to put &quot;FOO&quot; at the beginning of the line and we want\nnothing but that word on that line. &quot;fishers&quot; shall be put on the next\nline.</p>\n<p>If I understand correctly, switching environments is key: The\nenvironment holds the currently collected line (among many other\nthings). Switch to a new one and we get a new buffer/line -- one that&#39;s\nempty so far. We can then flush/break this line to have it included in\nthe PDF, and then switch back to the previous environment:</p>\n<pre><code>.de MyTrap\n.   ev MyTrapEnv\nFOO\n.   br\n.   ev\n..</code></pre>\n<p>Looks like this:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-3.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-3.webp.jpg\" alt=\"traps-3.webp\" title=\"traps-3.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>So far, so good. Now I want there to be an empty line before and after\n&quot;FOO&quot;:</p>\n<pre><code>.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n..</code></pre>\n<p>In the new environment, we issue <code>.sp</code>: It breaks and inserts space.\nNothing was collected so far, so the break doesn&#39;t print anything at\nthis point. Then we have <code>FOO</code> -- this isn&#39;t printed directly, it&#39;s just\ncollected. The next <code>.sp</code> breaks again (thus printing &quot;FOO&quot;) and then\ninserts more space.</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-4.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-4.webp.jpg\" alt=\"traps-4.webp\" title=\"traps-4.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>Okay. Now. Suppose that printing &quot;FOO&quot; with those two lines around it is\nall we want to do inside of the trap. We then want the normal text to\ncontinue at some absolute position on the page, say at 17v.</p>\n<p>So, how about the following? We go back to the previous environment and\nthen issue an absolute location request:</p>\n<pre><code>.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n.   sp |17v\n..</code></pre>\n<p>Oops:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-5.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-5.webp.jpg\" alt=\"traps-5.webp\" title=\"traps-5.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p><code>.sp |17v</code> broke the already collected line (the one with just &quot;fishers&quot;\nin it) and <em>then</em> inserted the space. We don&#39;t want that break. (Also\nnote that &quot;fishers&quot; is at the exact same position where we left off\ninside the trap.)</p>\n<p>This can be avoided by using <code>&#39;</code> instead of <code>.</code>:</p>\n<pre><code>&#39;   The neutral apostrophe is the no-break control character, rec‐\n    ognized where the control character  is.   It  suppresses  the\n    (first) break implied by the bp, ce, cf, fi, fl, &quot;in&quot;, nf, rj,\n    sp,  ti,  and trf requests.  The requested operation takes ef‐\n    fect at the next break.</code></pre>\n<p>So let&#39;s do this:</p>\n<pre><code>.de MyTrap\n.   ev MyTrapEnv\n.   sp\nFOO\n.   sp\n.   ev\n&#39;   sp |17v\n..</code></pre>\n<p>Result:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/traps-6.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/traps-6.webp.jpg\" alt=\"traps-6.webp\" title=\"traps-6.webp\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>The example in\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Page-Location-Traps.html\" rel=\"nofollow ugc noopener\">the documentation</a>\ndoesn&#39;t change environments. But I find it much easier to understand\nwhat&#39;s going when changing them. (And I hope I got it right.)</p>\n<p>One final remark: Environment carry settings. <code>.ev foo</code> starts a\ncompletely new environment (unless an environment with that name already\nexists), it doesn&#39;t clone the previous one. That&#39;s why my macro package\nalso does <code>.evc 0</code>.</p>\n<p>As a little exercise, see what happens when you use <code>&#39;sp |12v</code>, <code>&#39;sp\n|11.5v</code>, <code>&#39;sp |11v</code>, all the way down to <code>&#39;sp |9v</code>.</p>\n<h3 id=\"inter-sentence-spacing\">Inter-sentence spacing</h3>\n<p>Only when writing this blog post, I found the following sentence in\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Basics.html\" rel=\"nofollow ugc noopener\">the docs (Basics)</a>:</p>\n<blockquote><p>If you don&#39;t start a sentence on a new line, put two spaces after the\nprevious sentence. GNU troff then recognizes punctuation that ends a\nsentence, and inserts inter-sentence space accordingly.</p></blockquote>\n<p>I didn&#39;t do that, because this isn&#39;t customary in German. But now I see\nit. Sometimes, it looks like this in the PDF:</p>\n<pre><code>Foo. Bar.</code></pre>\n<p>And sometimes there&#39;s a little bit of extra space:</p>\n<pre><code>Foo.  Bar.</code></pre>\n<p>As far as I know, this is usually not done in German books. I disabled\nit with this request, which keeps &quot;minimal inter-word spacing&quot; at the\ndefault value of 12 but sets &quot;supplemental inter-sentence spacing&quot; to 0:</p>\n<pre><code>.ss 12 0</code></pre>\n<p>This isn&#39;t part of my macro package, but it comes first in the &quot;index&quot;\nfile (<code>book.groff</code>, see demo package below).</p>\n<h3 id=\"german-hyphenation\">German hyphenation</h3>\n<p>Apparently, it&#39;s as simple as this:</p>\n<pre><code>.hla den\n.hpf hyphen.den</code></pre>\n<p><code>den</code> is &quot;de(utsch) new&quot;: This includes the &quot;new&quot; German rules from\n2006.</p>\n<h2 id=\"markdown-and-other-pre-processing\">Markdown and other pre-processing</h2>\n<p>I actually wrote both of my stories in plain groff, using the macros I\nexplained above.</p>\n<p><a href=\"https://en.wikipedia.org/wiki/Markdown\" rel=\"nofollow ugc noopener\">Markdown</a>\nhas the big advantage of being &quot;visually pleasing&quot;: It mostly looks like\ntext that is intended to be read by a human being. groff isn&#39;t, really.\nI mean, it wasn&#39;t <em>horrible</em>, I wouldn&#39;t have written over 170 pages in\ngroff if this was <em>pain</em>. It&#39;s fine. I use groff in several other places\nas well. But Markdown is a tiny little bit better, and I assume that it\nallows me to focus more on the creative process.</p>\n<p>So, afterwards, I converted the second story to &quot;Markdown&quot;. Didn&#39;t\nbother to do that for the first one. I put that in quotation marks\nbecause there are only very few elements, it&#39;s not full Markdown:</p>\n<ul><li><code># Chapter title</code> at the top of the file.</li><li>Empty lines between paragraphs, <code>---</code> for &quot;long empty paragraphs&quot;.</li><li><code>*foo*</code> for emphasized text.</li></ul>\n<p>And that&#39;s it. Makes the conversion really easy.</p>\n<p>I could have just use plain Markdown for this whole thing and created an\nHTML file. I already have the tooling for that -- that&#39;s what drives my\nblog. Maybe this could even produce a PDF file. But what would be\nmissing there, among other things, would be an engine to *properly\njustify text*. It hurts my eyes to see justified text in HTML, it just\nlooks like a complete disaster. The results that groff or TeX create are\nmuch, much better.</p>\n<p>While we&#39;re at it, we can also do some basic character replacements: I\nhave the German typographic quotation marks U+201E and U+201C directly\non my keyboard, but\n<a href=\"https://en.wikipedia.org/wiki/Guillemet\" rel=\"nofollow ugc noopener\">Guillemets</a>\nare preferred in books.</p>\n<p>I first wanted to do all this in Python but then switched to a little\nPerl snippet, because it makes it easy to read the entire file and then\ndo multiline-regex stuff on it. It goes something like this:</p>\n<pre><code>perl -0pe &#39;\n# Guillemets are preferred in books.\ns/... German typographic quotes, see demo package .../... Guillemets .../g;\n\n# Markdown &quot;h1&quot; into &quot;.SH&quot;.\ns/^# ([^\\n]+)\\n/.SH &quot;\\1&quot;\\n/smg;\n\n# Markdown &quot;hr&quot; into &quot;.LP&quot;.\ns/\\n---\\n/.LP/smg;\n\n# Markdown paragraphs into &quot;.PP&quot;.\ns/\\n\\n/\\n.PP\\n/smg;\n\n# Markdown emphasize into groff font selection:\ns/\\*([^*]+)\\*/\\\\fI\\1\\\\fP/smg;\n&#39;</code></pre>\n<p>The output is still groff for my little macro package. But I can now\nwrite it like this:</p>\n<pre><code># Kapitel 42: Die Antwort\n\nDa war sie also. Die Antwort auf *alle* Fragen.\n\nUnd dann ging es weiter:\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum\nhendrerit blandit suscipit. Maecenas sed nisi nec ante mattis\nvulputate. Pellentesque maximus leo id purus vestibulum dictum.\nDonec tincidunt mollis viverra. Curabitur at ligula in turpis\npellentesque vehicula.\n\nDuis hendrerit commodo mauris, non posuere leo vulputate ut. Nulla\nfinibus urna eget vehicula auctor. Mauris in posuere nibh. Vivamus\nut metus vel nisi gravida molestie vitae et tellus. Integer mi odio,\nvestibulum eget laoreet vel, auctor nec ligula. Quisque eu placerat\nquam, eu tincidunt mauris. Nam vestibulum lectus non leo dignissim,\nnon sagittis dolor venenatis.</code></pre>\n<p>This reads much nicer and there is syntax highlighting in Vim for it.\nWell, the <code>*emphasized*</code> parts, that is -- the rest doesn&#39;t matter:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/vim-md.png\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/vim-md.png.jpg\" alt=\"vim-md.png: Screenshot of Vim with standard Markdown highlighting: Emphasized text uses the terminal&#39;s &#39;standout&#39; attribute.\" title=\"Screenshot of Vim with standard Markdown highlighting: Emphasized text uses the terminal&#39;s &#39;standout&#39; attribute.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>Speaking of Vim ...</p>\n<h2 id=\"vim\">Vim</h2>\n<h3 id=\"goyo\">Goyo</h3>\n<p>There is one super important\n<a href=\"https://vim-classic.org/\" rel=\"nofollow ugc noopener\">Vim</a>\nplugin for this:</p>\n<p><a href=\"https://github.com/junegunn/goyo.vim\" rel=\"nofollow ugc noopener\">https://github.com/junegunn/goyo.vim</a></p>\n<p>It hides almost all UI elements.</p>\n<p>On top of that, I put the terminal window in fullscreen mode to hide my\ndesktop.</p>\n<p>And there you go. &quot;Distraction-free writing&quot; indeed. Maybe put on some\nmusic, but there&#39;s nothing else. No browser, no clock, no nothing. Just\na typewriter with an easy undo function.</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/vim-photo.webp\" rel=\"nofollow ugc noopener\"><img src=\"https://movq.de/blog/postings/2026-10-31/0/t/vim-photo.webp.jpg\" alt=\"vim-photo.webp: Photo of Vim with Markdown highlighting and active Goyo, terminal in fullscreen mode.\" title=\"Photo of Vim with Markdown highlighting and active Goyo, terminal in fullscreen mode.\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></a></p>\n<p>The font is the 11x22 variant of\n<a href=\"https://people.mpi-inf.mpg.de/~uwe/misc/uw-ttyp0/\" rel=\"nofollow ugc noopener\">UW ttyp0</a>.</p>\n<h3 id=\"reflowing-text\">Reflowing text</h3>\n<p>There&#39;s a popular way to format text in plain-text files:</p>\n<pre><code>This is one sentence.\nThis is another one.\nAnd so on and so on.\nOne sentence per line, that&#39;s it.\nSentences can be short.\nOr they can be pretty long, sometimes even exceeding the available width on your screen, thus requiring you to either scroll or have your editor soft-wrap it for you when displaying it.</code></pre>\n<p>As we&#39;ve learned above from\n<a href=\"https://www.gnu.org/software/groff/manual/groff.html.node/Basics.html\" rel=\"nofollow ugc noopener\">the groff docs</a>,\nthis actually carries meaning for groff (properly detect the ends of\nsentences). And it makes the diffs in VCS&#39;s less noisy.</p>\n<p>Another popular way would be to put each paragraph on its own line.\nLike, there&#39;s only one &quot;physical&quot; newline character after the whole\nthing and it&#39;s your editor&#39;s job to properly display this:</p>\n<pre><code>This is one sentence. This is another one. And so on and so on. One sentence per line, that&#39;s it. Sentences can be short. Or they can be pretty long, sometimes even exceeding the available width on your screen, thus requiring you to either scroll or have your editor soft-wrap it for you when displaying it.</code></pre>\n<p>I used the second version for a couple of years at the end of the\n1990ies and the early 2000s, but eventually switched to hard-wrapped\ntext. Like this:</p>\n<pre><code>This is one sentence. This is another one. And so on and so on. One\nsentence per line, that&#39;s it. Sentences can be short. Or they can be\npretty long, sometimes even exceeding the available width on your\nscreen, thus requiring you to either scroll or have your editor\nsoft-wrap it for you when displaying it.</code></pre>\n<p>I just find this easier to read and easier to navigate in. And it\nreminds me of the &quot;good&quot; old DOS days, where I used\n<a href=\"https://ecsoft2.org/t-tiny-editor\" rel=\"nofollow ugc noopener\">the <code>T</code> editor</a>\na lot and all my files looked like that (manually formatted, of course).\nIt does have drawbacks, yes. It&#39;s not great for collaboration with other\npeople, but that doesn&#39;t matter in my case.</p>\n<p>Another drawback is that I have to reformat these paragraphs while\nediting. Luckily, Vim makes that easy:</p>\n<pre><code>&quot; In ~/.vimrc:\nset nojs\nmap Q gq}</code></pre>\n<p>I can then just put my cursor at the beginning of a paragraph:</p>\n<pre><code>[T]his is one sentence.\nThis is another one.\nAnd so on and so on.\nOne sentence per line, that&#39;s it.\nSentences can be short.</code></pre>\n<p>And hit <code>Q</code> to turn it into this:</p>\n<pre><code>This is one sentence. This is another one. And so on and so on. One\nsentence per line, that&#39;s it. Sentences can be short.\n[_]</code></pre>\n<p>The cursor will be positioned after that paragraph. To reflow the entire\ndocument, I can just keep <code>Q</code> pressed down until it hits the end.</p>\n<p>*-- edit: Or do <code>:set formatoptions+=a</code> to have paragraphs reformatted\nautomatically while editing it. I usually don&#39;t want that, I usually\nwant it to be an explicit operation. But for writing prose, this might\nbe pretty useful.*</p>\n<p>The <code>nojs</code> option (funny name, huh?) was new to me, only found out about\nit just now. The full name is <code>nojoinspaces</code> and it prevents the very\nthing that I <em>should</em> be doing (but which is not customary in German):\nIt does <em>not</em> insert two spaces after a period. Without it, i.e., with\n<code>set js</code>, the result would look like this:</p>\n<pre><code>This is one sentence.  This is another one.  And so on and so on.\nOne sentence per line, that&#39;s it.  Sentences can be short.</code></pre>\n<p>Some people like that, I don&#39;t.</p>\n<h2 id=\"git\">Git</h2>\n<p>As with virtually everything I do, this is in Git.</p>\n<p>But that&#39;s the end. I regularly commit the current state, but I hardly\ncare about anything else. No proper commit messages, nothing. It&#39;s just\na tool for making &quot;backups&quot; easier and to sync the data between my\nlaptop and desktop PC.</p>\n<h2 id=\"demo-book-tar-gz-putting-it-all-together\"><code>demo-book.tar.gz</code>: Putting it all together</h2>\n<p>As I said, I won&#39;t publish the actual &quot;books&quot;. But here&#39;s a demo of the\n&quot;scaffold&quot;:</p>\n<p><a href=\"https://movq.de/blog/postings/2026-10-31/0/demo-book.tar.gz\" rel=\"nofollow ugc noopener\">demo-book.tar.gz</a></p>\n<p>(I won&#39;t update this. This is just a snapshot of the current status.)</p>\n<h2 id=\"the-writing-process-itself\">The writing process itself</h2>\n<p>I won&#39;t say much about this. I&#39;m a total noob.</p>\n<p>I changed course a couple of times. For both stories, I tried to draft\nthe whole thing before I began writing the actual text, but that didn&#39;t\nhelp much. The first story isn&#39;t that great anyway. It has an\ninteresting premise, but I wasn&#39;t really &quot;in the zone&quot;. That&#39;s also why\nit took so long. The second story has a much more mundane basic idea to\nit and then I eventually realized how interesting it actually was. There\nare quite a few twists and turns in it, and I love that.</p>\n<p>It was <em>way</em> harder than I thought to keep the facts straight,\nespecially with the course changes. Which character knows what, when,\nwhy? What are the motives? Is everything consistent and plausible?\nConstantly question everything -- does she <em>really</em> need to do that now\nor is there some other, much more likely way out? Does every sentence\nshe said 100 pages ago still make sense after the big reveal at the end?\nStuff like that. I&#39;ll have to get better at that. Probably use a little\n&quot;character inventory&quot; next time, like, a profile for each one.</p>\n<p>Building a world with its own set of rules and history and what not\nturns out to be very fascinating. As is building the characters.</p>\n<p>The length of the stories make proof-reading ridiculously hard. Like,\nI&#39;m not going to read 120 pages in a couple of minutes. I re-read the\nsecond story one last time yesterday and it took ... <em>checks notes</em> ...\nthree hours. Ouch.</p>\n<h2 id=\"where-to-go-from-here\">Where to go from here?</h2>\n<p>Now that I&#39;ve re-read that 120-page thing again yesterday ... I actually\nlike it. I&#39;m happy with the result. There&#39;s obviously a lot to learn:\nThis entire field is completely new to me. I have identified quite a few\nplaces where the storytelling isn&#39;t great -- the pace isn&#39;t right, things\nprogress too fast. (At the moment, I only notice this when reading the\nwhole thing in one go. Oof.) Sometimes the wording isn&#39;t great. Not\nenough detail. And so on. But the story itself is something that I&#39;d\nenjoy reading myself.</p>\n<p>Digging deeper into groff is on my TODO list, also for obvious reasons.</p>\n<p>What I really loved about this whole thing is that I ended up completely\nin the tunnel. On one of those ten days that it took me to write the\n120-page thing, I wasn&#39;t even actually typing on a keyboard: We were\ntravelling across the country, lots of idle time, I didn&#39;t have a\nlaptop, but I basically &quot;wrote&quot; at least one chapter and then memorized\n(most of) it. Went back and forth, new ideas. Completely absorbed.</p>\n<p>I want more of that. :-)</p>\n<p>Maybe stuff will eventually get published (as in: I might put it on this\nwebsite), but not now. I do this for myself. I&#39;m not even remotely\ninterested in my work getting torn apart by rude critics. Leave me\nalone. :-)</p>\n<p>And if you think about suggesting the use of LLMs: Congratulations, you\nhave <em>completely</em> missed the point. &quot;Setzen, 6.&quot;</p>","headings":[{"level":1,"text":"Novellas with groff","id":"novellas-with-groff"},{"level":2,"text":"groff","id":"groff"},{"level":3,"text":"Basic formatting","id":"basic-formatting"},{"level":3,"text":"Footers and page numbers","id":"footers-and-page-numbers"},{"level":3,"text":"Header","id":"header"},{"level":3,"text":"A closer look at traps","id":"a-closer-look-at-traps"},{"level":3,"text":"Inter-sentence spacing","id":"inter-sentence-spacing"},{"level":3,"text":"German hyphenation","id":"german-hyphenation"},{"level":2,"text":"Markdown and other pre-processing","id":"markdown-and-other-pre-processing"},{"level":2,"text":"Vim","id":"vim"},{"level":3,"text":"Goyo","id":"goyo"},{"level":3,"text":"Reflowing text","id":"reflowing-text"},{"level":2,"text":"Git","id":"git"},{"level":2,"text":"demo-book.tar.gz: Putting it all together","id":"demo-book-tar-gz-putting-it-all-together"},{"level":2,"text":"The writing process itself","id":"the-writing-process-itself"},{"level":2,"text":"Where to go from here?","id":"where-to-go-from-here"}]}}