git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Include unnumbered sections in TOC.
commit11f74074454d8c58da18ee1b7e2480530baeb7e1 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 15 Feb 2013, 19:23 (14 years ago) parent0d1fa0a
1 file changed+18−12
src/Text/Pandoc/Writers/LaTeX.hs+18−12
src/Text/Pandoc/Writers/LaTeX.hs+18−12
@@ -494,7 +494,7 @@ sectionHeader unnumbered ref level lst = do
494494 else do
495495 res <- inlineListToLaTeX lstNoNotes
496496 return $ char '[' <> res <> char ']'
497− let stuffing = star <> optional <> char '{' <> txt <> char '}'
497+ let stuffing = star <> optional <> braces txt
498498 book <- gets stBook
499499 opts <- gets stOptions
500500 let level' = if book || writerChapters opts then level - 1 else level
@@ -507,17 +507,23 @@ sectionHeader unnumbered ref level lst = do
507507 <> braces (text ref))
508508 else lab)
509509 let headerWith x y = refLabel $ text x <> y
510− return $ case level' of
511− 0 -> if writerBeamer opts
512− then headerWith "\\part" stuffing
513− else headerWith "\\chapter" stuffing
514− 1 -> headerWith "\\section" stuffing
515− 2 -> headerWith "\\subsection" stuffing
516− 3 -> headerWith "\\subsubsection" stuffing
517− 4 -> headerWith "\\paragraph" stuffing
518− 5 -> headerWith "\\subparagraph" stuffing
519− _ -> txt
520−
510+ let sectionType = case level' of
511+ 0 | writerBeamer opts -> "part"
512+ | otherwise -> "chapter"
513+ 1 -> "section"
514+ 2 -> "subsection"
515+ 3 -> "subsubsection"
516+ 4 -> "paragraph"
517+ 5 -> "subparagraph"
518+ _ -> ""
519+ return $ if level' > 5
520+ then txt
521+ else headerWith ('\\':sectionType) stuffing
522+ $$ if unnumbered
523+ then "\\addcontentsline{toc}" <>
524+ braces (text sectionType) <>
525+ braces txt
526+ else empty
521527
522528-- | Convert list of inline elements to LaTeX.
523529inlineListToLaTeX :: [Inline] -- ^ Inlines to convert