Python sphinx 如何在StructuredText/Sphinx中创建浮动图形?
我想要一个有文字环绕的图形 这就是我要说的:Python sphinx 如何在StructuredText/Sphinx中创建浮动图形?,python-sphinx,restructuredtext,Python Sphinx,Restructuredtext,我想要一个有文字环绕的图形 这就是我要说的: Installation of Optional Accessories ==================================== .. warning:: Never plug in or unplug a Hand Robot or a Grasp Sensor while the robot is turned on, as the system will not function properly and damage to
Installation of Optional Accessories
====================================
.. warning:: Never plug in or unplug a Hand Robot or a Grasp Sensor while the robot is turned on, as the system will not function properly and damage to the robot could occur.
Installing a Hand Robot
-----------------------
.. _`fig-attach-hand-robot`:
.. figure:: attach-hand-robot.*
:scale: 40%
:align: right
Attach Hand Robot
Make sure the robot is turned off as described in the section :ref:`turn-off-robot`.
Take the hand robot out of the grounded bin that sits on top of the electrical panel (if you have an adjustable height table) or sits on top of the rear table (if you have a fixed height table). Make sure not to touch the pins on the electrical wiring while doing so. Insert the conical protrusion of the hand robot into the conical receptacle (see :ref:`fig-attach-hand-robot`). Once the hand robot is supported by the InMotion Arm Robot, make sure the two knobs below the Hand Robot have engaged and sprung in. If they have not, twist them until they do as shown (see :ref:`fig-knobs-in`).
及
- 为什么图形标题居中,而不是在图像下方
- 为什么正文文本(“确保…”和“拿着…”)不在图像的左边,而不是下面?我希望图形向右浮动,文本在左边
我希望悬赏能引起一些注意,但我怀疑他没有。为了处理图像,因为它们是你可能实际使用的文本的一部分 以下是从文档中摘录的有用信息:
The |biohazard| symbol must be used on containers used to
dispose of medical waste.
.. |biohazard| image:: biohazard.png
我希望这有帮助如果其他人遇到这个问题,那么这段代码可能会有所帮助。我决定我不想破解实际的sphinx代码,所以我制作了一个非常短的python脚本,应用于生成的
\u build/latex/pi3d\u book.tex
,以将\includegraphics
之前或之后包含\hfill
的转换为包装图像。有很多事情会阻止这项工作,例如将图像放入列表或缩放图像。我的rst中的斯芬克斯指令如下
.. image:: perspective.png
:align: right
显然,您必须更改文件名和路径以适应您的设置。从我的spinx项目中,我运行
$ make latexpdf
$ python wrapfix.py # or whatever you call this file
wrapfix.py的程序列表
import subprocess
with open("_build/latex/pi3d_book.tex", "r") as f:
tx = f.read().splitlines()
txnew = []
flg1 = True
for line in tx:
if line == "" and flg1:
txnew += ["\\usepackage{wrapfig}",""]
flg1 = False # just do this once before first blank line
elif "includegraphics{" in line and "hfill" in line:
fname = line.split("{")[2].split("}")[0]
if line.startswith("{\\hfill"): # i.e. right justify
fl_type = "R"
else:
fl_type = "L"
txnew += ["\\begin{wrapfigure}{" + fl_type + "}{0.35\\textwidth}",
"\\includegraphics[width = 0.3\\textwidth]{" + fname + "}",
"\\end{wrapfigure}"]
else:
txnew += [line]
txnew = "\n".join(txnew)
with open("_build/latex/pi3d_book.tex", "w") as fo:
fo.write(txnew)
subprocess.Popen(["pdflatex", "pi3d_book"], cwd="/home/jill/pi3d_book/_build/latex")
虽然为时已晚,但也许答案会帮助未来的人们
您可以使用边栏指令来放置图像
.. sidebar:: mandatory_title. Use can use image caption here
.. Figure:: 1.png
我发现数字浮动到指定了:figwidth:
和:align:
的一侧。(使用readthedocs主题。)
如果一个人需要在一章的开头放一个大的带照明的字母,这没有多大帮助。我试图在Sphinx+Latex pdf文件中包含一个图像,但出现了错误。请检查一下这个好吗?
.. figure:: images/myimage.jpg
:figwidth: 40%
:align: right