def latex_image_length(self, width_str, figure=False):
"""Convert `width_str` with rst length to LaTeX length.
This function is copied from docutils' latex writer
The last parameter, ``figure`` is only for compatibility with 1.4.4.
It will be removed at Sphinx-1.5.
"""
match = re.match('(\d*\.?\d*)\s*(\S*)', width_str)
if not match:
# fallback
return width_str
res = width_str
amount, unit = match.groups()[:2]
if figure and unit in ('', 'pt'):
res = '%sbp' % amount # convert to 'bp'
elif not unit or unit == "px":
# pixels: let LaTeX alone
return None
elif unit == "%":
res = "%.3f\\linewidth" % (float(amount) / 100.0)
return res
评论列表
文章目录