writing a tufte book in markdown: additions

This commit is contained in:
Wouter Groeneveld 2022-11-16 08:53:07 +01:00
parent 0fc356a46e
commit 2b77652a78
1 changed files with 16 additions and 1 deletions

View File

@ -10,7 +10,7 @@ categories:
- software
---
Somehow, [Writing Academic Papers in Markdown](/post/2021/02/writing-academic-papers-in-markdown/) is one of my most popular blog posts. I'm glad so many (presumably academics) are looking to partially ditch LaTeX and separate content from markup! Pandoc is a wonderful tool that takes in a plain `.md` Markdown file and spits out whatever you'd like: Word, HTML, or of course, PDFs using a TeX engine of your choice---which is what we're interested in.
Somehow, [Writing Academic Papers in Markdown](/post/2021/02/writing-academic-papers-in-markdown/) is one of my most popular blog posts. I'm glad so many people are looking to partially ditch LaTeX and separate content from markup! Pandoc is a wonderful tool that takes in a plain `.md` Markdown file and spits out whatever you'd like: Word, HTML, or of course, PDFs using a TeX engine of your choice---which is what we're interested in.
Writing a paper in Markdown is easy enough since most of the post processing is done by the conference or journal template you slap on afterwards. For my PhD dissertation, things are a bit more complicated, as I wanted to use the [tufte-book](https://www.latextemplates.com/template/tufte-style-book) document style. [Edward Tufte's books](https://www.edwardtufte.com/tufte/books_vdqi) are simply amazing. He's a statistics and visualization expert that has inspired an entire army of design and styling guidelines---including a TeX package. That means we can do things like this:
@ -98,6 +98,10 @@ And Pandoc will interpret the width ratio and produce `includegraphics[width=1\t
I have no solution for margin figures except for a custom property within `{}`that does more or less the same.
As for tables, Pandoc generates `longtable` blocks instead of regular ones, and it's full of weird crap. Most of the tables I have require special TeX commands anyway, for instance to rotate certain column headers, so I gave up and simply relied on TeX for those blocks instead.
If you want subtables: do not use the deprecated `subfigure` package which is incompatible with tufte-book! `booktabs` and `subfig` (with `caption=false`) does the trick, see [this stackexchange post](https://tex.stackexchange.com/questions/87364/problem-with-tufte-book-and-subfigure).
## Acronyms
Inspired by [pandoc-acro](https://kprussing.github.io/pandoc-acro/), I created a simplified version by replacing `\+([A-Z]\w+)` with `\ac{\1}`. That means you write:
@ -129,6 +133,17 @@ Tufte starts his later books out with a "new thought" in each new chapter and se
2. Scan for the next line that is not empty; a TeX command; or the start of a TeX block---in case of that last one, fast-forward to the first `\end{}`.
3. Break up the line, push the first words into `\newthought{}`, and save.
As for text alignment, tufte-book uses left alignment instead of a justified one as Tufte believes it's easier to read. I think I agree, but as it's an academic text-heavy work, I still like it to be justified. The `justified` option for the document breaks more than it fixes though, as a lot of hyphenation errors occurred, to the point that fixing them manually `\hyphen{}` was fruitless. Thanks to [this blog article](https://sumanta679.wordpress.com/2009/05/20/latex-justify-without-hyphenation/), adding
```
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
```
Creates a Word-like justified style, spreading out words rather than breaking them.
## Other TeX-specific settings
Remember that tufte-book by default doesn't show sections in the table of contents, and that dotted lines are absent. This can be fixed with: