aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Util.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs
index 8dcec54dd..86b95795c 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Util.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs
@@ -260,8 +260,14 @@ wrapDiv (_,classes,kvs) t = do
hypertarget :: PandocMonad m => Text -> LW m (Doc Text)
hypertarget "" = return mempty
hypertarget ident = do
- label <- labelFor ident
- return $ text "\\phantomsection" <> label
+ inHeading <- gets stInHeading
+ if inHeading
+ then do -- see #9209 (these cases should be rare)
+ ref <- literal <$> toLabel ident
+ return $ text "\\protect\\hypertarget" <> braces ref <> "{}"
+ else do
+ label <- labelFor ident
+ return $ text "\\phantomsection" <> label
labelFor :: PandocMonad m => Text -> LW m (Doc Text)
labelFor "" = return empty