最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to add MathJax macros in a Quarto Revealjs presentation? - Stack Overflow

programmeradmin5浏览0评论

I am trying to define a new operator in Quarto presentation (revealjs), but I either fail or it adds a white empty slide. Here are two examples:

Fails

This code fails in the sense that \N is not understood and litteraly written.

---
title: "Test title"
date: today
author: Test author
date-format: iso
keep-tex: true
format:
  revealjs: default
---

::: {.content-hidden}

\newcommand{\test}{f_{\text{test}}}
\renewcommand{\phi}{\varphi}

$$
\DeclareMathOperator{\N}{\mathcal{N}}
$$

:::

## First slide

$$
\test = \N(\phi)
$$

Works but add a white slide

This time \N is written because the math operator is declared in the html (see after qmd block code for the html output)

---
title: "Test title"
date: today
author: Test author
date-format: iso
keep-tex: true
format:
  revealjs: default
---

::: {.hidden}

\newcommand{\test}{f_{\text{test}}}
\renewcommand{\phi}{\varphi}

$$
\DeclareMathOperator{\N}{\mathcal{N}}
$$

:::

## First slide

$$
\test = \N(\phi)
$$

Opening the html output file, I found:

<section class="slide level2">

<div class="hidden">
<p><span class="math display">\[
\DeclareMathOperator{\N}{\mathcal{N}}
\]</span></p>
</div>
</section>

So, how to add latex macros in quarto revealjs? I also tried to hide the slide itself rather than the content, as shown in this post, but it did not work out.

I am trying to define a new operator in Quarto presentation (revealjs), but I either fail or it adds a white empty slide. Here are two examples:

Fails

This code fails in the sense that \N is not understood and litteraly written.

---
title: "Test title"
date: today
author: Test author
date-format: iso
keep-tex: true
format:
  revealjs: default
---

::: {.content-hidden}

\newcommand{\test}{f_{\text{test}}}
\renewcommand{\phi}{\varphi}

$$
\DeclareMathOperator{\N}{\mathcal{N}}
$$

:::

## First slide

$$
\test = \N(\phi)
$$

Works but add a white slide

This time \N is written because the math operator is declared in the html (see after qmd block code for the html output)

---
title: "Test title"
date: today
author: Test author
date-format: iso
keep-tex: true
format:
  revealjs: default
---

::: {.hidden}

\newcommand{\test}{f_{\text{test}}}
\renewcommand{\phi}{\varphi}

$$
\DeclareMathOperator{\N}{\mathcal{N}}
$$

:::

## First slide

$$
\test = \N(\phi)
$$

Opening the html output file, I found:

<section class="slide level2">

<div class="hidden">
<p><span class="math display">\[
\DeclareMathOperator{\N}{\mathcal{N}}
\]</span></p>
</div>
</section>

So, how to add latex macros in quarto revealjs? I also tried to hide the slide itself rather than the content, as shown in this post, but it did not work out.

Share Improve this question edited Mar 24 at 19:00 Jan 9,9156 gold badges20 silver badges33 bronze badges asked Mar 21 at 13:56 mistralmistral 1389 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This is because if you put anything before the first header, it will be regarded as content which has to be put on a slide. The solution is that you define things afterwards:

---
title: "Test title"
date: today
author: Test author
date-format: iso
keep-tex: true
format:
  revealjs: default
---

## First slide

::: {.hidden}

\newcommand{\test}{f_{\text{test}}}
\renewcommand{\phi}{\varphi}

$$
\DeclareMathOperator{\N}{\mathcal{N}}
$$

:::

$$
\test = \N(\phi)
$$
发布评论

评论列表(0)

  1. 暂无评论