Anton
Anton

Reputation: 1126

Do not include section in TOC in pandoc

I am using this thesis template. It includes the abstract, acknowledgements, list of figures... in the table of contents. According to the university guidelines my TOC should start with Chapter 1 Introduction and not list abstract, acknowledgements... .

In latex you can just use \section* however using .unnumbered in pandoc results in that section still being included.

What is the cleanest way to exclude the sections before the introduction chapter from the TOC?

Upvotes: 5

Views: 3750

Answers (4)

Luciano Rizzi
Luciano Rizzi

Reputation: 106

You need to combine .unlisted with .unnumbered to achieve this, as stated in Pandoc documentation.

Example:

# Abstract {.unnumbered .unlisted}

# Acknowledgements {.unnumbered .unlisted}

# Chapter 1

Upvotes: 2

Clément
Clément

Reputation: 2648

You can use {.unlisted}.

Typically,

# Intro{.unlisted}

# Chapter 1

compiled with

pandoc test.md --toc -s -o test.html will give you

enter image description here

with the relevant html bit:

<body>
<nav id="TOC" role="doc-toc">
<ul>
<li><a href="#chapter-1">Chapter 1</a></li>
</ul>
</nav>
<h1 class="unlisted" id="intro">Intro</h1>
<h1 id="chapter-1">Chapter 1</h1>
</body>

Source, Doc

Upvotes: 4

sky_y
sky_y

Reputation: 46

I'm using -H header.tex as an Pandoc option.

My workaround is appending:

\let\oldaddcontentsline\addcontentsline

to header.tex directly.

I wrote the same issue on GitHub: https://github.com/chdemko/pandoc-latex-unlisted/issues/1

Upvotes: 2

mb21
mb21

Reputation: 39229

There's an open issue about this in pandoc.

To remove {.unnumbered} headers from the LaTeX TOC, you can meanwhile use the pandoc-latex-unlisted filter.

$ pip install pandoc-latex-unlisted
$ pandoc --filter pandoc-latex-unlisted input.md -o output.pdf

Upvotes: 3

Related Questions