Ale*_*lex 5 latex figure python-sphinx
我正在尝试使用Sphinx生成乳胶和HTML手册,但是乳胶中的图形放置存在问题。在狮身人面像中,我的数据如下:
.. figure:: _images/somepicture.png
:figwidth: 100 %
:width: 100 %
:align: center
some caption
Run Code Online (Sandbox Code Playgroud)
这样一来,当它写入HTML时,图形将覆盖页面的整个宽度。这很好。
麻烦来自乳胶,乳胶中的典型数字写为:
\begin{figure}[htbp]
\centering
\includegraphics[width=1.000\linewidth]{reset.png}
\end{figure}
Run Code Online (Sandbox Code Playgroud)
问题是[htbp]放置选项。由于图像的长度为\ linewidth,因此它们非常大,最终浮动到下一页,并且pdf输出中通常不会保留文档中文本和图形的任何顺序。我想将[htbp]更改为[H]。
我在“ figure_align”乳胶元素部分下找到了放入conf.py文件的选项,但是当我使用它时,它不起作用。链接在此处http://sphinx.readthedocs.org/en/latest/config.html#options-for-latex-output
在我的conf.py文档中,我具有以下内容:
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble':'',
#Figure placement within LaTeX paper NOT WORKING
'figure_align': 'H'
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么该选项不起作用,我应该怎么做才能使其起作用?
我发现这里添加了此功能的拉取请求:https://bitbucket.org/birkenfeld/sphinx/pull-request/227/latex-allow-alternative-float-options-for/diff
我查看了源代码,发现我的 sphinx 版本在 writers 文件中不包含乳胶元素“figure_align”。我添加了拉取请求中的代码,现在它可以工作了。
sphinx 的“构建配置文件”文档中所述的版本(可在此处找到)指出所有 Latex 元素选项在版本 0.5 或更高版本中可用,似乎某些元素仅在更高版本的 sphinx 中添加。我使用的是 1.2.2 版本,“figure_align”不是有效的乳胶元素。
简而言之,我本可以升级到最新版本的 sphinx,但是我只是添加了拉取请求中的代码,现在它按预期工作了。