Home > OS >  How t o enter properly instructions to widen margins a page for RMarkdown pdf.doc
How t o enter properly instructions to widen margins a page for RMarkdown pdf.doc

Time:11-11

Since I'm facing with an incorrected reporting into pages in RMarkdown, as you could see here:

enter image description here

I was suggested to enter these commands around the line that is supposed to print the table.

<span style='font-size: 0.8em'>
```{r model, echo = FALSE, results = 'asis'}
iwalk(tables_models, ~ cat(knitr::knit_print(.x)))
```
</span>

Since I've tried to reproce that into my doc as follows

enter image description here

Producing red marks and the only way I found to make them set correctly is this:

enter image description here

that does not make the problem fixed, I would like to ask help to set these instructions properly. Thanks

CodePudding user response:

If you want to make a special margin in your file (knitting to pdf), then try this LaTeX-solution:

Add this package to the header:

header-includes: 
 \usepackage{geometry}

Make a special margin for some pages (you also can use mm, cm):

\newgeometry{top=1in,left=1in,bottom=1in,right=1in}

And after return to your previous style:

\restoregeometry  

An example to you:

---
title: "R"
header-includes:
- \usepackage{geometry}
output:
  pdf_document: default
---  

\newgeometry{top=1in,left=5in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry      

\newpage
\newgeometry{top=1in,left=0in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry  

\newpage
\newgeometry{top=5in,left=1in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry 
  • Related