Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Imports:
glue,
details,
gluedown,
katex,
purrr,
readr,
xml2,
Expand Down
25 changes: 25 additions & 0 deletions authortechnical.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,32 @@ Value 21 | Value 22 | Value 23
Value 31 | Value 32 | Value 33
{.table .table-responsive .table-striped}
```

### Math

If you want to use mathematical formulae,

* install the package [katex](https://docs.ropensci.org/katex/).
* add `math: true` to your post YAML.
* for all math you'll need to double the backslashes, meaning all "\\\" become "\\\\\".
* for inline math (`$1+1$`), don't use dollar signs, instead use `katex::katex_html()` like so:

``{{r}} katex::katex_html("1 + 1", displayMode = FALSE, include_css = TRUE)``


* for displayed math (usually starting and ending with `$$`), again do not use dollar signs and instead use the `katex::katex_html()` function:

```{r}
#| echo: fenced
Comment on lines +409 to +410
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```{r}
#| echo: fenced
```{{r}}

string <- "\\begin{aligned}
x_t & \\sim N(-0.5 y_{t-1} + x_{t-1} + z_{t-1}, 0.3^2)\\\\
y_t & \\sim N(0.7x_{t-1}, 0.3^2)\\\\
\\end{aligned}"
katex::katex_html(string, include_css = TRUE)
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```{r, echo=FALSE}
string <- "\\begin{aligned}
x_t & \\sim N(-0.5 y_{t-1} + x_{t-1} + z_{t-1}, 0.3^2)\\\\
y_t & \\sim N(0.7x_{t-1}, 0.3^2)\\\\
\\end{aligned}"
katex::katex_html(string, output = "mathml")
```

You need `include_css = TRUE` only once per post.

### Examples

Comparing the raw Markdown to the live posts in these examples might be helpful.
Expand Down
2 changes: 1 addition & 1 deletion index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ date: "`r Sys.Date()`"
documentclass: book
bibliography: [book.bib]
biblio-style: apalike
link-citations: yes
link-citations: true
github-repo: ropensci-org/blog-guidance
twitter: ropensci
url: 'https\://blogguide.ropensci.org/'
Expand Down