-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-blocks.Rmd
109 lines (75 loc) · 3.06 KB
/
05-blocks.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Blocks
## Equations
Here is an equation.
\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
(\#eq:binom)
\end{equation}
You may refer to using `\@ref(eq:binom)`, like see Equation \@ref(eq:binom).
## Theorems and proofs
Labeled theorems can be referenced in text using `\@ref(thm:tri)`, for example, check out this smart theorem \@ref(thm:tri).
::: {.theorem #tri}
For a right triangle, if $c$ denotes the *length* of the hypotenuse
and $a$ and $b$ denote the lengths of the **other** two sides, we have
\[a^2 + b^2 = c^2\]
:::
Read more here <https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html>.
Another example of a named theorem environment:
::: {.theorem name="Pythagorean theorem"}
For a right triangle, if $c$ denotes the length of the hypotenuse
and $a$ and $b$ denote the lengths of the other two sides, we have
$$a^2 + b^2 = c^2$$
:::
## Callout blocks
The `bs4_book` theme also includes special callout blocks, like this `.rmdnote`.
::: {.rmdnote}
You can use **markdown** inside a block.
```{r collapse=TRUE}
head(beaver1, n = 5)
```
:::
It is up to the user to define the appearance of these blocks for LaTeX output.
You may also use: `.rmdcaution`, `.rmdimportant`, `.rmdtip`, or `.rmdwarning` as the block name.
The R Markdown Cookbook provides more help on how to use custom blocks to design your own callouts: https://bookdown.org/yihui/rmarkdown-cookbook/custom-blocks.html
## Example minted blocks
\begin{minted}[fontsize=\small]{python}
# Example code
import numpy as np
import pandas as pd
print("This is an example string")
\end{minted}
## Example listings blocks
\begin{listing}[!htb]
\begin{minted}[]{python}
from ml_fingerprint import ml_fingerprint, example_models
from Crypto.PublicKey import RSA
from datetime import datetime
# Generamos el par de claves público-privadas
key = RSA.generate(2048)
private_key = key
public_key = key.publickey()
# Insertamos las funciones de firma y verificación en los modelos de Scikit-learn
ml_fingerprint.decorate_base_estimator()
# Obtenemos el modelo de nuestro módulo de modelos de ejemplo y lo firmamos
model, scores = example_models.rain_classifier()
model.sign(private_key)
# Subimos el modelo al servidor
rem.insert_model(model, "rain_australia", True, "classification", scores,\
"1.0.0", {}, datetime.now(), "Predictor de lluvia en Australia")
# Descargamos el modelo del servidor
server_model = rem.get_model("rain_australia", public_key)
\end{minted}
\caption{Código para el caso de ejemplo del modelo de clasifiación de lluvia en Australia.}
\label{lst:listing1}
\end{listing}
Este ejemplo es una referencia al listado de código \ref{lst:listing1}.
## Tables
Tables can be typeset using \LaTeX syntax directly or through the powerful
[Kable package](https://haozhu233.github.io/kableExtra/awesome_table_in_pdf.pdf),
available [from CRAN](https://cran.r-project.org/web/packages/kableExtra/index.html).
```{r}
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kbl(dt, caption = "This is a demo table.", booktabs = TRUE) %>%
kable_styling(latex_options = "striped")
```