2

In my MWE I specify the image rendering to be width=\textwidth. I generate the epub/html with tex4ebook main.tex. The generated html for the image sets width=289 and height=289 (even tho I didn't specify a height) which doesn't render well on some eReaders. If I edit the html and delete the height and specify width='100%' it renders perfectly on the couple eReaders I tested on.

Is there a reason width shouldn't be a percentage? If not, is there a way to tell tex4ebook to render at 100% (or any percentage)?

\documentclass[ebook]{memoir}
\usepackage{graphicx}
\graphicspath{ {images/ebook} }

\begin{document} Here's a png:\ \includegraphics[width=\textwidth]{chapter_ornament.png} \end{document}

Here's the generated html with width and height set to 289 (instead of 100%)

<?xml version='1.0' encoding='utf-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns='http://www.w3.org/1999/xhtml'> 
<head><title></title> 
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='originator' /> 
<!--  xhtml,charset=utf-8,epub,uni-html4,html  --> 
<meta content='main.tex' name='src' /> 
<link href='main.css' rel='stylesheet' type='text/css' /> 
</head><body>
<!-- l. 6 --><p class='noindent'>Here’s a png:<br class='newline' /><img alt='PIC' height='289' src='./images/ebook/chapter_ornament.jpg' width='289' />
</p>      
</body></html>
  • I think this is a duplicate of this question: https://tex.stackexchange.com/a/563314/2891 – michal.h21 Apr 21 '23 at 10:35
  • Thanks @michal.h21! It is a duplicate, but its solution isn't working me. Per the solution, I added \Configure{Gin-percent} to my tex4ebook.cfg and ran tex4ebook -l -c tex4ebook.cfg main.tex and my \includegraphics[width=\textwidth]{chapter_ornament.png} line still generates a width and height of 289. I'm running TeX Live 2023 and my packages are update to date. – buttonsrtoys Apr 22 '23 at 12:20
  • 1
    It shouldn't be \Configure{Gin-perecent}, but \Preamble{xhtml,Gin-percent}. Or use the config file itself, because I found that Gin-percent may not work as you would expect (it uses max-width instead of width CSS property). – michal.h21 Apr 22 '23 at 16:18
  • Awesome. Worked great. Thanks @michal.h21!!! – buttonsrtoys Apr 22 '23 at 21:51

0 Answers0