Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headings do not appear in TOC when inside 2-column layout #336

Closed
Woosah opened this issue Nov 13, 2024 · 3 comments
Closed

headings do not appear in TOC when inside 2-column layout #336

Woosah opened this issue Nov 13, 2024 · 3 comments

Comments

@Woosah
Copy link

Woosah commented Nov 13, 2024

When you use a two-column layout on a page and include any heading inside of the columns, these are not recognized / shown in the table of contents.

Reprex:

---
title: "TOC error reprex"
author: "Myself"
date: "`r Sys.Date()`"
output:
  pagedown::html_paged:
    toc: true
    toc-depth: 3
    self_contained: true
lot: false
lof: false
---

# H1 - normal page

This is a normal page without 2 columns. The level 2 headings are included in the toc.

## H2A - normal page

The first h2.

### H3A - normal page

The first h3.

## H2B normal page

The second h2.

### H3B - normal page

The second h3.

<!-- Here is the CSS: -->

```{css}
.columns-2 {
	display: flex;
}
```


# H1 - 2-column page

This is a 2 column layout. The level 2 and 3 headings are NOT included in the toc.

:::: {.columns-2}

::: {}

## H2A - 2-column page

The first h2 in the left column.

### H3A - 2-column page

The first h3 in the right column.

:::

::: {}

## H2B - 2-column page

The second h2 in the right column.

### H3B - 2-column page

The second h3 in the right column.

:::

::::

Do you have any idea how to solve this?

Best, Ulf

@Woosah
Copy link
Author

Woosah commented Dec 5, 2024

@RLesur @yihui Any idea how to fix / change this?

Kind regards!

@Woosah
Copy link
Author

Woosah commented Dec 10, 2024

After digging deeper into this, it turns out, that neither pagedown (nor bookdown) are the source of this problem, but it stems from pandoc treating fenced divs as "isolated environments" for now.

Closing this here with a link to a comment I posted on a related pandoc issue in case anyone is interested

Multiple subheadings in same fenced div don't appear in the TOC

@Woosah Woosah closed this as completed Dec 10, 2024
@yihui
Copy link
Member

yihui commented Dec 13, 2024

Thanks for the investigation and posting back!

Just FYI, I started rewriting the R Markdown ecosystem this year as the new litedown package, and I've also partially rewritten pagedown there. Below is your example using the litedown setup (to be built via litedown::fuse()):

---
title: "TOC error reprex"
author: "Myself"
date: "`{r} Sys.Date()`"
output:
  html:
    meta:
      css: ["@default", "@book", "@pages"]
      js: ["@pages"]
    options:
      toc:
        depth: 3
---

# H1 - normal page

This is a normal page without 2 columns. The level 2 headings are included in the toc.

## H2A - normal page

The first h2.

### H3A - normal page

The first h3.

## H2B normal page

The second h2.

### H3B - normal page

The second h3.

<!-- Here is the CSS: -->

```{css}
.columns-2 {
	display: flex;
	justify-content: space-between;
}
```


# H1 - 2-column page

This is a 2 column layout. The level 2 and 3 headings are NOT included in the toc.

:::: {.columns-2}

::: {}

## H2A - 2-column page

The first h2 in the left column.

### H3A - 2-column page

The first h3 in the right column.

:::

::: {}

## H2B - 2-column page

The second h2 in the right column.

### H3B - 2-column page

The second h3 in the right column.

:::

::::

And the HTML output can be printed to PDF in browser: TOC.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants