[FR] Custom Environment Using `Div` Blocks
I am just learning about bookdown. I would like to use it for lecture notes, largely due to the much more accessible nature of its HTML output vs a PDF compiled with LaTeX. I appreciate that this means I'll have to tone back my macro usage—probably not a bad thing—but there are some things which I'm struggling to replace.
My main issue is the lack of usability of the numbered environments. Unless I'm misunderstanding, there seems to be a preset collection, some of which are numbered and some aren't. Moreover, the numbering is independent between different environments—eg, Definition 1.1 may come after Corollary 1.2—which is just very difficult for the reader.
The environments themselves seem perfectly reasonable.
::: {.theorem name="Pythagoras" #pythag}
...theorem content...
:::
Theorem 1.1 (Pythagoras) ...content...
**Theorem 1.1 (Pythagoras)** ...content...
This just uses one of Pandoc's fenced Div blocks. Some details towards constructing a custom block are given in the RMarkdown Cookbook. Would it be possible to have a new environment taking the following form?
::: {.env type="TYPE" name="NAME" #tag}
...content...
:::
TYPE 1.1 (NAME). ...content...
**TYPE 1.1** (NAME)**.** ...content...
Its tag would be env:tag, or simply tag and it's up to the user to make sure the labels are unique—like, when writing LaTeX documents, people typically manually use \label{eq:tag} or \label{thm:tag}. Incidentally, I have taken (NAME) out of bold face; most people seem to use this in my experience, but it's hardly the end of the world either way. Perhaps additionally some flag could be put in to remove the numbering, akin to adding a * in LaTeX.
A further extension could include a 'literal' flag, where type="TYPE" doesn't become TYPE (**TYPE**), but rather just literally TYPE (TYPE). This way, one could write type="*Remark*" if, for example, one wants Remark in italics, not bold. Even if the type was always literal, so one had to write type=**Theorem** every time, it's hardly a big effort. The added flexibility is surely worth the few extra characters.
This has two key benefits. First, it numbers sequentially, which really is a must for mathematical lecture notes. Second, it allows customisation of the type: I just have a single format for theorem, lemma, corollary, etc.
It seems like the main place to be looking for this in the code is in /R/utils.R#474+. Also, /R/html.R#L650+ seems relevant.