latex - 狮身人面像到 latex 人物放置

标签 latex python-sphinx figure

我正在尝试使用 Sphinx 生成 Latex 和 HTML 格式的手册,但我在 Latex 中的图形放置方面遇到问题。在Sphinx中我的人物如下:

.. figure:: _images/somepicture.png
    :figwidth: 100 %
    :width: 100 %
    :align: center

    some caption

这样,当它写入 HTML 时,数字就会跨越页面的整个宽度。这工作得很好。

问题出现在 latex 中, latex 中的典型数字写为:

\begin{figure}[htbp]
\centering

\includegraphics[width=1.000\linewidth]{reset.png}
\end{figure}

问题在于 [htbp] 放置选项。由于图像的长度为\linewidth,因此它们非常大,最终会 float 到下一页,并且文档中文本和图形的顺序通常不会保留在 pdf 输出中。我想将 [htbp] 更改为 [H]。

我找到了一个选项,可以将其放入名为“figure_align”的 Latex elements 部分下的 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'

}

我的问题是,为什么此选项不起作用?我该怎么做才能使它起作用?

最佳答案

修改conf.py时,您可能忘记了“H”后面的逗号。

latex 图形( float )对齐

'figure_align': 'H',

适用于 sphinx-doc 版本 1.4.6。

'figure_align' Latex figure float alignment, default ‘htbp’ (here, top, bottom, page). Whenever an image doesn’t fit into the current page, it will be ‘floated’ into the next page but may be preceded by any other text. If you don’t like this behavior, use ‘H’ which will disable floating and position figures strictly in the order they appear in the source. Reference Sphinx-doc latex_element.

关于latex - 狮身人面像到 latex 人物放置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24285445/

相关文章:

python - 来自 matplotlib 的 pickle 数字

r - R Markdown中的图形大小

r - 并排对齐多个表格

python - Sphinx、gettext 和 html : how can I create multiline translations?

使用 python-Shinx 在重组文本中并排显示图像和目录

python - Sphinx 中 toctree 的显式标题

python - 如何在不重新运行脚本的情况下重置 matplotlib 动画

pdf - sphinx 使用latexpdf 在我的pdf 中添加分页符?

R markdown 函数分页符

python - Matplotlib 上的 Latex 未被识别为字符串