Knitr: how to set keepaspectratio in a figure

I have some numbers generated by R too high to fit on the page. I want to include these numbers, but reduce the shape to fit the height limit.

<<fig=TRUE,out.height='0.7\\textheight'>>=

Unfortunately, this fetters the chart vertically.

Verification of the received latex code shows that the problem is that it is width=\maxwidthinstalled automatically:

\begin{knitrout}\footnotesize
...
\includegraphics[width=\maxwidth,height=0.7\textheight]{figures/view_unnamed-chunk-10} 
\end{knitrout}

How can I save a specification width=\maxwidthin an expression \includegraphicswithout setting an argument out.widthto <<>>=explicitly? In this example fig.width==fig.height, so that I can further establish out.width='0.7\\textheight'(and adjust accordingly for any aspect ratio), but I would like to know a more general case.

keepaspectratio=TRUE <<>>= , .

+4
1

. , out.extra keepaspectratio.

:

<<out.height='0.7\\textheight',out.extra='keepaspectratio'>>=

LaTex :

\includegraphics[width=\maxwidth,height=0.7\textheight,keepaspectratio]{figure/unnamed-chunk-1-1} 
+3

Source: https://habr.com/ru/post/1531135/


All Articles