LaTeX writer: support page
,trim
,clip
attributes on images.
These are actually supported by `\includegraphics`, though this is not well documented. See https://tex.stackexchange.com/questions/7938/pdflatex-includegraphics-and-multi-page-pdf-files Partially addresses #7181.
This commit is contained in:
parent
7a7e1b2b70
commit
a9498a1568
2 changed files with 20 additions and 6 deletions
|
@ -930,7 +930,7 @@ inlineToLaTeX il@(Image _ _ (src, _))
|
|||
| Just _ <- T.stripPrefix "data:" src = do
|
||||
report $ InlineNotRendered il
|
||||
return empty
|
||||
inlineToLaTeX (Image attr _ (source, _)) = do
|
||||
inlineToLaTeX (Image attr@(_,_,kvs) _ (source, _)) = do
|
||||
setEmptyLine False
|
||||
modify $ \s -> s{ stGraphics = True }
|
||||
opts <- gets stOptions
|
||||
|
@ -953,10 +953,13 @@ inlineToLaTeX (Image attr _ (source, _)) = do
|
|||
Height | isJust (dimension Width attr) ->
|
||||
[d <> "\\textheight"]
|
||||
_ -> []
|
||||
dimList = showDim Width <> showDim Height
|
||||
dims = if null dimList
|
||||
then empty
|
||||
else brackets $ mconcat (intersperse "," dimList)
|
||||
optList = showDim Width <> showDim Height <>
|
||||
maybe [] (\x -> ["page=" <> literal x]) (lookup "page" kvs) <>
|
||||
maybe [] (\x -> ["trim=" <> literal x]) (lookup "trim" kvs) <>
|
||||
maybe [] (\_ -> ["clip"]) (lookup "clip" kvs)
|
||||
options = if null optList
|
||||
then empty
|
||||
else brackets $ mconcat (intersperse "," optList)
|
||||
source' = if isURI source
|
||||
then source
|
||||
else T.pack $ unEscapeString $ T.unpack source
|
||||
|
@ -964,7 +967,7 @@ inlineToLaTeX (Image attr _ (source, _)) = do
|
|||
inHeading <- gets stInHeading
|
||||
return $
|
||||
(if inHeading then "\\protect\\includegraphics" else "\\includegraphics") <>
|
||||
dims <> braces (literal source'')
|
||||
options <> braces (literal source'')
|
||||
inlineToLaTeX (Note contents) = do
|
||||
setEmptyLine False
|
||||
externalNotes <- gets stExternalNotes
|
||||
|
|
11
test/command/7181.md
Normal file
11
test/command/7181.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
```
|
||||
% pandoc -t latex
|
||||
![Global frog population.](slides.pdf){page=13,trim=1cm,clip,width=4cm}
|
||||
^D
|
||||
\begin{figure}
|
||||
\centering
|
||||
\includegraphics[page=13,trim=1cm,clip,width=4cm]{slides.pdf}
|
||||
\caption{Global frog population.}
|
||||
\end{figure}
|
||||
|
||||
```
|
Loading…
Reference in a new issue