diff options
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 11 | ||||
-rw-r--r-- | tests/writer.latex | 26 |
2 files changed, 19 insertions, 18 deletions
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 '}' diff --git a/tests/writer.latex b/tests/writer.latex index 883217c86..0e7f7c165 100644 --- a/tests/writer.latex +++ b/tests/writer.latex @@ -792,11 +792,12 @@ Here is a movie \includegraphics{movie.jpg} icon. \section{Footnotes} Here is a footnote -reference,\footnote{ Here is the footnote. It can go anywhere after the footnote -reference. It need not be placed at the end of the document. -} +reference,% +\footnote{Here is the footnote. It can go anywhere after the footnote +reference. It need not be placed at the end of the document.} and -another.\footnote{ Here's the long note. This one contains multiple blocks. +another.% +\footnote{Here's the long note. This one contains multiple blocks. Subsequent blocks are indented to show that they belong to the footnote (as with list items). @@ -805,24 +806,23 @@ footnote (as with list items). { <code> } \end{Verbatim} If you want, you can indent every line, but you can also be lazy -and just indent the first line of each block. -} +and just indent the first line of each block.} This should \emph{not} be a footnote reference, because it contains a space.[\^{}my note] Here is an inline -note.\footnote{ This is \emph{easier} to type. Inline notes may contain +note.% +\footnote{This is \emph{easier} to type. Inline notes may contain \href{http://google.com}{links} and \verb!]! verbatim characters, -as well as [bracketed text]. -} +as well as [bracketed text].} \begin{quote} -Notes can go in quotes.\footnote{ In quote. -} +Notes can go in quotes.% +\footnote{In quote.} \end{quote} \begin{enumerate}[1.] \item - And in list items.\footnote{ In list. -} + And in list items.% +\footnote{In list.} \end{enumerate} This paragraph should not be part of the note, as it is not indented. |