在由rmarkdown
和knitr
包创建的报告中,我想创建一个1乘2的表,其中每个单元将承载一个LaTeX方程。在等式中,单个元素必须是自定义颜色的选项,产生类似:
使用hmarkdown应该识别的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>
编织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
Howerver,安装时:
package ‘inputenc’ is not available (for R version 3.1.0)
这两个方程都是从MathType 6.8复制粘贴的。左边的等式style="color:red"
是手动添加的。有没有办法在复制粘贴时保留颜色?