knitr with octave out.width does not restrict text out runs out of margin

38 Views Asked by At

The following is the minimal reproducing example, if you use debian system, one can install octave by snap or apt easily.

\documentclass[english]{article}
\title{Minimal example of octave with knitr for Rnw file}
\author{Xudong Sun}
\begin{document} 
\maketitle

<<engine='octave', engine.path='/snap/bin/octave', results='markup', echo=TRUE, out.width=5>>=
  x = -10:0.01:10
@
\end{document}

The output text runs out of margin:

image

Any solutions?

1

There are 1 best solutions below

0
manro On

You can simply add the white background ;)

F.e.:

\documentclass[english]{article}
\title{Minimal example of octave with knitr for Rnw file}
\author{Xudong Sun}
\begin{document} 
\maketitle

<<chunkName, echo=FALSE, comment=NA, background='#FFFFFF'>>=
x <- rnorm(100)
x
@
\end{document}

enter image description here

... but if you want to save "default dimensions of the bg area" you can use f.e:

<<chunkName, echo=FALSE, comment=NA, background='#FFFF33'>>=
options(width = 60)
x <- rnorm(100)
x
@

enter image description here