Archive for the ‘reStructuredTEXT’ tag
reStructuredTEXT输出为LaTeX以及公式的问题
中文的rst文件,输出为LaTeX文件:
在home目录下编辑.docutils文件,内容如下:
[latex2e writer]
documentclass: article
documentoptions: 12pt a4paper
output-encoding: utf-8
stylesheet: /home/username/docutils.tex
前几行没什么可说的,最后一行所指定文件的内容如下:
\usepackage[slantfont,boldfont,CJKaddspaces,CJKchecksingle]{xeCJK}
\CJKlanguage{zh-cn}
\setmainfont{Times New Roman}
\setCJKmainfont{Adobe Song Std}
\usepackage{CJKfntef}
我这是想用xelatex,如果是用CCT或者CTEX,语句相对少些。大家自己改吧。
公式的话,在文件头添加
.. role:: raw-math(raw)
:format: latex html
行内公式这样写:
If :raw-math:`$x=5 \times 3$` then :raw-math:`$x$` is
注意,冒号后面没空格!
独立公式这样写:
.. raw:: latex html
$$ W \approx \sum{f(x_k) \Delta x} $$
$$ W = \int_{a}^{b}{f(x) dx} $$
参考源:
- Docutils Configuration: http://docutils.sourceforge.net/docs/user/config.html
- reStructured Text tips and tricks: http://www.programmerq.net/rsttricks.html
- [tip] python-docutils: rst2latex create chinese pdf(繁体中文): http://kalug.linux.org.tw/~lloyd/bblog/archives/2009/11/09/%5Btip%5D_python-docutils:_rst2latex_create_chinese_pdf/
注:
如果是使用Sphinx,那么对于公式的支持就不用这么麻烦了,可以直接使用:math:和.. math::这样的命令,因为Sphinx支持rST扩展,用上面的方法,反而会出很多问题。
1 [latex2e writer]
2 documentclass: article
3 documentoptions: 12pt,a4paper
4 output-encoding: utf-8
5 stylesheet: /home/mzy/docutils.tex
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
– 可视 行 — 5,1 全部