title: Create index of definitions / theorems at end of bookdown book
body: <p>For reader convenience, I'd like to include, at the end of my bookdown book, written in markdown, a simple list or index of definitions from the body of the book. i.e. ones created using custom blocks, like this: </p>
  
  <pre><code>```{definition, bar, echo=T}
  A bar is defined here as a foo-like thing.
  ```
  </code></pre>
  
  <p>(My need is for definitions, but others might like lists of theorems, etc. Don't know if lists of figures and tables could be covered in the same way?)</p>
  
  <p>Thanks to @yihui I know that <code>knitr::all_labels(engine == 'definition')</code> is my friend.</p>
  
  <p>So I can do this anywhere in the end of the book, usually at the end:</p>
  
  <pre><code>```{r comment="",results="asis",echo=FALSE}
  knitr::all_labels(engine == 'definition') %&gt;% unlist %&gt;% paste0("\n\n","\\@ref(def:",.,"): ",.,"\n\n",collapse="\n\n") %&gt;% cat
  
  ```
  </code></pre>
  
  <p>Which prints this: </p>
  
  <pre><code>1: bar
  
  2: foobar
  </code></pre>
  
  <p>With clickable numbers. Which is OK. But wouldn't it be nice if, after each label, the actual definition could be printed too? (The content of the blocks is not available in knitr::all_labels(engine == 'definition'))</p>