From 40fa01765bbd41145372e4e6f01f375353f683d0 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 1 Nov 2007 17:32:59 +0000 Subject: Cleaned up LaTeX footnotes: + Footnotes start on a separate line. A comment % is used at the end of the previous line to prevent unwanted spaces. This makes footnotes easier to see, delete, and move around. + The final } now only appears on a separate line if it needs to (i.e. if the note ends with a Verbatim environment). git-svn-id: https://pandoc.googlecode.com/svn/trunk@1061 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/LaTeX.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 03d6fc055..f64e06e24 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -31,7 +31,7 @@ module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Printf ( printf ) -import Data.List ( (\\), isInfixOf, intersperse ) +import Data.List ( (\\), isInfixOf, isSuffixOf, intersperse ) import Data.Char ( toLower ) import qualified Data.Set as S import Control.Monad.State @@ -303,7 +303,8 @@ inlineToLaTeX (Note contents) = do put (st {stInNote = True}) contents' <- blockListToLaTeX contents modify (\st -> st {stInNote = False}) - return $ text "\\footnote{" $$ - (nest 11 $ text (stripTrailingNewlines $ render contents') <> text "\n}") - -- note: the \n before } is important; removing it causes problems - -- if a Verbatim environment occurs at the end of the footnote. + let rawnote = stripTrailingNewlines $ render contents' + -- note: a \n before } is needed when note ends with a Verbatim environment + let optNewline = "\\end{Verbatim}" `isSuffixOf` rawnote + return $ text "%\n\\footnote{" <> + text rawnote <> (if optNewline then char '\n' else empty) <> char '}' -- cgit v1.2.3