Created on Nov. 13, 2012, 6:03 p.m. by Hevok & updated on June 26, 2013, 10:38 a.m. by Hevok
A data entry can be rendered in various forms, like html and pdf.
¶
Specifically for pdf outputs rst2pdf is used.
¶
¶
This renders a data entry output as a legal size, serif document with code in murphy style::
¶
¶
$ rst2pdf article.rst -o article.pdf -s serif,murphy,legal
¶
¶
(perldoc looks better though)
¶
¶
In order to leverage the full set of UTF8 characters one should use a font that supports those encodings such as Dejavu::
¶
¶
$ rst2pdf article.rst -o article.pdf -s serif,dejavu,legal
¶
¶
Code syntax highlighting works via the code-block directive::
¶
¶
.. code-block:: python
¶
¶
import this
¶
# Test
¶
for something in here:
¶
print something, "more"
¶
¶
.. code-block:: python
¶
¶
import this
¶
# Test
¶
for something in here:
¶
print something, "more"
¶
¶
ReStructuredText can highlight itself::
¶
¶
.. code-block:: rest
¶
¶
reST Test
¶
=========
¶
¶
.. class:: test
¶
¶
.. code-block:: rest
¶
¶
reST Test
¶
=========
¶
¶
.. class:: test
¶
¶
¶
The linenos option can be used to display line numbers
¶
¶
.. code-block:: python
¶
:linenos:
¶
¶
def func(x,y):
¶
"""Adds up x and y."""
¶
print(x+y) # Do heavy calculation.
¶
¶
.. code-block:: python
¶
:linenos:
¶
¶
def func(x,y):
¶
"""Adds up x and y."""
¶
print(x+y) # Do heavy calculation.
¶
¶
Python in console
¶
¶
.. code-block:: pycon
¶
¶
>>> print("Console online")
¶
Console online
¶
¶
Python traceback
¶
¶
.. code-block:: pytb
¶
¶
¶
Code can also be included into a document::
¶
¶
.. code-block:: python
¶
:include: setup.py
¶
¶
:start-at: string
¶
Will start here
¶
¶
Page Counters
¶
-------------
¶
raw pdf can be used to control the page count::
¶
¶
.. raw:: pdf
¶
¶
SetPageCounter 1 lowerroman
¶
¶
SetPageCounter
¶
By default sets the counter to 0 and the style to arabic numerals
¶
¶
SetPageCounter number style
¶
Used to specifically start a page number with the specific style
¶
¶
Possible styles are:
¶
¶
* loweroman: i, ii, iii
¶
* roman: I, II, III
¶
* arabic: 1, 2, 3
¶
* loweralpha: a, b, c
¶
* alpha: A, B, C
¶
¶
romans start at 1. Arabic can start at 0, and alphas cannot go beyond 26 (of course).
¶
¶
Page Breaks
¶
-----------
¶
``PageBreak``, EvenPageBreak or OddPageBreak can be used to break a page. Each of these can take an additional arguments which os the name of next page template::
¶
¶
.. raw:: pdf
¶
¶
PageBreak oneColumn
¶
¶
``TwoColumn`` would create a two columned page in the following.
¶
¶
¶
Math
¶
----
¶
For formula and equation use the math directive::
¶
¶
.. math::
¶
¶
frac{2 pm sqrt{7}}{3}
¶
¶
.. math::
¶
¶
frac{2 pm sqrt{7}}{3}
¶
¶
For mathematical symbols use the math role or directive::
¶
¶
π
¶
¶
:math:`pi`
¶
Comment on This Data Unit