Bookdown (v0.25+) exercise titles should not be numbered

I have a book which I build with bookdown. In the book, I use the exercises environment extensively. My exercises are usually a list of steps. Recently I built the book (I use R 4.2.1, RStudio 2022.07.1 and bookdown 0.27) and noticed that the title of the exercises is numbered too (which was not the case before). To reproduce the issue, I create a new example bookdown project in RStudio and added Rmd file 01-1-exr.Rmd, the contents of which are as follows (I tried the old and the new syntax to define the exercises block):

File contents
  # Excercises
  
  Do exercises \@ref(exr:exr-1) and \@ref(exr:exr-2).
  
  ::: {.exercise #exr-1}
  
  
  1) Open RStudio.
  2) Write `1 + 9` to console.
  
  :::
  
  
  ```{exercise, exr-2, echo=TRUE}
  
  
  1) Open RStudio.
  2) Write `1 + 9` to console.
  
  ```

With bookdown 0.25 and newer I get:

With bookdown 0.24 the old syntax gave the desired result:

If I use HTML comment, which is a regular practice to restart list numbering, pandoc fails:

  ::: {.exercise #exr-1}
  <!-- -->
  
  1) Open RStudio.
  2) Write `1 + 9` to console.
  
  :::

I'm aware that from bookdown 0.25 exercises do not use block2. But what about the numbering? Is it a bug? Or is it expected to have the title of exercises numbered?

Yet, how can I get the previous behaviour? Is using bookdown 0.24 the only option?

Hi,

I believe this is a bug due to the new way we are creating the environment, and the fact that you exercice only contains a list and not title.

Try

---
title: test
output: bookdown::html_document2
---

# Excercises

Do exercises \@ref(exr:exr-1)

::: {.exercise #exr-1}

Playing with the console

1) Open RStudio.
2) Write `1 + 9` to console.

:::

image

As the content of the fenced blocks is only a list, the first part being Exercise 1.1 becomes part of the list.

I'll open an issue in bookdown for that. In the meantime, you can add a Hard Line break as first line in your block content

::: {#exr-1 .exercise}
\

1)  Open RStudio.
2)  Write `1 + 9` to console.
:::

This should prevent the first part to be taken as part of the list.

1 Like

Tracked now in

Thanks for the report!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.