Skip to content

Commit

Permalink
LaTeX: sync pdftex engine default imageresolution with pxunit
Browse files Browse the repository at this point in the history
Closes: sphinx-doc#8253

The 'pxunit' key from latex_elements tell how to handle image dimensions
specified in px units.

pdftex has another setting \pdfimageresolution which is used when an
image file does not provide readable or legit values for the x and/or y
resolution.

This commit syncs them: this way if an image will behave the same if
loaded with no explicit size set, or with one such size is set using px
unit, _and_ the graphics file does not have readable image resolution
data (or that data matches the 'pxunit' setting).

Works also with 'lualatex' as latex_engine.

Does not work with 'xelatex' and 'uplatex'.
  • Loading branch information
jfbu committed Jan 24, 2021
1 parent 0ad3290 commit c0807e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Bugs fixed
``:unknown:doc:``)
* #8711: LaTeX: backticks in code-blocks trigger latexpdf build warning (and font
change) with late TeXLive 2019
* #8253: LaTeX: Figures with no size defined get overscaled (compared to images
with size explicitly set in pixels) (fixed for `'pdflatex'/'lualatex'` only)

Testing
--------
Expand Down
3 changes: 3 additions & 0 deletions sphinx/templates/latex/latex.tex_t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
\ifdefined\pdfpxdimen
\let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
\fi \sphinxpxdimen=<%= pxunit %>\relax
\ifdefined\pdfimageresolution
\pdfimageresolution= \numexpr \dimexpr1in\relax/\sphinxpxdimen\relax
\fi
<% if use_xindy -%>
%% turn off hyperref patch of \index as sphinx.xdy xindy module takes care of
%% suitable \hyperpage mark-up, working around hyperref-xindy incompatibility
Expand Down

0 comments on commit c0807e9

Please sign in to comment.