Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beamer writer doesn't output \hypertarget in header correctly #3220

Closed
Frefreak opened this issue Nov 9, 2016 · 9 comments
Closed

beamer writer doesn't output \hypertarget in header correctly #3220

Frefreak opened this issue Nov 9, 2016 · 9 comments

Comments

@Frefreak
Copy link

Frefreak commented Nov 9, 2016

For this test snippet

# Header1 {#head1}

## abc {#abc}

text under abc

## def {#def}

text under def

link to [abc](#abc)

I want the link under def points to abc header, the beamer output this by invoking pandoc test.md -t beamer:

\section{Header1}\label{head1}

\begin{frame}{abc}

text under abc

\end{frame}

\begin{frame}{def}

text under def

link to \protect\hyperlink{abc}{abc}

\end{frame}

the generated pdf does contains a link but when clicked it redirects to the first page. If I manually add \hypertarget{abc}{} before the \begin{frame}{abc} line and disable ignorenonframetext (which I know from this SO question) the link works as expected.

Is this behaviour expected? Is there any easier way without manually modifying generated latex code to achieve the same effects? The latex writer (-t latex) seems create the link correctly though.

@georgejean
Copy link

georgejean commented Nov 10, 2016

Hi,

it seems that

# Header1 {#head1}

## \hypertarget{abc}{abc}

text under abc

## \hypertarget{def}{def 1}

text under def

## \hypertarget{otherdef}{def 2}

link to [abc](#abc)

link to [def 1](#def)

does the job.

From Pandoc User's Guide:

Note, however, that this method of providing links to sections works only in HTML, LaTeX, and ConTeXt formats.
...
Internal links are currently supported for HTML formats (including HTML slide shows and EPUB), LaTeX, and ConTeXt.

@Frefreak
Copy link
Author

Thanks! In this way the link points to the content under the header rather than the header itself (tried in okular), but this is totally acceptable.

@jgm
Copy link
Owner

jgm commented Nov 10, 2016 via email

@Frefreak
Copy link
Author

Frefreak commented Nov 11, 2016

I didn't notice the username and thought that was the "official recommended solution" to this... Is it possible to make this work without inline latex code?

@georgejean
Copy link

georgejean commented Nov 12, 2016

According to the doc

Frame attributes in beamer
Sometimes it is necessary to add the LaTeX [fragile] option to a frame in beamer (for example, when using the minted environment). This can be forced by adding the fragile class to the header introducing the slide:

Fragile slide {.fragile}

All of the other frame attributes described in Section 8.1 of the Beamer User’s Guide may also be used: allowdisplaybreaks, allowframebreaks, b, c, t, environment, label, plain, shrink.

a more pandoc way to achieve this could be

# Header1 {#head1}

## abc {label=abc}

text under abc

## def 1 {label=def}

text under def

## otherdef

link to [abc](#abc)

link to [def 1](#def)

@alex-ball
Copy link

Note that, in normal HTML, LaTeX, and ConTeXt and in other slide outputs, links to headings of whatever level work as advertised. The same is true of Beamer output except for whatever heading level is selected as the slide level.

(Okay, for the above-slide-level links to work you have to remove [ignorenonframetext] from the class options.)

Surely it makes sense to routinely add the label attribute (with the auto-generated ID) to all frames in Beamer output to eliminate this inconsistency? It is something of a chore to ask the author to add them all manually for that one heading level...

@jgm jgm added this to the pandoc 2.0 milestone Mar 15, 2017
@jgm
Copy link
Owner

jgm commented Mar 15, 2017

@Frefreak - Disabling ignorenonframetext would have a number of other consequences which would amount to a breaking change.

For this reason @georgejean's approach, which puts the hypertarget inside the frame title, seems better. (Of course, pandoc should do this automatically rather than making the user put in raw latex.)

This should be an easy change; I'll put in in the pandoc 2.0 milestone.
For reference, here's what the latex would look like:

\begin{frame}{\hypertarget{abc}{abc}}

text under abc

\end{frame}

\begin{frame}{\hypertarget{def}{def 1}}

text under def

\end{frame}

\begin{frame}{\hypertarget{otherdef}{def 2}}

link to \protect\hyperlink{abc}{abc}

link to \protect\hyperlink{def}{def 1}

@Frefreak
Copy link
Author

Thank you. At that time I would use {#abc} instead of {label = abc} right?

@jgm jgm closed this as completed in 38c3a68 Mar 16, 2017
@jgm
Copy link
Owner

jgm commented Mar 16, 2017 via email

jgm added a commit that referenced this issue Mar 21, 2017
Previously you could link to a header above or below slide
level but not TO slide level.  This commit changes that.
Hypertargets are inserted inside frame titles; technically
the reference is to just after the title, but in normal
use (where slides are viewed full screen in a slide show),
this does not matter.

Closes #3220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants