-
Notifications
You must be signed in to change notification settings - Fork 7
/
rmarkdown.Rmd
61 lines (44 loc) · 1.14 KB
/
rmarkdown.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "Using texPreview in Rmarkdown HTML Documents"
author: "Jonathan Sidi"
date: "2023-12-09"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Using texPreview in Rmarkdown HTML Documents}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```r
library(texPreview)
tex_opts$set(
returnType = 'html',
opts.html = list(width = '75%', height = '75%')
)
```
The following examples use `kable` to generate LaTeX table outputs and raw LaTeX to pipe into `tex_preview` to render the in the document.
## Kable Input
```r
knitr::kable(head(iris,5),format = 'latex') |>
tex_preview()
```
![plot of chunk testOut](images/rmarkdown/testOut-1.png)
## TeX Input
```r
tab='
\\begin{tabular}{llr}
\\hline
\\multicolumn{2}{c}{Item} \\\\
\\cline{1-2}
Animal & Description & Price (\\$) \\\\
\\hline
Gnat & per gram & 13.65 \\\\
& each & 0.01 \\\\
Gnu & stuffed & 92.50 \\\\
Emu & stuffed & 33.33 \\\\
Armadillo & frozen & 8.99 \\\\
\\hline
\\end{tabular}'
tab |>
tex_preview()
```
![plot of chunk testOut2](images/rmarkdown/testOut2-1.png)