@@ -50,8 +50,6 @@ import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
51data WriterState =
51data WriterState =
52 WriterState { stInNote :: Bool -- true if we're in a note
52 WriterState { stInNote :: Bool -- true if we're in a note
53− , stInTable :: Bool -- true if we're in a table
54− , stTableNotes :: [Doc] -- List of notes in current table
55 , stOLLevel :: Int -- level of ordered list nesting
53 , stOLLevel :: Int -- level of ordered list nesting
56 , stOptions :: WriterOptions -- writer options, so they don't have to be parameter
54 , stOptions :: WriterOptions -- writer options, so they don't have to be parameter
57 , stVerbInNote :: Bool -- true if document has verbatim text in note
55 , stVerbInNote :: Bool -- true if document has verbatim text in note
@@ -72,8 +70,8 @@ data WriterState =
72writeLaTeX :: WriterOptions -> Pandoc -> String
70writeLaTeX :: WriterOptions -> Pandoc -> String
73writeLaTeX options document =
71writeLaTeX options document =
74 evalState (pandocToLaTeX options document) $
72 evalState (pandocToLaTeX options document) $
75− WriterState { stInNote = False, stInTable = False,
73+ WriterState { stInNote = False,
76− stTableNotes = [], stOLLevel = 1, stOptions = options,
74+ stOLLevel = 1, stOptions = options,
77 stVerbInNote = False,
75 stVerbInNote = False,
78 stTable = False, stStrikeout = False,
76 stTable = False, stStrikeout = False,
79 stUrl = False, stGraphics = False,
77 stUrl = False, stGraphics = False,
@@ -422,7 +420,6 @@ blockToLaTeX HorizontalRule = return $
422blockToLaTeX (Header level (id',classes,_) lst) =
420blockToLaTeX (Header level (id',classes,_) lst) =
423 sectionHeader ("unnumbered" `elem` classes) id' level lst
421 sectionHeader ("unnumbered" `elem` classes) id' level lst
424blockToLaTeX (Table caption aligns widths heads rows) = do
422blockToLaTeX (Table caption aligns widths heads rows) = do
425− modify $ \s -> s{ stInTable = True, stTableNotes = [] }
426 headers <- if all null heads
423 headers <- if all null heads
427 then return empty
424 then return empty
428 else ($$ "\\hline\\noalign{\\medskip}") `fmap`
425 else ($$ "\\hline\\noalign{\\medskip}") `fmap`
@@ -433,11 +430,8 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
433 else text "\\noalign{\\medskip}"
430 else text "\\noalign{\\medskip}"
434 $$ text "\\caption" <> braces captionText
431 $$ text "\\caption" <> braces captionText
435 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
432 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
436− tableNotes <- liftM (reverse . stTableNotes) get
437− let toNote x = "\\footnotetext" <> braces (nest 2 x)
438− let notes = vcat $ map toNote tableNotes
439 let colDescriptors = text $ concat $ map toColDescriptor aligns
433 let colDescriptors = text $ concat $ map toColDescriptor aligns
440− modify $ \s -> s{ stTable = True, stInTable = False, stTableNotes = [] }
434+ modify $ \s -> s{ stTable = True }
441 return $ "\\begin{longtable}[c]" <>
435 return $ "\\begin{longtable}[c]" <>
442 braces ("@{}" <> colDescriptors <> "@{}")
436 braces ("@{}" <> colDescriptors <> "@{}")
443 -- the @{} removes extra space at beginning and end
437 -- the @{} removes extra space at beginning and end
@@ -446,7 +440,6 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
446 $$ vcat rows'
440 $$ vcat rows'
447 $$ "\\hline"
441 $$ "\\hline"
450 $$ "\\end{longtable}"
443 $$ "\\end{longtable}"
452toColDescriptor :: Alignment -> String
445toColDescriptor :: Alignment -> String
@@ -661,16 +654,10 @@ inlineToLaTeX (Note contents) = do
661 modify (\s -> s{stInNote = True})
654 modify (\s -> s{stInNote = True})
662 contents' <- blockListToLaTeX contents
655 contents' <- blockListToLaTeX contents
663 modify (\s -> s {stInNote = False})
656 modify (\s -> s {stInNote = False})
664− inTable <- liftM stInTable get
665 let optnl = case reverse contents of
657 let optnl = case reverse contents of
666 (CodeBlock _ _ : _) -> cr
658 (CodeBlock _ _ : _) -> cr
667 _ -> empty
659 _ -> empty
670− curnotes <- liftM stTableNotes get
671− modify $ \s -> s{ stTableNotes = contents' : curnotes }
672− return $ "\\footnotemark" <> space
673− else return $ "\\footnote" <> braces (nest 2 contents' <> optnl)
660+ return $ "\\footnote" <> braces (nest 2 contents' <> optnl)
674 -- note: a \n before } needed when note ends with a Verbatim environment
661 -- note: a \n before } needed when note ends with a Verbatim environment
676citationsToNatbib :: [Citation] -> State WriterState Doc
663citationsToNatbib :: [Citation] -> State WriterState Doc