3

Below is a MWE that renders text and an image of two circles and line:

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

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

enter image description here

After I convert with tex4ebook main.tex the image looks great on ReadEra but is broken on Mac Book.app:

enter image description here

Below is the generated HTML. I know eReaders vary, but Book.app can load images with other books. How do I get it to load my images?

<?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>
6
  • 1
    It seems like a Book.app bug? The file path seems to be OK. Try to use \graphicspath{ {images/ebook/} } command instead, maybe it has problem with the trailing ./.
    – michal.h21
    Commented Apr 20, 2023 at 12:01
  • @michal.h21 That was it! Thanks! Commented Apr 20, 2023 at 12:37
  • 1
    great! I will add a proper answer later.
    – michal.h21
    Commented Apr 20, 2023 at 12:46
  • Perfect! FYI, I found the trailing slash in images/ebook/ created paths like images/ebook//myimage.png so I dropped the trailing slash. Commented Apr 20, 2023 at 13:11
  • 1
    Yes, I found that too, it produces epubcheck error when you use trailing slash.
    – michal.h21
    Commented Apr 20, 2023 at 13:35

1 Answer 1

3

This seems to be caused by your \graphicspath command. When you use it in this way, the Graphics package constructs this image name:

./images/ebook//chapter_ornament.jpg

It seems that some Ebook readers don't support this form - both leading ./ and double slash seems to be a problem. It can be fixed easily, fortunately. Just use this graphics path:

 \graphicspath{ {images/ebook} }

It produces this file:

 images/ebook//chapter_ornament.jpg

which seems to work correctly

1
  • @BenVoigt you are right, my bad
    – michal.h21
    Commented Apr 20, 2023 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .