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.
This commit is contained in:
John MacFarlane 2017-12-01 21:18:29 -08:00
parent 29ec13184d
commit 1193c1a505
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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}
```