Skip to content

theorem-title not in its own HTML paragraph #1926

Closed

Description

@jjallaire

Discussed in #1925

Originally posted by zeileis August 16, 2022
When using one of the theorem divs, then in the HTML output the corresponding "theorem-title" is sometimes in its own paragraph and sometimes not. Specifically, if the div just consists of a single paragraph, then the title is in a separate paragraph. Otherwise it is merged into the first paragraph.

As a concrete example consider:

::: {#exr-1}
Compute: 25 + 17.
:::

::: {#exr-2}
Let a = 25 and b = 17.

Compute: a + b.
:::

I have simply inserted the snippet above into the intro.qmd from the mybook demo (quarto create-project mybook --type book). This yields the following HTML output using quarto 1.0.38 with pandoc 2.17.1.1 on Debian GNU/Linux.

<div id="exr-1" class="theorem exercise">
<p><span class="theorem-title"><strong>Exercise 1.1 </strong></span></p>
<p>Compute: 25 + 17.</p>
</div>
<div id="exr-2" class="theorem exercise">
<p><span class="theorem-title"><strong>Exercise 1.2 </strong></span>Let a = 25 and b = 17.</p>
<p>Compute: a + b.</p>
</div>

Rendered in a browser it looks like this:

browser screenshot

Note that the text of the first exercise starts in a new paragraph while the second exercise starts in the same paragraph as the title.

Is this difference by design? Can I somehow switch between these layouts? I would like a consistent layout, preferably with the theorem-title in its own paragraph.

Activity

  1. jjallaire commented on Aug 16, 2022

    @jjallaire
    CollaboratorAuthor

    I think we are automatically assuming that the first paragraph is the name of the theorem when we shouldn't be (we should really be looking for a header not a plain paragraph). Will investigate and hopefully resolve shortly.

  2. self-assigned this
    on Aug 16, 2022
  3. added this to the v1.1 milestone on Aug 16, 2022
  4. mcanouil commented on Aug 16, 2022

    @mcanouil
    Collaborator

    I think the issue is not about the name/label (if we are talking about the same thing), which in my understanding is a level 2 header.
    The behaviour is the same with/without the level 2 header.
    image

    I think the issue is about the implicit markdown/html breakline, see #1925 (comment).

  5. cscheid commented on Aug 18, 2022

    @cscheid
    Member

    Context

    Let me first document the current state of affairs:

    Source

    ---
    title: github-issue-1926
    keep-md: true
    ---
    
    ::: {#exr-1}
    
    Compute: 25 + 17.
    
    :::
    
    ::: {#exr-2}
    
    Let a = 25 and b = 17.
    
    Compute: a + b.
    
    :::
    
    ::: {#exr-3}
    
    ## A title
    
    Compute: 25 + 17.
    
    :::
    
    ::: {#exr-4}
    
    ## Another title
    
    Let a = 25 and b = 17.
    
    Compute: a + b.
    
    :::
    

    HTML output

    image

    PDF output

    image

    Docx output

    image

    Discussion

    There are two factors: whether or not we have titles, and whether or not we have multiple paragraphs. The output we're generating is consistent between HTML and Docx, but inconsistent with PDF. PDF output, specifically, always uses the exercise number and title as the beginning of the exercise description. If my understanding is correct, @jjallaire, you'd like to make it so that the HTML and Docx we emit follows the PDF output. This behavior would be consistent with cs/mathy textbooks and material I used in my previous academic life.

    I agree with that goal, except that it also means changing the HTML behavior when there's a single paragraph and no title, which I think wasn't a source of complaints so far. I'm going to go ahead and do this, but I'm posting the discussion here just so we're all on the same page.

  6. jjallaire commented on Aug 18, 2022

    @jjallaire
    CollaboratorAuthor

    If we are requiring a title, could we just have it not resolve and/or print warning if there is a single paragraph and no title?

    Also, should we require the using of a heading element to denote the title?

  7. cscheid commented on Aug 18, 2022

    @cscheid
    Member

    Do we want to require a title? The PDF version does not.

  8. cscheid commented on Aug 18, 2022

    @cscheid
    Member

    My proposal would simply make sure that the first paragraph is always merged to the paragraph that starts with "Exercise ...". If there's a title, that gets a typographically-distinct treatment, but also on the same paragraph. This would make all formats emit more-or-less consistent output.

  9. added a commit that references this issue on Aug 18, 2022
    aae43cc
  10. added
    bug
    open-pr
    on Aug 18, 2022
  11. jjallaire commented on Aug 18, 2022

    @jjallaire
    CollaboratorAuthor

    Okay that sounds right to me

  12. added a commit that references this issue on Aug 18, 2022
    73f6fae
  13. removed
    open-pr
    on Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions