mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
latex writer considers unitless dimensions as px based
This commit is contained in:
parent
fe3f2a4a3f
commit
cd093fb0ca
2
CHANGES
2
CHANGES
@ -15,6 +15,8 @@ Incompatible changes
|
||||
sphinxVerbatimintable which handles captions and wraps lines(ref #2704).
|
||||
* latex, replace ``pt`` by TeX equivalent ``bp`` if found in ``width`` or
|
||||
``height`` attribute of an image.
|
||||
* latex, if ``width`` or ``height`` attribute of an image is given with no unit,
|
||||
use ``px`` rather than ignore it.
|
||||
|
||||
|
||||
Features added
|
||||
|
@ -283,12 +283,10 @@ def rstdim_to_latexdim(width_str):
|
||||
res = width_str
|
||||
amount, unit = match.groups()[:2]
|
||||
float(amount) # validate amount is float
|
||||
if not unit:
|
||||
return None
|
||||
if unit in ('', "px"):
|
||||
res = "%s\\sphinxpxdimen" % amount
|
||||
elif unit == 'pt':
|
||||
res = '%sbp' % amount # convert to 'bp'
|
||||
elif unit == "px":
|
||||
res = "%s\\sphinxpxdimen" % amount
|
||||
elif unit == "%":
|
||||
res = "%.3f\\linewidth" % (float(amount) / 100.0)
|
||||
return res
|
||||
|
@ -25,7 +25,7 @@ def test_rstdim_to_latexdim():
|
||||
assert rstdim_to_latexdim('160pt') == '160bp'
|
||||
assert rstdim_to_latexdim('160pc') == '160pc'
|
||||
assert rstdim_to_latexdim('30%') == '0.300\\linewidth'
|
||||
assert rstdim_to_latexdim('160') is None
|
||||
assert rstdim_to_latexdim('160') == '160\\sphinxpxdimen'
|
||||
|
||||
# flaot values
|
||||
assert rstdim_to_latexdim('160.0em') == '160.0em'
|
||||
|
Loading…
Reference in New Issue
Block a user