Open gl-eb opened 2 months ago
When a div with #title-slide is present in the document (used to horizontally center text https://github.com/quarto-dev/quarto-cli/issues/1231)
About this, I don't think this is the right solution to center horizontally a slide. First, this is using an id which is supposed to be unique on a HTML page. id = "title-slide"
is already used... by the title slide of the presentation. Then, using this internal id for something else than the title slide is not recommended.
Why using this id ? You don't need it. It "works" because the CSS rules that apply to title slide with this id will then apply to this div. But you don't want all the style to apply. Just use same CSS rules
:::{style="text-align: center;"}
Profound statement
:::
Using using another class and defining the CSS rule in a CSS or SCSS theme file.
:::{.center-h}
Profound statement
:::
.reveal section div.center-h {
text-align: center;
}
hash-type is set to number, the title on the title slide is top-aligned instead of vertically centered. Removing hash-type: number reverts the expected behaviour.
This is related to
fixed by
When hash-type: number
we are not expecting any element to have #title-slide
. We are removing it ourself
https://github.com/quarto-dev/quarto-cli/blob/cf0b7d06e67acb6180c822cc77e89cb936bb3c00/src/format/reveal/format-reveal.ts#L386-L395
As I explained doc.getElementById("title-slide");
is supposed to matched only one id
. But adding another one in the document makes it not removed, and then the center-title-slide
processing is not applying correctly
https://github.com/quarto-dev/quarto-cli/blob/cf0b7d06e67acb6180c822cc77e89cb936bb3c00/src/format/reveal/format-reveal.ts#L585-L588
Our processing is looking for #title-slide
id. And it is finding the additional div element and not the title slide, so the title slide centering applies to the div added and not the expected title slide.
Here, the problem really is to not use #title-slide
as an id. By applying it on another element, obviously this inherits all behavior supposed to apply to this element.
Even if we make it better for hash-type: number
to avoid this problem, it could lead to other undesired side effect as an id is supposed to be unique.
used to horizontally center text #1231
This discussion contains other solutions. Using #title-slide
is not a good one. You should probably try others
Hope it helps understand the situation.
About this, I don't think this is the right solution to center horizontally a slide. First, this is using an id which is supposed to be unique on a HTML page.
id = "title-slide"
is already used... by the title slide of the presentation. Then, using this internal id for something else than the title slide is not recommended.
I should have known about id's having to be unique. I vaguely remember finding the issue I linked a while ago and the id = "title-slide"
method being the only one that worked for whatever reason. The issue only came up yesterday when I noticed the change in title slide formatting.
I've switched to using text-align: center
now. I also appreciate you explaining the mechanics behind this, thanks!
Bug description
When a div with
#title-slide
is present in the document (used to horizontally center text https://github.com/quarto-dev/quarto-cli/issues/1231) andhash-type
is set tonumber
, the title on the title slide is top-aligned instead of vertically centered. Removinghash-type: number
reverts the expected behaviour.Steps to reproduce
Expected behavior
The title on the title slide should be vertically centered
Actual behavior
The title on the title slide is top-aligned
Your environment
Quarto check output