mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#38: fix behavior with unitless image dimensions.
This commit is contained in:
parent
22cefe2114
commit
49858b41f3
2
CHANGES
2
CHANGES
@ -159,6 +159,8 @@ New features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* Fix "illegal unit" error when using pixel image widths/heights.
|
||||||
|
|
||||||
* Support table captions in LaTeX output.
|
* Support table captions in LaTeX output.
|
||||||
|
|
||||||
* Work around a bug in Jinja that caused "<generator ...>" to be
|
* Work around a bug in Jinja that caused "<generator ...>" to be
|
||||||
|
@ -217,6 +217,11 @@ to the source file, and Sphinx will automatically copy image files over to a
|
|||||||
subdirectory of the output directory on building (e.g. the ``_static`` directory
|
subdirectory of the output directory on building (e.g. the ``_static`` directory
|
||||||
for HTML output.)
|
for HTML output.)
|
||||||
|
|
||||||
|
Interpretation of image size options (``width`` and ``height``) is as follows:
|
||||||
|
if the size has no unit or the unit is pixels, the given size will only be
|
||||||
|
respected for output channels that support pixels (i.e. not in LaTeX output).
|
||||||
|
Other units (like ``pt`` for points) will be used for HTML and LaTeX output.
|
||||||
|
|
||||||
Sphinx extends the standard docutils behavior by allowing an asterisk for the
|
Sphinx extends the standard docutils behavior by allowing an asterisk for the
|
||||||
extension::
|
extension::
|
||||||
|
|
||||||
|
@ -716,9 +716,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
return width_str
|
return width_str
|
||||||
res = width_str
|
res = width_str
|
||||||
amount, unit = match.groups()[:2]
|
amount, unit = match.groups()[:2]
|
||||||
if unit == "px":
|
if not unit or unit == "px":
|
||||||
# LaTeX does not know pixels but points
|
# pixels: let LaTeX alone
|
||||||
res = "%spt" % amount
|
return None
|
||||||
elif unit == "%":
|
elif unit == "%":
|
||||||
res = "%.3f\\linewidth" % (float(amount) / 100.0)
|
res = "%.3f\\linewidth" % (float(amount) / 100.0)
|
||||||
return res
|
return res
|
||||||
@ -735,11 +735,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,))
|
pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,))
|
||||||
post.append('}')
|
post.append('}')
|
||||||
if attrs.has_key('width'):
|
if attrs.has_key('width'):
|
||||||
include_graphics_options.append('width=%s' % (
|
w = self.latex_image_length(attrs['width'])
|
||||||
self.latex_image_length(attrs['width']), ))
|
if w:
|
||||||
|
include_graphics_options.append('width=%s' % w)
|
||||||
if attrs.has_key('height'):
|
if attrs.has_key('height'):
|
||||||
include_graphics_options.append('height=%s' % (
|
h = self.latex_image_length(attrs['height'])
|
||||||
self.latex_image_length(attrs['height']), ))
|
include_graphics_options.append('height=%s' % h)
|
||||||
if attrs.has_key('align'):
|
if attrs.has_key('align'):
|
||||||
align_prepost = {
|
align_prepost = {
|
||||||
# By default latex aligns the top of an image.
|
# By default latex aligns the top of an image.
|
||||||
|
Loading…
Reference in New Issue
Block a user