What is the best way to have a paragraph align in the center of the page using restructuredText for pdf (rst2pdf)?
Asked
Active
Viewed 1.3k times
10
-
2For sphinx users that come across this question: https://stackoverflow.com/q/33493589/2988730 – Mad Physicist Sep 21 '18 at 20:22
2 Answers
6
If you want to use center tag (as described above) on rst2html.py (Docutils 0.12), you should create a css file, namely mystyle.css by adding the following line to it:
.center {text-align: center;}
For converting your rst file, namely, myrst.rst to html file, use the following command
rst2html myrst.rst myrst.html --stylesheet=mystyle.css,html4css1.css
By using this method, the following code works well.
.. class:: center
This paragraph will be centered.

Ahmad Yoosofan
- 961
- 12
- 21
5
You can use the following:
.. class:: center
This paragraph will be centered.

iTech
- 18,192
- 4
- 57
- 80

Roberto Alsina
- 782
- 4
- 8
-
Good answer. Almost 100% applicable to sphinx as well: https://stackoverflow.com/q/33493589/2988730 – Mad Physicist Sep 21 '18 at 20:22