and*_*rey 5 latex r mathml knitr r-markdown
在由rmarkdown和knitr包创建的报告中,我想创建一个 1 x 2 的表格,其中的每个单元格都将托管一个 LaTeX 方程。在等式中,单个元素必须选择自定义颜色,生成如下内容:

使用 rmarkdown 应该识别的 html 元素:
---
output:
pdf_document: default
html_document:
mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
---
### Two formulas side by side
<div style="width:900px">
<div style="width:450px">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub style="color:red">
<mi>y</mi>
<mrow>
<mi>t</mi><mi>i</mi></mrow>
</msub>
<mo>=</mo><msub>
<mi>β</mi>
<mn>0</mn>
</msub>
<mo>+</mo><msub style="color:red">
<mi>ε</mi>
<mrow>
<mi>t</mi><mi>i</mi></mrow>
</msub>
</mrow>
</annotation>
</semantics>
</math>
</div>
<div style="width:450px">
$$
{y_{ti}} = {\beta _0} + {\beta _1}Tim{e_t} + {\varepsilon _{ti}}
$$
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
编织 html 时,左边的方程出错:

编织 PDF 时,右侧的公式会出错:
! Package inputenc Error: Unicode char \u8:? not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.59 y ti = ?
Try running pandoc with --latex-engine=xelatex.
pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
Run Code Online (Sandbox Code Playgroud)
但是,在安装时:
package ‘inputenc’ is not available (for R version 3.1.0)
Run Code Online (Sandbox Code Playgroud)
这两个方程都是从 MathType 6.8 复制粘贴的。在左边的方程style="color:red"是手动添加的。有没有办法在复制粘贴时保留颜色?

| 归档时间: |
|
| 查看次数: |
1410 次 |
| 最近记录: |