LaTeX writer: allow specifying just width or height for image size.
Previously both needed to be specified (unless the image was
being resized to be smaller than its original size).
If height but not width is specified, we now set width to
textwidth (and similarly if width but not height is specified).
Since we have keepaspectratio, this yields the desired result.
commit1193c1a505aac616d41a7b1c61c0cde07d2560d2
authorJohn MacFarlane <jgm@berkeley.edu>
dateFri 1 Dec 2017, 21:18 (9 years ago)
parent29ec131
src/Text/Pandoc/Writers/LaTeX.hs+6−1
@@ -1124,7 +1124,12 @@ inlineToLaTeX (Image attr _ (source, _)) = do
11241124 Just dim ->
11251125 [d <> text (show dim)]
11261126 Nothing ->
1127− []
1127+ case dir of
1128+ Width | isJust (dimension Height attr) ->
1129+ [d <> "\\textwidth"]
1130+ Height | isJust (dimension Width attr) ->
1131+ [d <> "\\textheight"]
1132+ _ -> []
11281133 dimList = showDim Width ++ showDim Height
11291134 dims = if null dimList
11301135 then empty
test/command/3450.md+1−1
@@ -8,5 +8,5 @@
88% pandoc -fmarkdown-implicit_figures -t latex
99{height=2em}
1010^D
11−\includegraphics[height=2em]{lalune.jpg}
11+\includegraphics[width=\textwidth,height=2em]{lalune.jpg}
1212```