This is a follow-up of this question of mine and uses the same setup.

How do I force tex4ebook to respect requests to go to a new page. Example:


The page breaks are ok using latex but are ignored by tex4ebook. Is there a way to fix this?



There are two things. First, page breaks doesn't really matter in HTML pages, so tex4ht doesn't try to preserve them. Second, \clearpage is used in quite a lot of LaTeX macros internally, so if you configure it to insert some code for page breaks, it may end at unexpected places.

Anyway, you can configure it using following configuration:

% save the clearpage before it is redefined by tex4ht
% define macro for newpage insertion
\def\mypagebreak{\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}}
% define it for \newpage
% modify \Configure{BODY} so our confiurations work on all extracted pages

This configurations redefines \clearpage to include <div class="newpage"></div> in the document, it does the same thing also for newpage, which has standard tex4ht configuration, as opposed with \clearpage, which must be redefined as macro. CSS is used for request page breaking. Finally, \clearpage must be cleared at end of each extracted page, it would otherwise output <div class="newpage"> after </html>, resulting in invalid HTML document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.