默认情况下,Latex将段落完全对齐并在整个文字中执行连字符。我发现很难阅读冗长且充分有道理的文章。 我发现阅读左对齐的较短文本更加容易。
您如何实现以下目标?
答案 0 :(得分:0)
在花了几天时间研究Sphinx并通过测试和搜索进行自我发现之后,我设法找到了解决方案。我想在这里分享。
在conf.py
文件中,您可以为latex_elements
关键字添加以下条目:
latex_elements = {
'papersize': 'a4paper',
'pointsize': '12pt',
'preamble': r'''
\usepackage[none]{hyphenat}
\usepackage[document]{ragged2e}
'''
}
但是,这将使源代码行换行。为了在代码中使用较小的字体,您需要在conf.py
的顶部添加以下几行。
# -- To change font size for code alone
from sphinx.highlighting import PygmentsBridge
from pygments.formatters.latex import LatexFormatter
class CustomLatexFormatter(LatexFormatter):
def __init__(self, **options):
super(CustomLatexFormatter, self).__init__(**options)
# Available font size is found in
# https://en.wikibooks.org/wiki/LaTeX/Fonts#Built-in_sizes
self.verboptions = r"formatcom=\scriptsize"
PygmentsBridge.latex_formatter = CustomLatexFormatter