aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-08-16 13:02:55 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-08-16 13:03:38 -0700
commit441a7aebf8c141612203d1cab0032f8c55e536ed (patch)
treeb991c5babcb42425145ed73210c39a0a025e46dc
parentab8c0dcd410282baaa9429f755ad55e6d01a2466 (diff)
downloadpandoc-441a7aebf8c141612203d1cab0032f8c55e536ed.tar.gz
LaTeX writer: Avoid problem with footnotes in unnumbered headers.
Closes #940. Added test case.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs13
-rw-r--r--tests/Tests/Writers/LaTeX.hs6
2 files changed, 13 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 7f9a99801..98553c421 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -498,14 +498,15 @@ sectionHeader unnumbered ref level lst = do
let noNote (Note _) = Str ""
noNote x = x
let lstNoNotes = walk noNote lst
+ txtNoNotes <- inlineListToLaTeX lstNoNotes
let star = if unnumbered then text "*" else empty
- -- footnotes in sections don't work unless you specify an optional
- -- argument: \section[mysec]{mysec\footnote{blah}}
- optional <- if lstNoNotes == lst
+ -- footnotes in sections don't work (except for starred variants)
+ -- unless you specify an optional argument:
+ -- \section[mysec]{mysec\footnote{blah}}
+ optional <- if unnumbered || lstNoNotes == lst
then return empty
else do
- res <- inlineListToLaTeX lstNoNotes
- return $ char '[' <> res <> char ']'
+ return $ brackets txtNoNotes
let stuffing = star <> optional <> braces txt
book <- gets stBook
opts <- gets stOptions
@@ -536,7 +537,7 @@ sectionHeader unnumbered ref level lst = do
$$ if unnumbered
then "\\addcontentsline{toc}" <>
braces (text sectionType) <>
- braces txt
+ braces txtNoNotes
else empty
-- | Convert list of inline elements to LaTeX.
diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs
index b1427d91f..ebde5b97c 100644
--- a/tests/Tests/Writers/LaTeX.hs
+++ b/tests/Tests/Writers/LaTeX.hs
@@ -36,4 +36,10 @@ tests = [ testGroup "code blocks"
[ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
"$\\sigma|_{\\{x\\}}$"
]
+ , testGroup "headers"
+ [ "unnumbered header" =:
+ headerWith ("foo",["unnumbered"],[]) 1
+ (text "Header 1" <> note (plain $ text "note")) =?>
+ "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
+ ]
]