summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/default.latex3
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs8
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Types.hs2
3 files changed, 11 insertions, 2 deletions
diff --git a/data/templates/default.latex b/data/templates/default.latex
index e3b54ec4a..7b02262a3 100644
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -270,6 +270,9 @@ $if(graphics)$
\def\fps@figure{htbp}
\makeatother
$endif$
+$if(svg)$
+\usepackage{svg}
+$endif$
$if(strikeout)$
$-- also used for underline
\usepackage[normalem]{ulem}
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index cd1f59056..31dff78bf 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -165,6 +165,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do
defField "numbersections" (writerNumberSections options) $
defField "lhs" (stLHS st) $
defField "graphics" (stGraphics st) $
+ defField "svg" (stSVG st) $
defField "has-chapters" (stHasChapters st) $
defField "has-frontmatter" (documentClass `elem` frontmatterClasses) $
defField "listings" (writerListings options || stLHS st) $
@@ -934,7 +935,9 @@ inlineToLaTeX il@(Image _ _ (src, _))
return empty
inlineToLaTeX (Image attr@(_,_,kvs) _ (source, _)) = do
setEmptyLine False
- modify $ \s -> s{ stGraphics = True }
+ let isSVG = ".svg" `T.isSuffixOf` source || ".SVG" `T.isSuffixOf` source
+ modify $ \s -> s{ stGraphics = True
+ , stSVG = stSVG s || isSVG }
opts <- gets stOptions
let showDim dir = let d = text (show dir) <> "="
in case dimension dir attr of
@@ -968,7 +971,8 @@ inlineToLaTeX (Image attr@(_,_,kvs) _ (source, _)) = do
source'' <- stringToLaTeX URLString source'
inHeading <- gets stInHeading
return $
- (if inHeading then "\\protect\\includegraphics" else "\\includegraphics") <>
+ (if inHeading then "\\protect" else "") <>
+ (if isSVG then "\\includesvg" else "\\includegraphics") <>
options <> braces (literal source'')
inlineToLaTeX (Note contents) = do
setEmptyLine False
diff --git a/src/Text/Pandoc/Writers/LaTeX/Types.hs b/src/Text/Pandoc/Writers/LaTeX/Types.hs
index c06b7e923..ff5b22cad 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Types.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Types.hs
@@ -35,6 +35,7 @@ data WriterState =
, stStrikeout :: Bool -- ^ true if document has strikeout
, stUrl :: Bool -- ^ true if document has visible URL link
, stGraphics :: Bool -- ^ true if document contains images
+ , stSVG :: Bool -- ^ true if document contains SVGs
, stLHS :: Bool -- ^ true if document has literate haskell code
, stHasChapters :: Bool -- ^ true if document has chapters
, stCsquotes :: Bool -- ^ true if document uses csquotes
@@ -66,6 +67,7 @@ startingState options =
, stStrikeout = False
, stUrl = False
, stGraphics = False
+ , stSVG = False
, stLHS = False
, stHasChapters = case writerTopLevelDivision options of
TopLevelPart -> True