michal-h21 / tex4ebook

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

New page not working #100

Closed alexandre1985 closed 1 year ago

alexandre1985 commented 1 year ago

I am able to create a epub file.

In the pages after my cover page, I am unable to set a new page. They are all put in sequence, without page breaks. On my pdf the output is correct.

The new page commands that I am using is:

\clearpage
\newpage
first page text
\vfill

\clearpage
\newpage
second page text
\vfill

Please help. I have a deadline on my book. Sorry...

ivanistheone commented 1 year ago

Do you want \clearpage instead of /clearpage maybe? Same for \newpage instead of /newpage.

There is also \cleardoublepage you can try (like clear page but makes sure next page is on the right)

alexandre1985 commented 1 year ago

Yes, I want that. I sorry for the misspell. In my book I am using \clearpage, etc.

My problem persists.

michal-h21 commented 1 year ago

In theory, this configuration file should work:


\Preamble{xhtml}
\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}
\Css{.newpage{page-break-before:always;}}
\begin{document}
\EndPreamble

I had similar question some time ago, and proposed a special command instead of \newpage or \clearpage, because I experienced issues with some commands that use \newpage internally. But if you don't run into this problems, this configuration should work. For some reason, it doesn't work in Calibre, but it can be a bug in viewer.

alexandre1985 commented 1 year ago
\Preamble{xhtml}
\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}
\Css{.newpage{page-break-before:always;}}
\begin{document}
\EndPreamble

pdflatex doesn't compile with this commands. It gives me

! Undefined control sequence.
l.110 \Preamble
               {xhtml}

Where exactly do I paste this lines of code?

Before \begin{document}? Before \documentclass? I have tried in a lot of places, and they all give me errors in compiling; either compiling with pdflatex or compiling with tex4ebook.

alexandre1985 commented 1 year ago

I got it. Thank @michal-h21 , it worked.

I have to put that code in a main.cfg file and run: tex4ebook -f epub3 -c main.cfg main.tex