git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Add keepaspectratio to includegraphics...
171187aJohn MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+6−1
@@ -1125,7 +1125,12 @@ inlineToLaTeX (Image attr _ (source, _)) = do
1125 [d <> text (show dim)]
1125 [d <> text (show dim)]
1126 Nothing ->
1126 Nothing ->
1127 []
1127 []
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+ _ -> []
1128− dimList = showDim Width ++ showDim Height
1133+ dimList = showDim Width ++ showDim Height ++ keepaspectratio
1129 dims = if null dimList
1134 dims = if null dimList
1130 then empty
1135 then empty
1131 else brackets $ cat (intersperse "," dimList)
1136 else brackets $ cat (intersperse "," dimList)
test/command/3450.md+1−1
@@ -8,5 +8,5 @@
8% pandoc -fmarkdown-implicit_figures -t latex
8% pandoc -fmarkdown-implicit_figures -t latex
9![image](lalune.jpg){height=2em}
9![image](lalune.jpg){height=2em}
10^D
10^D
11−\includegraphics[height=2em]{lalune.jpg}
11+\includegraphics[height=2em,keepaspectratio]{lalune.jpg}
12```
12```