Skip to content

Commit

Permalink
Added rendering - explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fiskebeck authored and Fiskebeck committed Nov 21, 2024
1 parent c6e44b5 commit ee227e3
Show file tree
Hide file tree
Showing 6 changed files with 2,843 additions and 145 deletions.
167 changes: 73 additions & 94 deletions docs/Installation_for_rendering_formats.html

Large diffs are not rendered by default.

2,653 changes: 2,653 additions & 0 deletions docs/which_version.html

Large diffs are not rendered by default.

121 changes: 70 additions & 51 deletions workshops/202411_Rworkshop/Installation_for_rendering_formats.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,91 +28,110 @@ editor_options:
wrap: 72
---

<u>Warning:</u>. This is in development and has not been tested yet. Please if you have problems to use it, let us know.
# Easy fix from a fresh R installation (simple way)

# A note on installation : which version to use ?
You might need to modify some options in Rstudio.

An installer for windows has the **extension (file name ending with)** `.msi`.
Go to `Tools` -> `Global Options` -> `Sweave` panel,

- x86 means its a 32 bits windows computers (most older computers)
- x64 means its for a 64 bits windows computers (most recent laptops, and likely the version you should choose when you install software).
- x86_64 is meant for both 32 and 64 bits windows computers
![](./files/pdf_render_1.png)

Usually, software versions for 32 bits computer will work on 64 bits computers BUT software version for 32 bits computer will NOT work on 64 bits computers. In doubt, you may choose the 32 bits version.
Change *Sweave* to *knitr* in the "Weave Rnw files using" drop down menu. Then
change `pdf latex` to `Xelatex`

Once a software is installed, and can be run, the extension on windows is `.exe` (for executable).
![The options should look like that](files/Renderpdf_1.png)

# Installation of pandoc
Then **click apply** at the bottom of the window (you need to scroll, it can be
hidden). It will ask you to modify this also for the current project. Do it (it
is the same options). Then **click apply** at the bottom of the window and close
the window.

[Pandoc](https://pandoc.org/) is a universal document converter, ie: it allows to translate / save document from one type eg. Rmarkdown `.Rmd` to another eg. word document `.docx` or many other formats, eg. portable document `.pdf`. The list of the formats you can convert from and to is given on the pandoc website. If you use pandoc alone to convert between types, the conversion of the **formatting (how it looks like)** might not be exactly as you wish but it does certainly help to go faster in the process.

Pandoc, when used directly from Rstudio to render your Rmarkdown files (`.Rmd` file containing both codes and notes) as a word document (`.docx`) is a very powerful tool, because the integration of Rstudio and pandoc is very well done.
Then install the following package in R (type in the Rstudio console)
```{r, eval=FALSE}
install.packages(
tinytex::install_tinytex()
)
```

## Choice 1: installation of pandoc via a special R package

This is an adaptation of pandoc as an R package.
It is still under development and might not be as complete as the original pandoc
version that you can install as standalone.

The description and development website for this package (a github repository)
can be found [here](https://github.com/cderv/pandoc)
You are ready to test if this work. Create a new markdown document and knit it
as pdf


```{r}
install.packages("pandoc")
```

<!--
- [ ] check :
https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html
-->
# Testing or changing the rendering format for your files

## Choice 2: installation of the stand alone version of pandoc

- download the latest version of the installer for windows from the [pandoc website](https://pandoc.org/installing.html)
You can try to render a pdf (portable document format), .html (webpage) or .docx (word document) file from an Rmarkdown file (`.Rmd`) by clicking on the `knit` button.

The version you have to choose should look like : `pandoc-<version>-windows-x86_64.msi`
Which format your document is rendered is determined by the header of your R markdown document.

Then double click on this file to install it, and follow the default instructions for installation.
```{r, eval=FALSE}
output: pdf_document # for pdf document
output: html_document # for html document
output: word_document # for word document
```


# Configuration of Rstudio to produce pdf files

You might need to modify some options in Rstudio.
# Going further: installing Pandoc

Go to `Tools` -> `Global Options` -> `Sweave` panel,
- [ ] NOT tested yet ! Please tell me if you want to try this.

![](./files/pdf_render_1.png)

Change *Sweave* to *knitr* in the "Weave Rnw files using" drop down menu. Then **click apply** at the bottom of the window and close the window.
[Pandoc](https://pandoc.org/) is a universal document converter, ie: it allows
to translate / save document from one type eg. Rmarkdown `.Rmd` to another eg.
word document `.docx` or many other formats, eg. portable document `.pdf`. The
list of the formats you can convert from and to is given on the pandoc website.
If you use pandoc alone to convert between types, the conversion of the
**formatting (how it looks like)** might not be exactly as you wish but it does
certainly help to go faster in the process.

# Testing the render of your files

You can try to render a pdf (portable document format), .html (webpage) or .docx (word document) file from an Rmarkdown file (`.Rmd`) by clicking on the `knit` button.
Pandoc, when used directly from Rstudio to render your Rmarkdown files
(`.Rmd` file containing both codes and notes) as a word document (`.docx`) is a
very powerful tool, because the integration of Rstudio and pandoc is very well
done.

Which format your document is rendered is determined by the header of your R markdown document.
- [ ] Is this the R package or an adaptation ?
This is an adaptation of pandoc as an R package.
It is still under development and might not be as complete as the original pandoc
version that you can install as standalone.

The description and development website for this package (a github repository)
can be found [here](https://github.com/cderv/pandoc)

To install the pandoc package in R, type the following line in Rstudio console:
```{r, eval=FALSE}
output: pdf_document # for pdf document
output: html_document # for html document
output: word_document # for word document
install.packages("pandoc")
```


- [ ] ? Choice 2: installation of the stand alone version of pandoc
and check that the path to the pandoc executable is correct.

- download the latest version of the installer for windows from the [pandoc website](https://pandoc.org/installing.html)

<!--
The version you have to choose should look like :
`pandoc-<version>-windows-x86_64.msi`

# Installation of pdflatex
Then double click on this file to install it, and follow the default instructions
for installation.

pdflatex is a tool
police and fonts ?

(`.pdf`).
- [ ] ? Configuration of Rstudio to produce different file types files with pandoc

You might need to modify some options in Rstudio.

Installing pdflatex will allow you to render
your Rmarkdown file as a pdf document (`.pdf`).
Go to `Tools` -> `Global Options` -> `Sweave` panel,

![](./files/pdf_render_1.png)

Change *Sweave* to *knitr* in the "Weave Rnw files using" drop down menu. Then
**click apply** at the bottom of the window and close the window.


<!--
- [ ] check :
https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html
-->

-->
Binary file added workshops/202411_Rworkshop/files/Renderpdf_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions workshops/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Please click on the links to find go to the content.

# Software setup

[which version should I choose](which_version.html)

[Git setup](detailed_git_setup.html)

[WHONET setup](WHONET_usage.html)
Expand Down
45 changes: 45 additions & 0 deletions workshops/which_version.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "`r params$title`"
date: "`r format(Sys.time(), '%d %B, %Y')`"
author: Eve Zeyl Fiskebeck and Madelaine Norström
params:
title: "Installation : Which version should I choose"

knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding, output_dir = "../docs") })

output:

rmdformats::readthedown:
css: ../styles/style.css
self_contained: true
code_download: true
toc_depth: 4
df_print: paged
code_folding: show
author: params$author
highlight: espresso
number_sections: true



editor_options:
markdown:
wrap: 72
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# A note on installation : which version to use ?

An installer for windows has the **extension (file name ending with)** `.msi`.

- x86 means its a 32 bits windows computers (most older computers)
- x64 means its for a 64 bits windows computers (most recent laptops, and likely the version you should choose when you install software).
- x86_64 is meant for both 32 and 64 bits windows computers

Usually, software versions for 32 bits computer will work on 64 bits computers BUT software version for 32 bits computer will NOT work on 64 bits computers. In doubt, you may choose the 32 bits version.

Once a software is installed, and can be run, the extension on windows is `.exe` (for executable).

0 comments on commit ee227e3

Please sign in to comment.