Stop Sphinx from Hyphenating

前端 未结 2 908
一向
一向 2021-01-21 01:52

I have a similar question to this, except for Sphinx and RST. Namely, I would like to prevent text from being hyphenated at the end of the line.

For example I want this:

相关标签:
2条回答
  • 2021-01-21 02:52

    Hyphenation is implemented by the stylesheet basic.css in the Sphinx theme "basic".

    div.body p, div.body dd, div.body li, div.body blockquote {
        -moz-hyphens: auto;
        -ms-hyphens: auto;
        -webkit-hyphens: auto;
        hyphens: auto;
    }
    

    You can override these styles with your own. See my answer to How do I customize Sphinx RtD Theme default search settings?

    Your theme may have JavaScript or other styles that implement hyphenation.

    For PDF output, see https://tex.stackexchange.com/a/5039

    0 讨论(0)
  • 2021-01-21 02:53

    After reading pointers from @steve-piercy, I managed to find a solution for the problem. I need to customize conf.py in my project. My conf.py has the following settings:

    # ...
    # ...
    
    # -- Options for LaTeX output ------------------------------------------------
    
    latex_elements = {
        # The paper size ('letterpaper' or 'a4paper').
        #
        'papersize': 'a4paper',
    
        # The font size ('10pt', '11pt' or '12pt').
        #
        'pointsize': '12pt',
    
        # Additional stuff for the LaTeX preamble.
        #
        'preamble': r'''
        \usepackage[none]{hyphenat}
        '''
    
        # Latex figure (float) alignment
        #
        # 'figure_align': 'htbp',
    
    }
    
    # ...
    # ...
    

    I am using Sphinx 1.8.2, MikTex 2.9 and Strawberry Perl 5.28.1. This new change in conf.py will download new perl package(s).

    0 讨论(0)
提交回复
热议问题