git.iko.soy/typeable/pandoc
on master help sign in
LaTeX/Beamer writer: allow hyperlinks to frames.

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.

commit38c3a683468428fc26485f3346bdbbb4eb7d6ef2 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 16 Mar 2017, 10:15 (10 years ago) parent257d96f
1 file changed+13−4
src/Text/Pandoc/Writers/LaTeX.hs+13−4
src/Text/Pandoc/Writers/LaTeX.hs+13−4
@@ -390,10 +390,19 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts)
390390 let options = if null optionslist
391391 then ""
392392 else "[" ++ intercalate "," optionslist ++ "]"
393− let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ options) :
394− if tit == [Str "\0"] -- marker for hrule
395− then []
396− else (RawInline "latex" "{") : tit ++ [RawInline "latex" "}"]
393+ let latex = RawInline (Format "latex")
394+ slideTitle <-
395+ if tit == [Str "\0"] -- marker for hrule
396+ then return []
397+ else
398+ if null ident
399+ then return $ latex "{" : tit ++ [latex "}"]
400+ else do
401+ ref <- toLabel ident
402+ return $ latex ("{%\n\\protect\\hypertarget{" ++
403+ ref ++ "}{%\n") : tit ++ [latex "}}"]
404+ let slideStart = Para $
405+ RawInline "latex" ("\\begin{frame}" ++ options) : slideTitle
397406 let slideEnd = RawBlock "latex" "\\end{frame}"
398407 -- now carve up slide into blocks if there are sections inside
399408 bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts