Skip to content

toccolor needed when Documentclass is declared #11098

@szarka

Description

@szarka

I'm using Pandoc 3.7.0 on Windows to create a tagged PDF from Markdown with the command line pandoc --pdf-engine=lualatex -f markdown -t pdf book.md -o book.pdf --template=custom-template.tex.

My source file has the following YAML block at the top:

header-includes: |
    \usepackage{hanging}
documentclass: book
classoption: oneside
title: Principles of Economics
date: 2025-08-30
lang: en-US
colorlinks: true
linkcolor: blue
top-level-division: chapter
numbersections: true
pagestyle: headings
toc: true
toc-depth: 1

The custom template was produced by using the command pandoc -D latex > custom-template.backup and then adding the line \DocumentMetadata{ lang = en-US, pdfstandard = ua-2, pdfstandard = a-4f, tagging=on, tagging-setup={math/setup=mathml-SE} } at the top.

With this configuration, I receive the following error:

! LaTeX Error: Unknown color ''.

For immediate help type H <return>.
 ...

l.77 \hypersetup{linkcolor=}

This is apparently due to this section of the default/custom template:

$if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
$endif$
{
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
$endif$
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$

Which produces this block in the intermediate file:

{
  \hypersetup{linkcolor=}
  \setcounter{tocdepth}{1}
  \tableofcontents
  }

Adding the line toccolor: blue to my YAML block fixes the error and then everything works as expected. However, I don't believe this variable should be needed. And if, instead of adding toccolor, I remove the top line of the template with \DocumentMetadata, everything also works as expected.

So it seems that somehow adding \DocumentMetadata causes the logic in the block that handles the TOC to fail? Or rather, the result of the logic in that block causes some other conflict?

Am I wrong about toccolor not needing to be specified or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions