michal-h21 / tex4ebook

Converter from LaTeX to ebook formats (epub, mobi). Using tex4ht and texlua scripts.
301 stars 32 forks source link

Bit of an odd question: Forced orientation of images on ebook readers? #103

Open hanetzer opened 1 year ago

hanetzer commented 1 year ago

So, given any ebook reader, usually they have some non-square resolution to their display. Lets call it 1920x1080 for the sake of argument. Supposing I wish to include an image with the same 16:9 aspect ratio onto its own page in an ebook, it would obviously be better to keep this image aligned with the same orientation as the display, regardless of what settings one may use on their ebook reader. (for instance, I keep mine in landscape mode as its a bit easier on my eyes and reading style). Is this possible in ebooks in general, and can one set this up using tex4ebook somehow?

michal-h21 commented 1 year ago

If your Epub reader supports CSS, you can set all images to have a max-width same as is the width of the reader. In this way, images will be not cropped. Images smaller than the display are displayed in their full size. This can be done using this configuration:

\Preamble{xhtml} 
\Configure{Gin-dim}{} 
\Css{img { 
    max-width: 100\%; 
    height: auto; 
}} 
\begin{document} 
\EndPreamble

See also this how-to for more tricks.