我们使用Docutils
生成reST文档,然后通过rst2latex
生成TeX文件。
在rst
文件中,我们添加了许多LaTeX代码,如:
.. raw:: latex
~\
rule{textwidth}{1pt}
~\
但是我不知道在哪里添加像usepackage{tabulary}
这样的包。
如果我像上面所示的那样在rst
文件中添加它,即使在最开始,这个usepackage
行也会自动添加到tex输出文件中的begin{document}
之后。这显然会产生错误。
任何想法在哪里我可以在reST中添加usepackage
命令?
您可以使用LaTeX序言(在Docutils 0.7之后)
rst2latex foo.rst foo.tex --latex-preamble="usepackage{tabulary}"
将在foo.html
%%% Custom LaTeX preamble
usepackage{tabulary}
或者,可以通过
提供自定义样式表rst2latex foo.rst foo.tex --stylesheet=preamble.tex
将生成
%%% User specified packages and stylesheets
input{preamble.tex}