From 8d19e45b97d81276b046de2a5078cf5ce0122745 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 2 Jun 2013 14:37:15 -0700 Subject: LaTeX writer: Always create labels for sections. Previously the labels were only created when there were links to the section in the document. Closes #871. --- src/Text/Pandoc/Writers/LaTeX.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc') 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) <> -- cgit v1.2.3