git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Add keepaspectratio to includegraphics...

...if only one of height/width is given.

commit171187a4527497701b3c77bd56cea2d770d4e3b0 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 30 Nov 2017, 16:02 (9 years ago) parent7a8c830
2 files changed+7−2
src/Text/Pandoc/Writers/LaTeX.hs+6−1 test/command/3450.md+1−1
src/Text/Pandoc/Writers/LaTeX.hs+6−1
@@ -1125,7 +1125,12 @@ inlineToLaTeX (Image attr _ (source, _)) = do
11251125 [d <> text (show dim)]
11261126 Nothing ->
11271127 []
1128− dimList = showDim Width ++ showDim Height
1128+ -- if we just have a width or a height, we add keepaspectratio:
1129+ keepaspectratio = case (dimension Height attr, dimension Width attr) of
1130+ (Nothing, Just _) -> ["keepaspectratio"]
1131+ (Just _, Nothing) -> ["keepaspectratio"]
1132+ _ -> []
1133+ dimList = showDim Width ++ showDim Height ++ keepaspectratio
11291134 dims = if null dimList
11301135 then empty
11311136 else brackets $ cat (intersperse "," dimList)
test/command/3450.md+1−1
@@ -8,5 +8,5 @@
88% pandoc -fmarkdown-implicit_figures -t latex
99![image](lalune.jpg){height=2em}
1010^D
11−\includegraphics[height=2em]{lalune.jpg}
11+\includegraphics[height=2em,keepaspectratio]{lalune.jpg}
1212```