Internal section link fails in beamer output of pandoc markdown

I have tried the answer to this question, but I can't get the internal section links in Pandoc to work with the Latex Beamer output.

Following the Pandoc Documentation, I have created this minimal working example:

# Part One {#part-one}

## Section One {#section-one} 

### Frame one {#frame-one}

- Items... 

### Frame two {#frame-two}

- Items... 
- Link to [Section One](#section-one)

And built it using:

pandoc \
    --table-of-contents \
    -s -t beamer test.md \
    -o test.pdf

The built LaTex Beamer pdf looks fine, but the internal link [Section One](#section-one) just isn't working. It should bring me to the "Section One" frame but it doesn't. How do I make this work?

Edit: here is the LaTex output for -o test.latex:

\documentclass[]{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{:}
\setbeamercolor{caption name}{fg=normal text.fg}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\usepackage{lmodern}
\ifxetex
  \usepackage{fontspec,xltxtra,xunicode}
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \newcommand{\euro}{€}
\else
  \ifluatex
    \usepackage{fontspec}
    \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
    \newcommand{\euro}{€}
  \else
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
      \fi
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}

% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\AtBeginPart{
  \let\insertpartnumber\relax
  \let\partname\relax
  \frame{\partpage}
}
\AtBeginSection{
  \let\insertsectionnumber\relax
  \let\sectionname\relax
  \frame{\sectionpage}
}
\AtBeginSubsection{
  \let\insertsubsectionnumber\relax
  \let\subsectionname\relax
  \frame{\subsectionpage}
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\setcounter{secnumdepth}{0}

\date{}

\begin{document}

\begin{frame}
\tableofcontents[hideallsubsections]
\end{frame}

\part{Part One}\label{part-one}

\hyperdef{}{section-one}{\section{Section One}\label{section-one}}

\begin{frame}{Frame one}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  Items\ldots{}
\end{itemize}

\end{frame}

\begin{frame}{Frame two}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  Items\ldots{}
\item
  Link to \hyperref[section-one]{Section One}
\end{itemize}

\end{frame}

\end{document}

Answers

I think I've pinpointed it to the ignorenonframetext in \documentclass[ignorenonframetext,]{beamer}, which is part of the default Pandoc beamer template.

Since the \hyperdef{}{part-one}{\section{Part One}\label{part-one}} is not inside a frame, it is apparently ignored by hyperref.

Could you try to create your own template (pandoc -D beamer > mytemplate.tex) without the ignorenonframetext and see whether that works without any adverse side effects? (When manually testing the .tex I always had to run LaTeX twice for the changes to take full effect.)

Posted on by mb21

Relevant tags