2

This is my first ever question.

I use TeXLive:

tex4ebook -c config -l filename.tex

One of my LaTeX sources contain the text of a whole printed book (several hundred pages) without any parts, chapters or sections. Calibre says: html file is too large, IPUB-Check says: epub is OK! Epub-readers, however, make extra page breaks as they seem convenient.

My question:

Can I insert my own, extra file break without ensuing page break into LaTeX-source? Or is it so that each separate html file starts from new page?

I solved this problem concocting my extra chapter title to make Calibre editor happy.

Thank you for this opportunity!

2
  • I would say that it is a bug in Calibre. Are you OK with sections that would be used only in the Epub version of your book?
    – michal.h21
    Commented Mar 20, 2021 at 11:04
  • It may not be a bug but a fair warning as there may be consequences. Commented Mar 21, 2021 at 6:23

1 Answer 1

1

I would say that this is a bug in Calibre. Anyway, if you really want to broke your huge HTML file into smaller ones, you can try this. First, a sample TeX file:

\documentclass{book}
\usepackage{lipsum}
\newcommand\breakhtml{}
\begin{document}

\chapter{Hello world}
\lipsum[1-4]

\breakhtml

\lipsum[5-6]

\breakhtml

\lipsum[7-9]
\end{document}

The important thing is the \breakhtml command. It does nothing in the PDF mode. For Epub, we need to redefine it to do something useful:

\Preamble{xhtml}
\renewcommand\breakhtml{\section[page break]{}}
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother
\CutAt{section,likesection,part}
\begin{document}
\EndPreamble

In this configuration file, we redefine the command to produce \section[page break]{}. This will produce section without text in the main text, but it will insert something to the main TOC. I found that some Epub readers can have problems if there is no text in the TOC entry, so this should fix that. Even if there is no text in the section, there is still section number. We remove it using \renewcommand{\@seccntformat}[1]{}. The last thing is that we tell tex4ebook to break HTML files at \section, because it doesn't by default for the book class.

To your last question, if a new HTML page produce page break? Yes, in general it does.

enter image description here

5
  • Html file size in my case is 267 kilo bytes. Epub readers in windows "cuts" these files causing extra page break. It's not fatal, looks only bad. At least Bluefire and Adobe Digital Editions do that. Freda don't. In iPad there is not such a problem. Commented Mar 21, 2021 at 5:56
  • tex4ebook is really magnificent program, thank you Michal! I have successfully made 37 e-books during last 5 months. I have used LaTeX from 90's. I scanned and converted the novels of my late father and then copied text files from Internet of several copyright free classics - all in Finnish. The problem with large html-files is cosmetic only. Certain e-book readers kind of cuts large files causing extra page break. I wanted to cut one particular file AND to avoid that extra page break. But, you confirmed my hunch that new html file starts a new page. So, I let it be, or use make my own chapter Commented Mar 21, 2021 at 6:15
  • @TimoKuronen thanks for you kind words. you project seems really interesting. are the ebooks available somewhere? I don't know any Finnish, but I am interested anyway :)
    – michal.h21
    Commented Mar 21, 2021 at 12:13
  • Not yet! I should be happy to tell more, but on which forum? Do you use Telegram? Commented Mar 21, 2021 at 16:02
  • @TimoKuronen I think I have Telegram, but I don't use it really. It is best to send me a mail to [email protected]
    – michal.h21
    Commented Mar 21, 2021 at 21:18

You must log in to answer this question.

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