diff --git a/share/templates/latex/base.tex.j2 b/share/templates/latex/base.tex.j2 index 493130b07..3f814615f 100644 --- a/share/templates/latex/base.tex.j2 +++ b/share/templates/latex/base.tex.j2 @@ -164,7 +164,26 @@ override this.-=)) \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}} \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} - + \makeatletter + \newsavebox\pandoc@box + \newcommand*\pandocbounded[1]{% + \sbox\pandoc@box{#1}% + % scaling factors for width and height + \Gscale@div\@tempa\textheight{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}% + \Gscale@div\@tempb\linewidth{\wd\pandoc@box}% + % select the smaller of both + \ifdim\@tempb\p@<\@tempa\p@ + \let\@tempa\@tempb + \fi + % scaling accordingly (\@tempa < 1) + \ifdim\@tempa\p@<\p@ + \scalebox{\@tempa}{\usebox\pandoc@box}% + % scaling not needed, use as it is + \else + \usebox{\pandoc@box}% + \fi + } + \makeatother % Define a nice break command that doesn't care if a line doesn't already % exist.