Skip to content

Commit 97a1eb5

Browse files
Peter JohnsonPeter Johnson
authored andcommitted
template update
1 parent 7963119 commit 97a1eb5

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/template.latex

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,23 @@ $endif$
125125
$if(graphics)$
126126
\usepackage{graphicx,grffile}
127127
\makeatletter
128-
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
129-
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
130-
\makeatother
131-
% Scale images if necessary, so that they will not overflow the page
132-
% margins by default, and it is still possible to overwrite the defaults
133-
% using explicit options in \includegraphics[width, height, ...]{}
134-
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
128+
129+
% Updating our template following changes to Pandoc
130+
% https://github.com/jgm/pandoc/pull/9666/files
131+
132+
\newsavebox\pandoc@box
133+
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
134+
\sbox\pandoc@box{#1}%
135+
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
136+
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
137+
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
138+
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
139+
\else\usebox{\pandoc@box}%
140+
\fi%
141+
}
142+
143+
% End update
144+
135145
$endif$
136146
$if(links-as-notes)$
137147
% Make links footnotes instead of hotlinks:

0 commit comments

Comments
 (0)