Sphinx Latex Output Without Justification And Hyphenation

10:48 Tuesday, 24 March 2015

If you’d like to turn off justification and hyphenation in the Latex produced by Sphinx, add the following code to the latex_elements map in your conf.py file.

latex_elements = {
    ...
    'preamble': '''\usepackage[document]{ragged2e}   
    \usepackage[none]{hyphenat}''',
    ...
}

This assumes you have the ragged2e (part of the ms suite) and hyphenat packages installed.

I found the above info on the TeX StackExchange site here and here.

While you’re editing your conf.py file, do your eyes a favour and increase the font size of the produced Latex with the pointsize setting also in the latex_elements map.

'pointsize': '12pt',

If you’d like to read more about Latex’s formatting options I suggest the paragraph and text sections of the Latex book.

I use the Python Markdown package with the Pygments CodeHilite extension to author this blog. I’ve converted the Pygments “tango” style from CSS to Stylus available as a gist.

FYI: To extract CSS styles from Pygments use a command like the below.

$ pygmentize -f html -S tango > tango.css

Tags