I've been writing [Microfictions]({{< relref "/content/personal/2020-03-28-microfictions.md" >}}) lately and am hoping to write some longer pieces as I go forward, but I also want a way to collect them all in a print format, as well as make them available online for viewing. At the moment I have no plans for a published book, although doing a free ebook would be cool. But just having somewhere that they can be shared and a form they can be printed in (for myself) is my main goal. In addition, I wanted to use the same base to produce both versions, because: * Why repeat myself? * Why not challenge myself? So I decided to produce my writings in [LaTeX](https://www.latex-project.org/), which I've tried using previously for my [choose-your-own-ending zine]({{< relref "/content/personal/2020-01-07-writing-a-zine-in-latex.md" >}}) and the [whitepaper for Hexago.nl](https://web.archive.org/web/20201125144601/https://hexago.nl/blog/2019-09-09-hexago-nl-whitepaper/). ## PDF - `pdflatex` Developing the PDF was the easiest bit, and required the least amount of new knowledge. All I needed to do was set up the paper like a book using `\documentclass[openany]{book}`, with the `openany` directive meaning that chapters could start without needing a blank page between them. I also didn't want the document growing out of hand as I wrote more and more, so I decided to break up the sections into their own `.tex` documents for each chapter and then using `include{documentname}` brought them into the main `.tex` file. For the sub-documents, all you need to do is act as if they're already part of the parent document, so no new `\documentclass` or `\begin{document}` directives required. To generate the document, you just need to be in a prompt in the folder and run: ``` pdflatex index.tex ``` ## Web - `make4ht` Here's where things got gnarly. I used `make4ht`, which drives `tex4ht`, which is a method of converting TeX (or LaTeX) to HTML or XML. I want to output my document as HTML5, but I also want a bunch of custom styling and an index page which links to all the chapters. For that the following command is required: ``` math4ht index.tex "html5,2" ``` Of course, the output still has no styling and the contents page is a bit of a mess since it goes down into the section level. So now I created a file called `config.cfg` and put the following in it (my actual version has a lot more styling): ``` \Preamble{html} \Configure{@HEAD}{\HCode{}} \Configure{@BODY}{\HCode{