jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.14k stars 3.35k forks source link

The command --toc-depth doesn't change the depth (md->pdf) #9861

Closed Thanatos0173 closed 3 months ago

Thanatos0173 commented 3 months ago

Reproducible steps :

  1. Create a file with the content:
    
    ---
    title: Title
    subtitle: Subtitle
    lang: fr-FR
    author: "Author"
    theme: "Boadilla"
    colortheme: "dolphin"
    fonttheme: "structurebold"
    aspectratio: 43
    fontsize: 14pt
    linkstyle: bold
    ---

Section One

Subsection One

Content

Subsection Two

Content

Section Two

Subsection One

Content

Subsection Two

Content


Compile using :

```shell
pandoc -t beamer --toc-depth=5 --toc  <file.md> -o <file.pdf>

Output: The toc slide is :

  1. Section One
  2. Section Two

Expected: The toc slide should be:

  1. Section One 1.1. Subsection One 1.2. Subsection Two
  2. Section Two 1.1. Subsection One 1.2. Subsection Two

Version :

pandoc 3.2
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/thanatos/.local/share/pandoc
Copyright (C) 2006-2024 John MacFarlane. 
Web: https://pandoc.orgThis is free software; see the source for copying conditions. There is nowarranty, not even for merchantability or fitness for a particular purpose.

OS : Linux, Archcraft

jgm commented 3 months ago

default latex template has:

$if(beamer)$
\begin{frame}[allowframebreaks]
$if(toc-title)$
  \frametitle{$toc-title$}
$endif$
  \tableofcontents[hideallsubsections]
\end{frame}
$else$
{
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
$endif$
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$

So, the \setcounter{tocdepth}{$toc-depth$} is only set for latex output, not for beamer. For beamer, we have the [hideallsubsections] option hard-coded.

I can't remember the rationale, if any, for these decisions.

jgm commented 3 months ago

One important thing to note: in your example, slide level = 2 (see the manual for this concept). That means that the level-2 headings do not create subsections; they create slides. So, even remove [hideallsubsections], you'd only get the top level in your toc.

jgm commented 3 months ago

Perhaps a better test case is

---
title: Title
subtitle: Subtitle
lang: fr-FR
author: "Author"
theme: "Boadilla"
colortheme: "dolphin"
fonttheme: "structurebold"
aspectratio: 43
fontsize: 14pt
linkstyle: bold
---

# Section One

## Subsection One

### Slide

Content

## Subsection Two

### Another slide

Content

# Section Two

## Subsection One

### Slide title

Content

## Subsection Two

### Another slide title

Content
jgm commented 3 months ago

I think I'll change this so it uses toc-depth like the regular LaTeX template.

Thanatos0173 commented 3 months ago

So, just to be sure, I can't change the way the toc is generated because I'm using beamer ? Or do I need to change the default latex template to be able to show more information in the toc ?

jgm commented 3 months ago

You'd have to change the latex template, yes. The commit noted above does this, so you can just grab the new template from there.

Thanatos0173 commented 3 months ago

Ok, thank you very much !

NMarkgraf commented 1 month ago

Bad fix! This breaks all my coding, because I do not want subsections in toc. Beamer does not care about toc-dept. - So this might be a bad solution.

jgm commented 1 month ago

@NMarkgraf can you elaborate? Setting toc-depth has no effect in beamer?

jgm commented 1 month ago

@NMarkgraf In my tests, --toc-depth seems to work properly with beamer. If you think this is not the case, please give full instructions for reproducing the issue.