low*_*rul 9 html latex r ms-word r-markdown
如何bbm
在 html/docx 输出的 R 降价中使用 LaTeX 包?
目前我正在使用下面的 hack 解决方案,基本上,我只是放弃使用bbm
.docx/.html 输出包。是否有一个 hack 解决方案,我仍然可以使用该软件包?
请注意,这个问题与我的问题有关在 R Markdown 文档中,“包含”用于 docx 输出?在那里我特别询问如何将这些特殊<!--- For DOCX Only --->
代码块移动preamble-word.tex
到要包含在 YAML 标头中的文件中。这个问题也与How to get \bm{} to work in a R markdown (to HTML) file? 我目前的 hack forbbm
基本上是对作为该问题的答案提出的其中一个hack的改编。
---
title: "TinyTeX Test"
header-includes:
- \usepackage{bbm}
output:
pdf_document: default
html_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<!--- For HTML Only --->
`r if (knitr:::is_html_output()) '
$\\newcommand{\\mathbbm}[1]{\\mathbf{#1}}$
'`
<!--- For DOCX Only --->
`r if (!knitr:::is_latex_output() & !knitr:::is_html_output()) '
\\newcommand{\\mathbbm}[1]{\\mathbf{#1}}
'`
Hello
\[\mathbbm{1}_{S}(x)\]
Run Code Online (Sandbox Code Playgroud)
您可以通过 Mathjax 以某种方式解决大多数重要符号/字符的问题。以下是受支持的符号/字符的列表:http://docs.mathjax.org/en/latest/input/tex/macros/index.html 只需在那里查找您需要的符号即可。
然后你像这样使用它:
$$
\require{mhchem}
\begin{equation}
[C] + [R]
\xrightleftharpoons[k_{-1}]{k_1}
[CR] + [C]
\xrightleftharpoons[k_{-2}]{k_2}
[C2R]
(\#eq:multiplebinding)
\end{equation}
$$
Run Code Online (Sandbox Code Playgroud)
因此,您需要将命令括在 $$ 中。在此示例中使用了 \xrightleftharpoons。从上面链接的表格中您可以看到在这种情况下您需要添加 \require{mhchem} 。对于您的情况,这不是必需的,您只需要编写 \mathbb 即可。
例子:
---
title: "TinyTeX Test"
header-includes:
- \usepackage{mathbbol}
output:
pdf_document: default
html_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Hello Mori, this should work
$$
\mathbb{1}_{S}(x)
$$
Greetings, Steffen
Run Code Online (Sandbox Code Playgroud)
另请注意,我用 \usepackage{mathbbol} 替换了 bbm - 否则为我渲染 pdf 时会出错。这里有关于 tex.stackexchange 上 bbm 的讨论...大多数人建议不要使用 bbm,因为有更好的包来获取符号https://tex.stackexchange.com/questions/26637/how-do-you-get- mathbb1 集合的工作特征函数
归档时间: |
|
查看次数: |
585 次 |
最近记录: |