From c0807e9c652194be9ed59fe76c6e5bc05da3b287 Mon Sep 17 00:00:00 2001 From: jfbu Date: Sun, 24 Jan 2021 23:26:06 +0100 Subject: [PATCH] LaTeX: sync pdftex engine default imageresolution with pxunit Closes: #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'. --- CHANGES | 2 ++ sphinx/templates/latex/latex.tex_t | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 79226b31000..6a06abb47b0 100644 --- a/CHANGES +++ b/CHANGES @@ -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 -------- diff --git a/sphinx/templates/latex/latex.tex_t b/sphinx/templates/latex/latex.tex_t index 88efab8f0a2..9bfb3c3ff71 100644 --- a/sphinx/templates/latex/latex.tex_t +++ b/sphinx/templates/latex/latex.tex_t @@ -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