diff options
Diffstat (limited to 'src/Text/Pandoc/Writers/LaTeX.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 287a978f4..04bb3f9e2 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -507,14 +507,16 @@ sectionHeader unnumbered ref level lst = do opts <- gets stOptions let level' = if book || writerChapters opts then level - 1 else level internalLinks <- gets stInternalLinks - let refLabel lab = (if ref `elem` internalLinks - then text "\\hyperdef" + let refLabel x = (if ref `elem` internalLinks + then text "\\hyperdef" <> braces empty <> braces (text ref) - <> braces (lab <> text "\\label" - <> braces (text ref)) - else lab) - let headerWith x y = refLabel $ text x <> y + <> braces x + else x) + let headerWith x y r = refLabel $ text x <> y <> + if null r + then empty + else text "\\label" <> braces (text r) let sectionType = case level' of 0 | writerBeamer opts -> "part" | otherwise -> "chapter" @@ -526,7 +528,7 @@ sectionHeader unnumbered ref level lst = do _ -> "" return $ if level' > 5 then txt - else headerWith ('\\':sectionType) stuffing + else headerWith ('\\':sectionType) stuffing ref $$ if unnumbered then "\\addcontentsline{toc}" <> braces (text sectionType) <> |