tmaric
tmaric

Reputation: 5497

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}

Upvotes: 1

Views: 1826

Answers (2)

jarauh
jarauh

Reputation: 2006

Internal links do work, as long as they point to slides (not sections). So the following should work:

# Part One {#part-one}

## Section One {#section-one} 

### Frame one {#frame-one}

- Items... 

### Frame two {#frame-two}

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

Of course, this workaround links to the first page of the section, so (1) one has to be careful when adding slides to the beginning of the section and (2) it does not work if the section has an automatic section page to which you want to link. In that case, I see two options:

  1. If you only want to link to the current or next sections start page, you can use \hyperlinksectionstart{text} and \hyperlinksectionstartnext{text} (which seem to be undocumented in the beameruserguide, see https://tex.stackexchange.com/questions/233408/how-to-hyperlink-to-section-title-frame).
  2. Create section pages manually and give them labels.

Upvotes: 0

mb21
mb21

Reputation: 39528

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.)

Upvotes: 2

Related Questions