aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs7
-rw-r--r--test/command/3450.md2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 8620f989b..1972269ff 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1125,7 +1125,12 @@ inlineToLaTeX (Image attr _ (source, _)) = do
[d <> text (show dim)]
Nothing ->
[]
- dimList = showDim Width ++ showDim Height
+ -- if we just have a width or a height, we add keepaspectratio:
+ keepaspectratio = case (dimension Height attr, dimension Width attr) of
+ (Nothing, Just _) -> ["keepaspectratio"]
+ (Just _, Nothing) -> ["keepaspectratio"]
+ _ -> []
+ dimList = showDim Width ++ showDim Height ++ keepaspectratio
dims = if null dimList
then empty
else brackets $ cat (intersperse "," dimList)
diff --git a/test/command/3450.md b/test/command/3450.md
index 8759aa0c1..a8f713ed0 100644
--- a/test/command/3450.md
+++ b/test/command/3450.md
@@ -8,5 +8,5 @@
% pandoc -fmarkdown-implicit_figures -t latex
![image](lalune.jpg){height=2em}
^D
-\includegraphics[height=2em]{lalune.jpg}
+\includegraphics[height=2em,keepaspectratio]{lalune.jpg}
```