aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-06-02 14:37:15 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-06-02 14:38:18 -0700
commit8d19e45b97d81276b046de2a5078cf5ce0122745 (patch)
tree2b86a0fc876c35a0ee522814af40ecbad6563b00 /src
parent768ddc3d5626dea320ee050ee8b411b43daa1105 (diff)
downloadpandoc-8d19e45b97d81276b046de2a5078cf5ce0122745.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs16
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) <>