@@ -161,14 +161,14 @@ blockToLaTeX (Plain lst) = inlineListToLaTeX lst
161161blockToLaTeX (Para [Image txt (src,tit)]) = do
162162 capt <- inlineListToLaTeX txt
163163 img <- inlineToLaTeX (Image txt (src,tit))
164− return $ text "\\begin{figure}[htb]" $$ text "\\centering" $$ img $$
165− (text "\\caption{" <> capt <> char '}') $$ text "\\end{figure}" $$ blankline
164+ return $ "\\begin{figure}[htb]" $$ "\\centering" $$ img $$
165+ ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline
166166blockToLaTeX (Para lst) = do
167167 result <- inlineListToLaTeX lst
168168 return $ result <> blankline
169169blockToLaTeX (BlockQuote lst) = do
170170 contents <- blockListToLaTeX lst
171− return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
171+ return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
172172blockToLaTeX (CodeBlock (_,classes,_) str) = do
173173 st <- get
174174 env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes &&
@@ -186,7 +186,7 @@ blockToLaTeX (CodeBlock (_,classes,_) str) = do
186186blockToLaTeX (RawHtml _) = return empty
187187blockToLaTeX (BulletList lst) = do
188188 items <- mapM listItemToLaTeX lst
189− return $ text "\\begin{itemize}" $$ vcat items $$ text "\\end{itemize}"
189+ return $ "\\begin{itemize}" $$ vcat items $$ "\\end{itemize}"
190190blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
191191 st <- get
192192 let oldlevel = stOLLevel st
@@ -205,12 +205,11 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
205205 map toLower (toRomanNumeral oldlevel) ++
206206 "}{" ++ show (start - 1) ++ "}"
207207 else empty
208− return $ text "\\begin{enumerate}" <> exemplar $$ resetcounter $$
209− vcat items $$ text "\\end{enumerate}"
208+ return $ "\\begin{enumerate}" <> exemplar $$ resetcounter $$
209+ vcat items $$ "\\end{enumerate}"
210210blockToLaTeX (DefinitionList lst) = do
211211 items <- mapM defListItemToLaTeX lst
212− return $ text "\\begin{description}" $$ vcat items $$
213− text "\\end{description}"
212+ return $ "\\begin{description}" $$ vcat items $$ "\\end{description}"
214213blockToLaTeX HorizontalRule = return $
215214 "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
216215blockToLaTeX (Header level lst) = do
@@ -241,18 +240,18 @@ blockToLaTeX (Header level lst) = do
241240blockToLaTeX (Table caption aligns widths heads rows) = do
242241 headers <- if all null heads
243242 then return empty
244− else liftM ($$ text "\\hline") $ tableRowToLaTeX heads
243+ else liftM ($$ "\\hline") $ tableRowToLaTeX heads
245244 captionText <- inlineListToLaTeX caption
246245 rows' <- mapM tableRowToLaTeX rows
247246 let colDescriptors = concat $ zipWith toColDescriptor widths aligns
248247 let tableBody = text ("\\begin{tabular}{" ++ colDescriptors ++ "}") $$
249− headers $$ vcat rows' $$ text "\\end{tabular}"
250− let centered txt = text "\\begin{center}" $$ txt $$ text "\\end{center}"
248+ headers $$ vcat rows' $$ "\\end{tabular}"
249+ let centered txt = "\\begin{center}" $$ txt $$ "\\end{center}"
251250 modify $ \s -> s{ stTable = True }
252251 return $ if isEmpty captionText
253252 then centered tableBody $$ blankline
254− else text "\\begin{table}[h]" $$ centered tableBody $$
255− inCmd "caption" captionText $$ text "\\end{table}" $$ blankline
253+ else "\\begin{table}[h]" $$ centered tableBody $$
254+ inCmd "caption" captionText $$ "\\end{table}" $$ blankline
256255
257256toColDescriptor :: Double -> Alignment -> String
258257toColDescriptor 0 align =
@@ -286,7 +285,7 @@ defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
286285defListItemToLaTeX (term, defs) = do
287286 term' <- inlineListToLaTeX $ deVerb term
288287 def' <- liftM vsep $ mapM blockListToLaTeX defs
289− return $ text "\\item[" <> term' <> text "]" $$ def'
288+ return $ "\\item" <> brackets term' $$ def'
290289
291290-- | Convert list of inline elements to LaTeX.
292291inlineListToLaTeX :: [Inline] -- ^ Inlines to convert
@@ -335,31 +334,31 @@ inlineToLaTeX (Code str) = do
335334inlineToLaTeX (Quoted SingleQuote lst) = do
336335 contents <- inlineListToLaTeX lst
337336 let s1 = if (not (null lst)) && (isQuoted (head lst))
338− then text "\\,"
339− else empty
337+ then "\\,"
338+ else empty
340339 let s2 = if (not (null lst)) && (isQuoted (last lst))
341− then text "\\,"
340+ then "\\,"
342341 else empty
343342 return $ char '`' <> s1 <> contents <> s2 <> char '\''
344343inlineToLaTeX (Quoted DoubleQuote lst) = do
345344 contents <- inlineListToLaTeX lst
346345 let s1 = if (not (null lst)) && (isQuoted (head lst))
347− then text "\\,"
348− else empty
346+ then "\\,"
347+ else empty
349348 let s2 = if (not (null lst)) && (isQuoted (last lst))
350− then text "\\,"
349+ then "\\,"
351350 else empty
352− return $ text "``" <> s1 <> contents <> s2 <> text "''"
351+ return $ "``" <> s1 <> contents <> s2 <> "''"
353352inlineToLaTeX Apostrophe = return $ char '\''
354−inlineToLaTeX EmDash = return $ text "---"
355−inlineToLaTeX EnDash = return $ text "--"
356−inlineToLaTeX Ellipses = return $ text "\\ldots{}"
353+inlineToLaTeX EmDash = return "---"
354+inlineToLaTeX EnDash = return "--"
355+inlineToLaTeX Ellipses = return "\\ldots{}"
357356inlineToLaTeX (Str str) = return $ text $ stringToLaTeX str
358357inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
359−inlineToLaTeX (Math DisplayMath str) = return $ text "\\[" <> text str <> text "\\]"
358+inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"
360359inlineToLaTeX (TeX str) = return $ text str
361360inlineToLaTeX (HtmlInline _) = return empty
362−inlineToLaTeX (LineBreak) = return $ text "\\\\"
361+inlineToLaTeX (LineBreak) = return "\\\\"
363362inlineToLaTeX Space = return space
364363inlineToLaTeX (Link txt (src, _)) =
365364 case txt of
@@ -367,17 +366,17 @@ inlineToLaTeX (Link txt (src, _)) =
367366 do modify $ \s -> s{ stUrl = True }
368367 return $ text $ "\\url{" ++ x ++ "}"
369368 _ -> do contents <- inlineListToLaTeX $ deVerb txt
370− return $ text ("\\href{" ++ src ++ "}{") <> contents <>
369+ return $ text ("\\href{" ++ src ++ "}{") <> contents <>
371370 char '}'
372371inlineToLaTeX (Image _ (source, _)) = do
373372 modify $ \s -> s{ stGraphics = True }
374− return $ text $ "\\includegraphics{" ++ source ++ "}"
373+ return $ "\\includegraphics" <> braces (text source)
375374inlineToLaTeX (Note contents) = do
376375 modify (\s -> s{stInNote = True})
377376 contents' <- blockListToLaTeX contents
378377 modify (\s -> s {stInNote = False})
379378 -- note: a \n before } is needed when note ends with a Verbatim environment
380− return $ text "\\footnote{" <> nest 2 contents' <> char '}'
379+ return $ "\\footnote" <> braces (nest 2 contents')
381380
382381
383382citationsToNatbib :: [Citation] -> State WriterState Doc