writer.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pymotw3 作者: reingart 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号