1

We used Docutils to produce reST document, and then make a TeX file via rst2latex.

In the rst file, we have added a lot of LaTeX code like:

.. raw:: latex

    ~\\
    \rule{\textwidth}{1pt}
    ~\\

But I do not know where to add packages like \usepackage{tabulary}.

If I add it in the rst file like I've shown above, even in the very beginning, this \usepackage line is automatically added after \begin{document} in the tex output file. This obviously generates an error.

Any idea where can I add \usepackage commands in reST?

Yuri Robbers
  • 291
  • 1
  • 10
Masood
  • 685
  • 2
  • 8
  • 16

1 Answers1

2

You can use the LaTeX preamble (after Docutils 0.7) by

rst2latex foo.rst foo.tex --latex-preamble="\usepackage{tabulary}"

which will generate the following in foo.html

%%% Custom LaTeX preamble
\usepackage{tabulary}

Alternatively, a custom stylesheet can be provided by

rst2latex foo.rst foo.tex --stylesheet=preamble.tex

which will generate

%%% User specified packages and stylesheets
\input{preamble.tex}

in the right place.

Gosh
  • 21
  • 4