aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-01 21:18:29 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-01 21:18:29 -0800
commit1193c1a505aac616d41a7b1c61c0cde07d2560d2 (patch)
tree3ef5b5d680432b35c9f6e28c49fea4651734e9a1
parent29ec13184ddb869038ca712e260e8a135992c8e9 (diff)
downloadpandoc-1193c1a505aac616d41a7b1c61c0cde07d2560d2.tar.gz
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.
-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 70744bde3..18138bf4c 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1124,7 +1124,12 @@ inlineToLaTeX (Image attr _ (source, _)) = do
Just dim ->
[d <> text (show dim)]
Nothing ->
- []
+ case dir of
+ Width | isJust (dimension Height attr) ->
+ [d <> "\\textwidth"]
+ Height | isJust (dimension Width attr) ->
+ [d <> "\\textheight"]
+ _ -> []
dimList = showDim Width ++ showDim Height
dims = if null dimList
then empty
diff --git a/test/command/3450.md b/test/command/3450.md
index 8759aa0c1..5b35e1d9e 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[width=\textwidth,height=2em]{lalune.jpg}
```