diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-08-19 09:52:01 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-08-19 09:52:01 -0700 |
| commit | 70329edcd7afb7b3f8f015b13ab2e734c9e31d05 (patch) | |
| tree | 34c8363de72e10ae737681f4cdbdb3f25b5f4a97 /src | |
| parent | 068fce4293eb139f54d4825e1dbdcaf35e34da03 (diff) | |
LaTeX writer: improve internal links and targets.
We no longer wrap section headings in a `\hypertarget`.
This is unnecessary (hyperref creates an anchor based on the
label) and it interferes with tagging.
In addition, we now use `\hyperref` rather than `\hyperlink`
for internal links.
Currently `\hypertarget` is still being used for link anchors
not on headings.
Closes #8744. Thanks to @u-fischer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index a09e366a7..3585e1544 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -734,12 +734,11 @@ sectionHeader classes ident level lst = do else empty lab <- labelFor ident let star = if unnumbered then text "*" else empty - let stuffing = star <> optional <> contents - stuffing' <- hypertarget True ident $ - text ('\\':sectionType) <> stuffing <> lab + let title = star <> optional <> contents return $ if level' > 5 then txt - else prefix $$ stuffing' + else prefix + $$ text ('\\':sectionType) <> title <> lab $$ if unnumbered && not unlisted then "\\addcontentsline{toc}" <> braces (text sectionType) <> @@ -960,7 +959,7 @@ inlineToLaTeX (Link (id',_,_) txt (src,_)) = Just ('#', ident) -> do contents <- inlineListToLaTeX txt lab <- toLabel ident - return $ text "\\protect\\hyperlink" <> braces (literal lab) <> braces contents + return $ text "\\hyperref" <> brackets (literal lab) <> braces contents _ -> case txt of [Str x] | unEscapeString (T.unpack x) == unEscapeString (T.unpack src) -> -- autolink do modify $ \s -> s{ stUrl = True } |
