LaTeX writer: Avoid problem with footnotes in unnumbered headers.

Closes #940.
Added test case.
This commit is contained in:
John MacFarlane 2013-08-16 13:02:55 -07:00
parent ab8c0dcd41
commit 441a7aebf8
2 changed files with 13 additions and 6 deletions

View file

@ -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.

View file

@ -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"
]
]