1

Whenever I try to introduce arbitrary cut points with tex4ebook, I'm getting the pages returned in a strange, incorrectly ordered way. Here's my MWE:

\newcommand{\mycut}{}
\begin{document}
A
\mycut{}
B
\mycut{}
C
\chapter{First}
D
\mycut{}
E
\end{document}

And my config file:

\Preamble{xhtml,svg,no-cut}
\NewSection\mycut{} 
\CutAt{chapter,chapter,mycut}
\CutAt{mycut,mycut,chapter}

I expected to see my MWE cut into 5 pages, with the pages being ordered like so:

A -> B -> C -> Chapter "First" + D (same page) -> E.

Instead, I get:

A -> Chapter "First" + D (same page) -> B -> C -> E.

Does anyone know why this is happening, and how I could instead introduce arbitrary cuts that will cut the way I described above?(In reality, outside my MWE, I would like arbitrary cuts to respect not just chapters correctly, but also sections and parts)

2
  • Sorry, I don't understand your term "cut points". Do you want to export specific parts as individual files?
    – MS-SPO
    Jun 25 at 12:46
  • 1
    More or less, yes. I want the created ebook to have page breaks at certain places that I am able to easily insert, for example between the half title and the title page, rather than both flowing onto the same page. Tex4ebook can handle doing this for chapters and other LaTeX sections, but I am looking to insert page cuts exactly where I want, regardless of chapters etc. And I want them to be sensibly ordered. See more here: kodymirus.cz/tex4ht-doc/Configurations.html#page-breaks Jun 25 at 13:07

1 Answer 1

1

TeX4ebook needs that all generated pages are recorded in the reading order using the \OpfRegisterFile command. You \mycut command doesn't do this, so the resulting pages are placed at the end of the Epub file, after the page produced by the \chapter command.

The following configuration file should fix that:

\Preamble{xhtml,svg,no-cut}
\NewSection\mycut{} 

\csgappto{c:mycut}{\OpfRegisterFile}%
\csgappto{c:chapter}{\OpfRegisterFile}%
\CutAt{chapter,chapter,mycut}
\CutAt{mycut,mycut,chapter}

\begin{document}
\EndPreamble

The important code is this:

\csgappto{c:mycut}{\OpfRegisterFile}%
\csgappto{c:chapter}{\OpfRegisterFile}%

This code adds the \OpfRegisterFile to the hook used by TeX4ht before the section title. It should ensure that the \OpfRegisterFile is called on the correct file.

2
  • Thanks Michal, works fantastically! One minor aside, do you know how I can use this with a ToC? Everything else is getting cut right where I want it to, but the ToC is ignoring the mycut commands completely, and is being included on the first page, despite chronologically it should be on about page 4. Jun 25 at 21:32
  • @ArneHeiko612 I think it could be actually hard to get them to TOC, because it uses only traditional sectioning commands by default. See kodymirus.cz/tex4ht-doc/Configurations.html#tables-of-contents for some configurations and commands related to TOC. I guess you would need to provide at least ∖ConfigureToc{mycut}, but probably also ∖Configure{tableofcontents*} that includes mycut.
    – michal.h21
    Jun 25 at 22:05

You must log in to answer this question.

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