For reader convenience, I would like to include at the end of my markdown book a simple list or index of definitions from the body of the book. those. created using custom blocks, for example:
```{definition, bar, echo=T}
A bar is defined here as a foo-like thing.
```
(My need for definitions, but others may like lists of theorems, etc. Don't know if lists of numbers and tables can be covered equally?)
Thanks @yihui, I know that knitr::all_labels(engine == 'definition')my friend.
Therefore, I can do this anywhere at the end of the book, usually at the end:
```{r comment="",results="asis",echo=FALSE}
knitr::all_labels(engine == 'definition') %>% unlist %>% paste0("\n\n","\\@ref(def:",.,"): ",.,"\n\n",collapse="\n\n") %>% cat
```
What prints this:
1: bar
2: foobar
With numeric numbers. This is normal. But would it be nice if, after each label, the actual definition could also be printed? (The contents of the blocks are not available in knitr :: all_labels (engine == 'definition'))