Skip to content

Commit

Permalink
vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 23, 2024
1 parent 6cc3869 commit 79cd3c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions vignettes/theme.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,26 @@ tt(tmp, width = .8, caption = cap) |>
```
:::

## User-written themes

### `theme_mitex()`

This theme was written by Kazuharu Yanagimoto. Thanks for your contribution!

The [MiTeX project](https://typst.app/universe/package/mitex/) aims to bring LaTeX support to Typst documents. This theme replace every instance of matching pairs of dollars signs `$..$` by a MiTeX function call: `#mitex(...)`. This allows you to use LaTeX math in Typst documents.

Warning: The substitution code is very simple and it may not work properly when there are unmatched `$` symbols in the document.

```r
theme_mitex <- function(x, ...) {
fn <- function(table) {
if (isTRUE(table@output == "typst")) {
table@table_string <- gsub("\\$(.*?)\\$", "#mitex(`\\1`)", table@table_string)
}
return(table)
}
x <- style_tt(x, finalize = fn)
x <- theme_tt(x, theme = "default")
return(x)
}
```

0 comments on commit 79cd3c5

Please sign in to comment.