mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
latex, allow image dimensions using px unit (96px=1in)
New key ``'pixelsize'`` in ``latex_elements`` dictionary.
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -46,6 +46,7 @@ Features added
|
||||
* latex, captions for literal blocks inside tables are handled, and long code
|
||||
lines wrapped to fit table cell (ref: #2704)
|
||||
* #2597: Show warning messages as darkred
|
||||
* latex, allow image dimensions using px unit (default is 96px=1in)
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
@@ -1601,6 +1601,14 @@ These options influence LaTeX output. See further :doc:`latex`.
|
||||
``'pointsize'``
|
||||
Point size option of the document class (``'10pt'``, ``'11pt'`` or
|
||||
``'12pt'``), default ``'10pt'``.
|
||||
``'pixelsize'``
|
||||
px unit size, default ``'49336sp'`` which achieves ``96px=1in`` (as
|
||||
``1in = 72.27*65536 = 4736286.72sp``, and all dimensions in TeX are
|
||||
internally integer multiples of ``sp``). To obtain for example
|
||||
``100px=1in``, one can use ``'0.01in'`` but it is more precise to issue
|
||||
``'pixelsize':'47363sp',``.
|
||||
|
||||
.. versionadded:: 1.5
|
||||
``'babel'``
|
||||
"babel" package inclusion, default ``'\\usepackage{babel}'``.
|
||||
``'fontpkg'``
|
||||
|
||||
@@ -35,6 +35,9 @@ HEADER = r'''%% Generated by Sphinx.
|
||||
\def\sphinxdocclass{%(docclass)s}
|
||||
\newif\ifsphinxKeepOldNames %(keepoldnames)s
|
||||
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(wrapperclass)s}
|
||||
\ifdefined\pdfpxdimen
|
||||
\let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
|
||||
\fi \sphinxpxdimen=%(pixelsize)s\relax
|
||||
\usepackage{iftex}
|
||||
%(passoptionstopackages)s
|
||||
%(inputenc)s
|
||||
@@ -299,6 +302,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
default_elements = {
|
||||
'papersize': 'letterpaper',
|
||||
'pointsize': '10pt',
|
||||
'pixelsize': '49336sp',
|
||||
'classoptions': '',
|
||||
'extraclassoptions': '',
|
||||
'passoptionstopackages': '',
|
||||
@@ -1380,9 +1384,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
return width_str
|
||||
res = width_str
|
||||
amount, unit = match.groups()[:2]
|
||||
if not unit or unit == "px":
|
||||
# pixels: let LaTeX alone
|
||||
if not unit:
|
||||
return None
|
||||
elif unit == "px":
|
||||
res = "%.3f\\sphinxpxdimen" % (float(amount))
|
||||
elif unit == "%":
|
||||
res = "%.3f\\linewidth" % (float(amount) / 100.0)
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user