diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/Tests/Writers/LaTeX.hs | 2 | ||||
| -rw-r--r-- | test/command/3450.md | 2 | ||||
| -rw-r--r-- | test/command/5476.md | 2 | ||||
| -rw-r--r-- | test/command/7181.md | 2 | ||||
| -rw-r--r-- | test/command/9045.md | 2 | ||||
| -rw-r--r-- | test/writer.latex | 23 |
6 files changed, 18 insertions, 15 deletions
diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs index f17dfdcce..c4a456dce 100644 --- a/test/Tests/Writers/LaTeX.hs +++ b/test/Tests/Writers/LaTeX.hs @@ -70,7 +70,7 @@ tests = [ testGroup "code blocks" "\\begin{description}\n\\item[foo] ~ \n\\subsection{bar}\n\nbaz\n\\end{description}" , "containing image" =: header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?> - "\\section{\\texorpdfstring{\\protect\\includegraphics{imgs/foo.jpg}}{Alt text}}" + "\\section{\\texorpdfstring{\\protect\\pandocbounded{\\includegraphics[keepaspectratio]{imgs/foo.jpg}}}{Alt text}}" ] , testGroup "inline code" [ "struck out and highlighted" =: diff --git a/test/command/3450.md b/test/command/3450.md index d12b0d9c1..e83ce21f7 100644 --- a/test/command/3450.md +++ b/test/command/3450.md @@ -8,5 +8,5 @@ % pandoc -fmarkdown-implicit_figures -t latex {height=2em} ^D -\includegraphics[width=\linewidth,height=2em]{lalune.jpg} +\includegraphics[width=\linewidth,height=2em,keepaspectratio]{lalune.jpg} ``` diff --git a/test/command/5476.md b/test/command/5476.md index 6e744f5ec..bc8b88549 100644 --- a/test/command/5476.md +++ b/test/command/5476.md @@ -4,7 +4,7 @@ ^D \begin{figure} \centering -\includegraphics{test/lalune.jpg} +\pandocbounded{\includegraphics[keepaspectratio]{test/lalune.jpg}} \caption[moon]{moon\footnotemark{}} \end{figure} \footnotetext{the moon} diff --git a/test/command/7181.md b/test/command/7181.md index e2cf7a731..e449e057e 100644 --- a/test/command/7181.md +++ b/test/command/7181.md @@ -4,7 +4,7 @@ ^D \begin{figure} \centering -\includegraphics[page=13,trim=1cm,clip,width=4cm]{slides.pdf} +\pandocbounded{\includegraphics[keepaspectratio,page=13,trim=1cm,clip,width=4cm]{slides.pdf}} \caption{Global frog population.} \end{figure} diff --git a/test/command/9045.md b/test/command/9045.md index 3556fc9a1..387ba75b5 100644 --- a/test/command/9045.md +++ b/test/command/9045.md @@ -4,7 +4,7 @@ ^D \begin{figure} \centering -\includegraphics{there.jpg} +\pandocbounded{\includegraphics[keepaspectratio]{there.jpg}} \caption{hi}\label{foo} \end{figure} ``` diff --git a/test/writer.latex b/test/writer.latex index 5027b85cc..1cb69633f 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -39,15 +39,17 @@ \usepackage{xcolor} \usepackage{graphicx} \makeatletter -\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} -\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} -\makeatother -% Scale images if necessary, so that they will not overflow the page -% margins by default, and it is still possible to overwrite the defaults -% using explicit options in \includegraphics[width, height, ...]{} -\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} +\newsavebox\pandoc@box +\newcommand*\pandocbounded[1]{% scales image to fit in text height/width + \sbox\pandoc@box{#1}% + \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}% + \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}% + \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both + \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}% + \else\usebox{\pandoc@box}% + \fi% +} % Set default figure placement to htbp -\makeatletter \def\fps@figure{htbp} \makeatother \ifLuaTeX @@ -922,11 +924,12 @@ From ``Voyage dans la Lune'' by Georges Melies (1902): \begin{figure} \centering -\includegraphics{lalune.jpg} +\pandocbounded{\includegraphics[keepaspectratio]{lalune.jpg}} \caption{lalune} \end{figure} -Here is a movie \includegraphics{movie.jpg} icon. +Here is a movie \pandocbounded{\includegraphics[keepaspectratio]{movie.jpg}} +icon. \begin{center}\rule{0.5\linewidth}{0.5pt}\end{center} |
