@@ -117,7 +117,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
117117 else return blocks'
118118 body <- mapM (elementToLaTeX options) $ hierarchicalize blocks''
119119 biblioTitle <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
120− let main = render colwidth $ vcat body
120+ let main = render colwidth $ vsep body
121121 st <- get
122122 let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
123123 citecontext = case writerCiteMethod options of
@@ -170,7 +170,7 @@ elementToLaTeX _ (Blk block) = blockToLaTeX block
170170elementToLaTeX opts (Sec level _ id' title' elements) = do
171171 header' <- sectionHeader id' level title'
172172 innerContents <- mapM (elementToLaTeX opts) elements
173− return $ vcat (header' : innerContents)
173+ return $ vsep (header' : innerContents)
174174
175175-- escape things as needed for LaTeX
176176stringToLaTeX :: Bool -> String -> State WriterState String
@@ -265,10 +265,10 @@ blockToLaTeX (Para [Image txt (src,tit)]) = do
265265 capt <- inlineListToLaTeX txt
266266 img <- inlineToLaTeX (Image txt (src,tit))
267267 return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
268− ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline
268+ ("\\caption{" <> capt <> char '}') $$ "\\end{figure}"
269269blockToLaTeX (Para lst) = do
270270 result <- inlineListToLaTeX lst
271− return $ result <> blankline
271+ return result
272272blockToLaTeX (BlockQuote lst) = do
273273 beamer <- writerBeamer `fmap` gets stOptions
274274 case lst of
@@ -280,8 +280,7 @@ blockToLaTeX (BlockQuote lst) = do
280280 return result
281281 _ -> do
282282 contents <- blockListToLaTeX lst
283− return $ "\\begin{quote}" $$ chomp contents $$ "\\end{quote}"
284− <> blankline
283+ return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
285284blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
286285 opts <- gets stOptions
287286 case () of
@@ -300,11 +299,7 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
300299 return "Verbatim"
301300 else return "verbatim"
302301 return $ flush (text ("\\begin{" ++ env ++ "}") $$ text str $$
303− text ("\\end{" ++ env ++ "}")) <> text "\n" <> blankline
304− -- note: we use 'text "\n"' instead of cr to make this
305− -- resistant to the 'chomp' in footnotes; a footnote
306− -- ending with a Verbatim environment must have a
307− -- cr before the closing }
302+ text ("\\end{" ++ env ++ "}")) <> cr
308303 listingsCodeBlock = do
309304 st <- get
310305 let params = if writerListings (stOptions st)
@@ -339,14 +334,14 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
339334 Nothing -> rawCodeBlock
340335 Just h -> modify (\st -> st{ stHighlighting = True }) >>
341336 return (flush $ text h)
342−blockToLaTeX (RawBlock "latex" x) = return $ text x <> blankline
337+blockToLaTeX (RawBlock "latex" x) = return $ text x
343338blockToLaTeX (RawBlock _ _) = return empty
344339blockToLaTeX (BulletList lst) = do
345340 incremental <- gets stIncremental
346341 let inc = if incremental then "[<+->]" else ""
347342 items <- mapM listItemToLaTeX lst
348− return $ text ("\\begin{itemize}" ++ inc) $$ chomp (vcat items) $$
349− "\\end{itemize}" <> blankline
343+ return $ text ("\\begin{itemize}" ++ inc) $$ vcat items $$
344+ "\\end{itemize}"
350345blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
351346 st <- get
352347 let inc = if stIncremental st then "[<+->]" else ""
@@ -367,15 +362,15 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
367362 "}{" ++ show (start - 1) ++ "}"
368363 else empty
369364 return $ text ("\\begin{enumerate}" ++ inc) <> exemplar $$ resetcounter $$
370− chomp (vcat items) $$ "\\end{enumerate}" <> blankline
365+ vcat items $$ "\\end{enumerate}"
371366blockToLaTeX (DefinitionList lst) = do
372367 incremental <- gets stIncremental
373368 let inc = if incremental then "[<+->]" else ""
374369 items <- mapM defListItemToLaTeX lst
375− return $ text ("\\begin{description}" ++ inc) $$ chomp (vcat items) $$
376− "\\end{description}" <> blankline
370+ return $ text ("\\begin{description}" ++ inc) $$ vcat items $$
371+ "\\end{description}"
377372blockToLaTeX HorizontalRule = return $
378− "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
373+ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}"
379374blockToLaTeX (Header level lst) = sectionHeader "" level lst
380375blockToLaTeX (Table caption aligns widths heads rows) = do
381376 modify $ \s -> s{ stInTable = True, stTableNotes = [] }
@@ -401,7 +396,7 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
401396 $$ braces (text "% rows" $$ "\\FL" $$
402397 vcat (headers : rows'') $$ "\\LL" <> cr)
403398 modify $ \s -> s{ stTable = True, stInTable = False, stTableNotes = [] }
404− return $ tableBody $$ blankline
399+ return $ tableBody
405400
406401toColDescriptor :: Alignment -> String
407402toColDescriptor align =
@@ -412,7 +407,7 @@ toColDescriptor align =
412407 AlignDefault -> "l"
413408
414409blockListToLaTeX :: [Block] -> State WriterState Doc
415−blockListToLaTeX lst = mapM blockToLaTeX lst >>= return . vcat
410+blockListToLaTeX lst = vsep `fmap` mapM blockToLaTeX lst
416411
417412tableRowToLaTeX :: Bool
418413 -> [Alignment]
@@ -430,7 +425,7 @@ tableRowToLaTeX header aligns widths cols = do
430425 let toCell 0 _ c = c
431426 toCell w a c = "\\parbox" <> valign <>
432427 braces (text (printf "%.2f\\columnwidth" w)) <>
433− braces (halign a <> cr <> chomp c <> cr)
428+ braces (halign a <> cr <> c <> cr)
434429 let cells = zipWith3 toCell widths aligns renderedCells
435430 return $ hcat $ intersperse (" & ") cells
436431
@@ -473,7 +468,6 @@ sectionHeader ref level lst = do
473468 <> braces (lab <> text "\\label"
474469 <> braces (text ref))
475470 else lab)
476− $$ blankline
477471 let headerWith x y = refLabel $ text x <> y
478472 return $ case level' of
479473 0 -> if writerBeamer opts
@@ -484,7 +478,7 @@ sectionHeader ref level lst = do
484478 3 -> headerWith "\\subsubsection" stuffing
485479 4 -> headerWith "\\paragraph" stuffing
486480 5 -> headerWith "\\subparagraph" stuffing
487− _ -> txt $$ blankline
481+ _ -> txt
488482
489483
490484-- | Convert list of inline elements to LaTeX.
@@ -600,7 +594,7 @@ inlineToLaTeX (Note contents) = do
600594 let marker = cycle ['a'..'z'] !! length curnotes
601595 modify $ \s -> s{ stTableNotes = (marker, contents') : curnotes }
602596 return $ "\\tmark" <> brackets (char marker) <> space
603− else return $ "\\footnote" <> braces (chomp $ nest 2 contents')
597+ else return $ "\\footnote" <> braces (nest 2 contents')
604598 -- note: a \n before } needed when note ends with a Verbatim environment
605599
606600citationsToNatbib :: [Citation] -> State WriterState Doc