Chapter 10: test

10.1 RStudio

10.1.2 writer options

https://rstudio.github.io/visual-markdown-editing/markdown.html#writer-options

10.1.2.2 ensuring the same markdown between source / visual mode

https://stackoverflow.com/questions/71775027/rstudio-switch-markdown-editing-mode-between-source-and-visual-changes-special

canonical mode

https://rstudio.github.io/visual-markdown-editing/markdown.html#canonical-mode

---
title: "My Document"
editor_options:
  markdown:
    wrap: 72
    references: 
      location: block
    canonical: true
---

10.1.4 addins

https://github.com/rstudio/addinexamples

if (!requireNamespace("devtools", quietly = TRUE))
  install.packages("devtools")
  
devtools::install_github("rstudio/htmltools")
devtools::install_github("rstudio/shiny")
devtools::install_github("rstudio/miniUI")

10.2 RMarkdown

https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf

https://slides.yihui.org/2020-taipei-satrday-rmarkdown.html#1

10.2.3 URL

https://stackoverflow.com/questions/29787850/how-do-i-add-a-url-to-r-markdown

[I'm an inline-style link](https://www.google.com)

[I'm an inline-style link with title](https://www.google.com "Google's Homepage")

[I'm a reference-style link][Arbitrary case-insensitive reference text]

[I'm a relative reference to a repository file](../blob/master/LICENSE)

[You can use numbers for reference-style link definitions][1]

Or leave it empty and use the [link text itself]

Some text to show that the reference links can follow later.

[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com

10.2.4 arrow

https://reimbar.org/dev/arrows/

Up arrow: ↑

Down arrow: ↓

Left arrow: ←

Right arrow: →

Double headed arrow: ↔

10.2.5 superscript and subscript

scriptsuperscriptsubscript

script^superscript^

scriptsuperscript

~subscript~

scriptsubscript

10.2.5.3 aligned

\[ \begin{aligned} c^{2} = & a^{2}+b^{2} \\ = & b^{2}+a^{2} \quad +\text{commutavie} \\ = & b^{2}+a^{2} \qquad +\text{commutavie} \\ = & b^{2}+a^{2} \qquad \Box \end{aligned} \]

\[ \begin{aligned} c^{2} = & a^{2}+b^{2} \\ = & b^{2}+a^{2} & +\text{commutavie} \\ = & a^{2}+b^{2} & +\text{commutavie} \\ = & b^{2}+a^{2} & \Box \end{aligned} \]

\[ \begin{aligned} c^{2} = & a^{2}+b^{2} & & & c^{2} = & a^{2}+b^{2} \\ = & b^{2}+a^{2} & +\text{commutavie} & +\text{commutavie} & = & b^{2}+a^{2} & +\text{commutavie} \\ = & a^{2}+b^{2} & +\text{commutavie} & +\text{commutavie} & = & a^{2}+b^{2} & +\text{commutavie} \\ = & b^{2}+a^{2} & \Box & +\text{commutavie} & = & b^{2}+a^{2} & \Box \end{aligned} \]

10.2.5.4 proof QED

https://math.meta.stackexchange.com/questions/3582/qed-for-mathjax-here-on-stackexchange

\tag*{$\Box$}

\[ a^2+b^2=c^2 \tag*{$\Box$} \]

\tag*{$\blacksquare$}

\[ a^2+b^2=c^2 \tag*{$\blacksquare$} \]

10.2.6 image

https://stackoverflow.com/questions/25166624/insert-picture-table-in-r-markdown

10.2.6.1 DiagrammeR / mermaid flowchart

Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML.
If your aiming to have some HTML widgets shown in non-HTML format as a screenshot,
please install webshot or webshot2 R package for knitr to do the screenshot.
Alternatively, you can allow HTML output in non-HTML formats
by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.

https://bookdown.org/yihui/rmarkdown-cookbook/diagrams.html#diagrams

https://stackoverflow.com/questions/40803017/how-to-include-diagrammer-mermaid-flowchart-in-a-rmarkdown-file

{r}
library(DiagrammeR)
mermaid("
graph LR
    A-->B
",
width = 100
)

https://github.com/rich-iannone/DiagrammeR/issues/364

https://stackoverflow.com/questions/55994210/how-to-solve-diagrammer-waste-of-space-issue-in-rmarkdown

10.2.6.2 multiple images / figures in the same line

https://cosname.github.io/rmarkdown-guide/rmarkdown-base.html#element-figure

{r, fig.show = "hold", out.width = "50%"}
plot(cars)
plot(nhtemp)
plot(cars)
plot(nhtemp)

cf.

{r}
plot(cars)
plot(nhtemp)
plot(cars)

plot(nhtemp)

10.2.6.3 figure size

https://sebastiansauer.github.io/figure_sizing_knitr/

YAML in index.Rmd

--- 
title: "My Document" 
output: html_document: 
fig_width: 6 
fig_height: 4 
--- 

first R-chunk in your RMD document

knitr::opts_chunk$set(fig.width=12, fig.height=8) 

width, height and options

```{r fig.height = 3, fig.width = 5

plot(pressure)

```

{r fig.height = 3, fig.width = 5

plot(pressure)

{r fig.height = 3, fig.width = 3, fig.align = "center"

plot(pressure)

{r fig.width = 5, fig.asp = .62

plot(pressure)

<center>
![](https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png){width=20%}
</center>
10.2.6.3.1 knitr

https://yihui.org/knitr/options/

https://bookdown.org/yihui/rmarkdown/tufte-figures.html

par(mar = c(4, 4, .1, .2)); plot(sunspots)

plot(cars)

We know from _the first fundamental theorem of calculus_ that
for $x$ in $[a, b]$:
$$\frac{d}{dx}\left( \int_{a}^{x} f(u)\,du\right)=f(x).$$
10.2.6.3.2 out.width vs. fig.width

https://stackoverflow.com/questions/29657777/how-to-make-fig-width-and-out-width-consistent-with-knitr

when chunk option cache=FALSE is set, then out.width has no effect because no PDF output is created. Hence one has to specify exact measures in inches for fig.width and fig.height for each chunk

https://stackoverflow.com/questions/59567235/a-ggmap-too-small-when-rendered-within-a-rmd-file

plot(pressure)

problem: out.width='100%' causing LaTeX Error: Not in outer par mode.

solution: out.width=if (knitr:::is_html_output()) '100%'

\begin{tikzpicture}
  \draw (-1,1)--(0,0)--(1,2);
\end{tikzpicture}

 

fig.width=10, fig.height=2

\begin{tikzpicture}
  \draw (-1,1)--(0,0)--(1,2);
\end{tikzpicture}

 

out.width=if (knitr:::is_html_output()) '100%'

\begin{tikzpicture}
  \draw (-1,1)--(0,0)--(1,2);
\end{tikzpicture}

 

10.2.6.4 dynamic knitr plot width and height

https://stackoverflow.com/questions/15365829/dynamic-height-and-width-for-knitr-plots

plot(pressure)

10.2.6.5 web image in PDF

https://stackoverflow.com/questions/46331896/how-can-i-insert-an-image-from-internet-to-the-pdf-file-produced-by-r-bookdown-i

cover_url = 'https://bookdown.org/yihui/bookdown/images/cover.jpg'
if (!file.exists(cover_file <- xfun::url_filename(cover_url)))
  xfun::download_file(cover_url)
knitr::include_graphics(if (knitr::pandoc_to('html')) cover_url else cover_file)
conic sections
conic sections
conic sections

Fig. 10.1: conic sections

conic sections

Fig. 10.2: conic sections

10.2.7 horizontal rule

***

horizontal rule (or slide break)


dim(iris) 
## [1] 150   5

10.2.8 footnote

10.2.11 xaringan

slide realtime preview with RStudio addin Infinite Moon Reader in RStudio viewer

https://github.com/yihui/xaringan

https://www.youtube.com/watch?v=3n9nASHg9gc

10.2.12 embed HTML or web page

10.2.12.1 iframe

10.2.12.2 include URL

https://bookdown.org/yihui/rmarkdown-cookbook/include-url.html

knitr::include_url("https://yihui.org")

10.2.12.3 htmltools

https://stackoverflow.com/questions/36524238/include-html-files-in-r-markdown-file

Three.js

however out.height etc. not works

Three.js

10.3 Bookdown

10.3.1 system locale

https://bookdown.org/tpemartin/ntpu-programming-for-data-science/appendix-d-.html

Sys.getlocale()

Windows

Sys.setlocale(category = "LC_ALL", locale = "UTF-8")

MacOS

Sys.setlocale(category = "LC_ALL", locale = "en_US.UTF-8")

https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html

10.3.2 render_book()

https://bookdown.org/yihui/bookdown/build-the-book.html

render_book(input = ".", output_format = NULL, ..., clean = TRUE,
  envir = parent.frame(), clean_envir = !interactive(),
  output_dir = NULL, new_session = NA, preview = FALSE,
  config_file = "_bookdown.yml")

10.3.3 serve_book()

https://bookdown.org/yihui/bookdown/serve-the-book.html

serve_book(dir = ".", output_dir = "_book", preview = TRUE,
  in_session = TRUE, quiet = FALSE, ...)

10.3.4 LaTeX

10.3.4.2 ugly mathptmx \(\sum\)

PDF LaTeX \usepackage{fdsymbol} to have \overrightharpoon vector; however, there are too many side effects, including ugly mathptmx \(\sum\), …


\usepackage{fdsymbol} % vector over accent, but will use mathptmx
% replace the rather ugly mathptmx \sum operator with the equivalent Computer Modern one
\let\sum\relax
\DeclareSymbolFont{CMlargesymbols}{OMX}{cmex}{m}{n}
\DeclareMathSymbol{\sum}{\mathop}{CMlargesymbols}{"50}

https://tex.stackexchange.com/questions/315102/different-sum-signs

https://tex.stackexchange.com/questions/275038/how-to-replace-mathptmx-sum-with-cm-sum

https://tex.stackexchange.com/questions/391410/calligraphic-symbols-are-too-fancy-with-mathptmx-package

https://blog.csdn.net/kongtaoxing/article/details/131005044

In preamble.tex, add


% replace the rather ugly mathptmx \sum operator with the equivalent Computer Modern one
\let\sum\relax
\DeclareSymbolFont{CMlargesymbols}{OMX}{cmex}{m}{n}
\DeclareMathSymbol{\sum}{\mathop}{CMlargesymbols}{"50}

\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
\DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n}

10.3.4.3 LaTeX package in HTML document

https://github.com/rstudio/rmarkdown/issues/1829

---
title: "assignment"
author: "author"
output: html_document
---

$$
  \require{cancel}
  \cancel{x}
$$

\[ \require{cancel} \cancel{x} \]

https://stackoverflow.com/questions/18189175/how-to-use-textup-with-mathjax

\textup is not available in MathJax. You can replace it with \mathrm, but \mathrm does not interpret spaces.

10.3.6 multi-column layout / two columns

https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html

10.3.6.1 for both HTML and PDF

figure size[10.2.6.3]

Below is a Div containing three child Divs side by side. The Div in the middle is empty, just to add more space between the left and right Divs.

:::::: {.cols data-latex=""}

::: {.col data-latex="{0.55\textwidth}"}
<img src="202401280001-test_files/figure-html/unnamed-chunk-35-1.png" width="480" />
:::

::: {.col data-latex="{0.05\textwidth}"}
\ 
<!-- an empty Div (with a white space), serving as
a column separator -->
:::

::: {.col data-latex="{0.4\textwidth}"}
The figure on the left-hand side shows the `cars` data.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur.
:::
::::::

{r, echo=FALSE, fig.width=5, fig.height=4}

 

The figure on the left-hand side shows the cars data.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

{r, echo=FALSE, fig.width=10, fig.height=8, out.width = "100%"}

 

The figure on the left-hand side shows the cars data.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

{r, echo=FALSE, fig.width=10, fig.height=8}

 

The figure on the left-hand side shows the cars data.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

10.3.6.2 multi-column fig.cap must use fig.pos="H"

https://community.rstudio.com/t/adding-fig-cap-caption-text-to-code-chunk-causes-figure-to-print-at-top-of-page-instead-of-where-it-should-be/30297

https://bookdown.org/yihui/rmarkdown-cookbook/figure-placement.html

to avoid LaTeX Error: Not in outer par mode for caption in multi-column LaTeX PDF

in output.yml add extra_dependencies: ["float"] under bookdown::pdf_book:

include first chunk knitr::opts_chunk$set(fig.pos = "H", out.extra = "") in .Rmd

add out.width=if (knitr:::is_html_output()) '50%' for TikZ chunk

thus complete chunk beginning with {r, echo=FALSE, cache=TRUE, engine='tikz', fig.ext=if (knitr:::is_latex_output()) 'pdf' else 'png', fig.width=10, fig.height=2, out.width=if (knitr:::is_html_output()) '100%', fig.cap=''}

\begin{tikzpicture}
  \draw (-1,1)--(0,0)--(1,2);
\end{tikzpicture}

 

LaTeX package caption

https://tex.stackexchange.com/questions/128485/how-to-make-a-caption-via-captionof-and-extra-margins-adhere-to-minipage-marg

What is the different between using \captionof{table}{ABC} and \caption{ABC}?

https://tex.stackexchange.com/questions/514286/what-is-the-different-between-using-captionoftableabc-and-captionabc

side-by-side table

https://stackoverflow.com/questions/73745714/how-to-print-gt-tbl-tables-side-by-side-with-knitr-kable

R ternary operator

https://stackoverflow.com/questions/8790143/does-the-ternary-operator-exist-in-r

10.3.6.4 for only HTML

10.3.6.4.1 CSS flex

Here is the first Div.

str(iris)
## 'data.frame':    150 obs. of  5 variables:
##  $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
##  $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
##  $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
##  $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
##  $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

And this block will be put on the right:

plot(iris[, -5])

10.3.6.4.2 CSS grid

https://github.com/yihui/knitr/issues/1743

head(iris)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa
plot(iris)

10.4 conditional block/chunk for either HTML or PDF, and Chinese issue

等價關係 equivalence relation

等價關係 equivalence relation

等價關係 equivalence relation

等價關係 equivalence relation

等價關係 equivalence relation

\[ a+b \]

\[\begin{align*} & R\text{ is an equivalence relation over }A\times B\\ \Leftrightarrow & \begin{cases} R=\sim=\left\{ \left\langle x,y\right\rangle \middle|x\sim y\right\} \subseteq A\times B & \left(\text{e}\right)\text{equivalence 等價}\\ \vdots & \vdots \end{cases}\\ \Leftrightarrow & \begin{cases} R=\left\{ \left\langle x,y\right\rangle \middle|xRy\right\} \subseteq A\times B & \left(R\right)\text{relation}\\ \forall\left\langle x,y\right\rangle \in R\left(xRx\right) & \left(r\right)\text{reflexive}\\ \forall\left\langle x,y\right\rangle \in R\left(xRy\Rightarrow yRx\right) & \left(s\right)\text{symmetric}\\ \forall\left\langle x,y\right\rangle ,\left\langle y,z\right\rangle \in R\left(\begin{cases} xRy\\ yRz \end{cases}\Rightarrow xRz\right) & \left(t\right)\text{transitive} \end{cases}\Leftrightarrow\begin{cases} R=\left\{ \left\langle x,y\right\rangle \middle|xRy\right\} \subseteq A\times B & \text{關係}\\ \forall\left\langle x,y\right\rangle \in R\left(\left\langle x,x\right\rangle \in R\right) & \text{自反}\\ \forall\left\langle x,y\right\rangle \in R\left(\left\langle y,x\right\rangle \in R\right) & \text{對稱}\\ \forall\left\langle x,y\right\rangle ,\left\langle y,z\right\rangle \in R\left(\left\langle x,z\right\rangle \in R\right) & \text{遞移} \end{cases} \end{align*}\]

https://stackoverflow.com/questions/76240244/bookdown-conditional-display-of-text-and-code-blocks-latex-pdf-vs-html

\[\begin{align*} & R\text{ is an equivalence relation over }A\times B\\ \Leftrightarrow & \begin{cases} R=\sim=\left\{ \left\langle x,y\right\rangle \middle|x\sim y\right\} \subseteq A\times B & \left(\text{e}\right)\text{equivalence 等價}\\ \vdots & \vdots \end{cases}\\ \Leftrightarrow & \begin{cases} R=\left\{ \left\langle x,y\right\rangle \middle|xRy\right\} \subseteq A\times B & \left(R\right)\text{relation}\\ \forall\left\langle x,y\right\rangle \in R\left(xRx\right) & \left(r\right)\text{reflexive}\\ \forall\left\langle x,y\right\rangle \in R\left(xRy\Rightarrow yRx\right) & \left(s\right)\text{symmetric}\\ \forall\left\langle x,y\right\rangle ,\left\langle y,z\right\rangle \in R\left(\begin{cases} xRy\\ yRz \end{cases}\Rightarrow xRz\right) & \left(t\right)\text{transitive} \end{cases}\Leftrightarrow\begin{cases} R=\left\{ \left\langle x,y\right\rangle \middle|xRy\right\} \subseteq A\times B & \text{關係}\\ \forall\left\langle x,y\right\rangle \in R\left(\left\langle x,x\right\rangle \in R\right) & \text{自反}\\ \forall\left\langle x,y\right\rangle \in R\left(\left\langle y,x\right\rangle \in R\right) & \text{對稱}\\ \forall\left\langle x,y\right\rangle ,\left\langle y,z\right\rangle \in R\left(\left\langle x,z\right\rangle \in R\right) & \text{遞移} \end{cases} \end{align*}\]

10.5 video embedding

https://stackoverflow.com/questions/42543206/r-markdown-compile-error

always_allow_html: true

install.packages("webshot")
webshot::install_phantomjs()

however webshot not work

https://cran.r-project.org/web/packages/vembedr/vignettes/embed.html

## Warning: package 'vembedr' was built under R version 4.2.3

Error: cannot find bilibili.com

https://cran.r-project.org/web/packages/vembedr/vignettes/embed.html

## embed_youtube("0LFg5dvPOoc")

10.6 equation term coloring

LaTeX annotation by TikZ[65]

10.6.1 font color

RegEx replacement in RStudio for {\\color{(\w+)} in LyX to be replaced with \\color{$1}{ in HTML document, and remain the same for PDF document

In HTML document, if no {} for text range, only the first following term will take effect

\color{orange}x=y

\[\color{orange}x=y\] \color{orange} and \color{cyan} are better color for HTML GitBook White and Night themes and PDF

\color{cyan}{x=y}

\[\color{orange}{x=y}\]

\color{cyan}{x=y}

\[\color{cyan}{x=y}\]

::: {show-in="html"}

$$
\dfrac{\colorbox{#FFD1DC}{$\epsilon^{2}\left(y_{{\scriptscriptstyle F}}-y_{{\scriptscriptstyle L}}\right)^{2}$}}{1-\epsilon^{2}}
$$

:::

::: {show-in="pdf"}

$$
\dfrac{\colorbox{red!50}{\text{\ensuremath{\epsilon^{2}\left(y_{{\scriptscriptstyle F}}-y_{{\scriptscriptstyle L}}\right)^{2}}}}}{1-\epsilon^{2}}
$$

:::

10.8 number and reference equations

https://stackoverflow.com/questions/71595882/rstudio-error-in-windows-running-pdflatex-exe-on-file-name-tex-exit-code-10

https://bookdown.org/yihui/rmarkdown/bookdown-markdown.html#equations

\#eq:emc \@ref(eq:emc)

https://stackoverflow.com/questions/55923290/consistent-math-equation-numbering-in-bookdown-across-pdf-docx-html-output

\[\begin{equation} \begin{aligned} & C\text{ is an equivalence class of }a\text{ on }A\\ \Leftrightarrow & \left[a\right]_{\sim}=C=\left\{ x\middle|\begin{cases} a\in A\\ x\in A\\ x\sim a\\ \sim\text{ is an equivalence relation over }A\times A=A^{2} \end{cases}\right\} \subseteq A\ne\emptyset\\ \Leftrightarrow & \left[a\right]=\left[a\right]_{\sim}=\left\{ x\middle|\begin{cases} a\in A\\ x\in A\\ x\sim a\\ \sim\text{ is an equivalence relation on }A \end{cases}\right\} \subseteq A\ne\emptyset\\ \Rightarrow & \left[a\right]_{\sim}=\left\{ x\middle|x\sim a\right\} \subseteq A\ne\emptyset \end{aligned} \tag{10.2} \end{equation}\]

https://bookdown.org/yihui/rmarkdown/bookdown-markdown.html#cross-referencing

This cross reference is the Fig. 10.5

https://stackoverflow.com/questions/51595939/bookdown-cross-reference-figure-in-another-file

I ran into the same issue and came up with this solution if you aim at compiling 2 different pdfs. It relies on LaTeX’s xr package for cross references: https://stackoverflow.com/a/52532269/576684

10.9 footnote

noun^[This is a footnote]

noun[^202401260000-test-cross-link-1]

[^202401260000-test-cross-link-1]: This is a footnote.

noun8

10.10 citation

https://stackoverflow.com/questions/48965247/use-csl-file-for-pdf-output-in-bookdown/49145699#49145699

citation 13 citation 23

citation 34 citation 44

10.10.1 citation in fig.cap

https://tex.stackexchange.com/questions/591882/citation-within-a-latex-figure-caption-in-rmarkdown

(ref:rudolph) *nice* cite: [@Lam94].

(ref:campbell1963) *nice* cite: [@campbell1963].

(ref:campbell1963) ([@campbell1963]

(ref:campbell1963) \ [@campbell1963]

pre- and true experimental designs ( 5 p.8)

Fig. 10.4: pre- and true experimental designs ( 5 p.8)

10.11 environment for definition, theorem, proof

https://bookdown.org/yihui/rmarkdown/bookdown-markdown.html

https://github.com/rstudio/rstudio/issues/5264

@howthebodyworks Ideally, previews of such equations should also work inside a theorem, although I could survive without that.

https://github.com/rstudio/rstudio/issues/8773

Theorem 10.1 (Theorem Name) Here is my theorem.

Proof (Proof Name). Here is my proof.

Theorem 10.2 (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 + \color{cyan}b^2 \overset{\ref{eq:emc}}= \color{red}{c^2} \]

Definition 10.1 (Definition Name) Here is my definition.

number and reference equations

(10.2)

(10.1)

10.2

parabola arc with points

Fig. 10.5: parabola arc with points

10.11.1 collapsible panel or HTML component

https://stackoverflow.com/questions/52576626/rmarkdown-collapsible-panel

Theorem 10.3 This is the description of a theorem

\[ c^2=a^2+b^2 \]

Proof:

\[ c^2=a^2+b^2 \]

\[ \tag*{$\Box$} \]

10.11.1.1 nested collapsible panel or HTML component

Hidden theorem

Theorem 10.4 This is the description of a theorem

\[ c^2=a^2+b^2 \]

Proof:

\[ c^2=a^2+b^2 \]

\[ \tag*{$\Box$} \]

10.12 slide or presentation

10.12.2 ioslides

https://www.youtube.com/watch?v=gkyjTcpCITM

https://bookdown.org/yihui/rmarkdown/ioslides-presentation.html

https://stackoverflow.com/questions/63749683/how-to-set-up-theorem-environment-in-the-rmarkdown-presentation

---
title: "Theorem demo"
output:
  ioslides_presentation:
    css: style.css
---

/* theorem environment _ plain */

/*
.theorem {
  display: block;
  font-style: italic;
  font-size: 24px;
  font-family: "Times New Roman";
  color: black;
}
.theorem::before {
  content: "Theorem. ";
  font-weight: bold;
  font-style: normal;
}
.theorem[text]::before {
  content: "Theorem (" attr(text) ") ";
}
.theorem p {
  display: inline;
}
*/

/* theorem environment _ Copenhagen style */

/*
.theorem {
  display: block;
  font-style: italic;
  font-size: 24px;
  font-family: "Times New Roman";
  color: black;
  border-radius: 10px;
  background-color: rgb(222,222,231);
  box-shadow: 5px 10px 8px #888888;
}
.theorem::before {
  content: "Theorem. ";
  font-weight: bold;
  font-style: normal;
  display: inline-block;
  width: -webkit-fill-available;
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 10px 5px 5px 15px;
  background-color: rgb(38, 38, 134);
}
.theorem p {
  padding: 15px 15px 15px 15px;
}
*/

references

3.
4.
ccjou. 二次型與正定矩陣. (2009).
5.
Campbell, D. T. & Stanley, J. Experimental and Quasi-Experimental Designs for Research. (Cengage Learning, Belomt, CA, 1963).